• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ GUINT_TO_POINTER函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中GUINT_TO_POINTER函数的典型用法代码示例。如果您正苦于以下问题:C++ GUINT_TO_POINTER函数的具体用法?C++ GUINT_TO_POINTER怎么用?C++ GUINT_TO_POINTER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GUINT_TO_POINTER函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: read_document

bool read_document(PhraseLargeTable3 * phrase_table,
                   FacadePhraseIndex * phrase_index,
                   FILE * document,
                   HashofDocument hash_of_document,
                   HashofUnigram hash_of_unigram){

    char * linebuf = NULL;size_t size = 0;
    phrase_token_t last_token, cur_token = last_token = 0;

    while ( getline(&linebuf, &size, document) ){
        if ( feof(document) )
            break;

        if ( '\n' == linebuf[strlen(linebuf) - 1] ) {
            linebuf[strlen(linebuf) - 1] = '\0';
        }

        TAGLIB_PARSE_SEGMENTED_LINE(phrase_index, token, linebuf);

        last_token = cur_token;
        cur_token = token;

        /* skip null_token in second word. */
        if ( null_token == cur_token )
            continue;

        gpointer value = NULL;
        gboolean lookup_result = g_hash_table_lookup_extended
            (hash_of_unigram, GUINT_TO_POINTER(cur_token),
             NULL, &value);
        if ( !lookup_result ){
            g_hash_table_insert(hash_of_unigram, GUINT_TO_POINTER(cur_token),
                                GUINT_TO_POINTER(1));
        } else {
            guint32 freq = GPOINTER_TO_UINT(value);
            freq ++;
            g_hash_table_insert(hash_of_unigram, GUINT_TO_POINTER(cur_token),
                                GUINT_TO_POINTER(freq));
        }

        /* skip pi-gram training. */
        if ( null_token == last_token ){
            if ( !g_train_pi_gram )
                continue;
            last_token = sentence_start;
        }

        /* remember the (last_token, cur_token) word pair. */
        HashofSecondWord hash_of_second_word = NULL;
        lookup_result = g_hash_table_lookup_extended
            (hash_of_document, GUINT_TO_POINTER(last_token),
             NULL, &value);
        if ( !lookup_result ){
            hash_of_second_word = g_hash_table_new
                (g_direct_hash, g_direct_equal);
        } else {
            hash_of_second_word = (HashofSecondWord) value;
        }

        value = NULL;
        lookup_result = g_hash_table_lookup_extended
            (hash_of_second_word, GUINT_TO_POINTER(cur_token),
             NULL, &value);
        guint32 count = 0;
        if ( lookup_result ) {
            count = GPOINTER_TO_UINT(value);
        }
        count ++;
        g_hash_table_insert(hash_of_second_word,
                            GUINT_TO_POINTER(cur_token),
                            GUINT_TO_POINTER(count));
        g_hash_table_insert(hash_of_document,
                            GUINT_TO_POINTER(last_token),
                            hash_of_second_word);
    }

    free(linebuf);

    return true;
}
开发者ID:ii0,项目名称:libpinyin,代码行数:80,代码来源:gen_k_mixture_model.cpp


示例2: gstbt_wave_tab_syn_class_init

static void
gstbt_wave_tab_syn_class_init (GstBtWaveTabSynClass * klass)
{
  GObjectClass *gobject_class = (GObjectClass *) klass;
  GstElementClass *element_class = (GstElementClass *) klass;
  GstBtAudioSynthClass *audio_synth_class = (GstBtAudioSynthClass *) klass;
  GParamSpec *pspec;

  audio_synth_class->process = gstbt_wave_tab_syn_process;
  audio_synth_class->setup = gstbt_wave_tab_syn_setup;

  gobject_class->set_property = gstbt_wave_tab_syn_set_property;
  gobject_class->get_property = gstbt_wave_tab_syn_get_property;
  gobject_class->dispose = gstbt_wave_tab_syn_dispose;

  // describe us
  gst_element_class_set_static_metadata (element_class,
      "WaveTabSyn",
      "Source/Audio",
      "Wavetable synthesizer", "Stefan Sauer <[email protected]>");
  gst_element_class_add_metadata (element_class, GST_ELEMENT_METADATA_DOC_URI,
      "file://" DATADIR "" G_DIR_SEPARATOR_S "gtk-doc" G_DIR_SEPARATOR_S "html"
      G_DIR_SEPARATOR_S "" PACKAGE "" G_DIR_SEPARATOR_S "GstBtWaveTabSyn.html");

  // register own properties
  g_object_class_install_property (gobject_class, PROP_WAVE_CALLBACKS,
      g_param_spec_pointer ("wave-callbacks", "Wavetable Callbacks",
          "The wave-table access callbacks",
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class, PROP_TUNING,
      g_param_spec_enum ("tuning", "Tuning", "Harmonic tuning",
          GSTBT_TYPE_TONE_CONVERSION_TUNING,
          GSTBT_TONE_CONVERSION_EQUAL_TEMPERAMENT,
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class, PROP_NOTE,
      g_param_spec_enum ("note", "Musical note",
          "Musical note (e.g. 'c-3', 'd#4')", GSTBT_TYPE_NOTE, GSTBT_NOTE_NONE,
          G_PARAM_WRITABLE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class, PROP_NOTE_LENGTH,
      g_param_spec_uint ("length", "Note length", "Note length in ticks",
          1, 255, 1,
          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));

  pspec = g_param_spec_uint ("wave", "Wave", "Wave index", 1, 200, 1,
      G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS);
  g_param_spec_set_qdata (pspec, gstbt_property_meta_quark,
      GUINT_TO_POINTER (1));
  g_param_spec_set_qdata (pspec, gstbt_property_meta_quark_flags,
      GUINT_TO_POINTER (GSTBT_PROPERTY_META_WAVE));
  g_object_class_install_property (gobject_class, PROP_WAVE, pspec);

  g_object_class_install_property (gobject_class, PROP_OFFSET,
      g_param_spec_uint ("offset", "Offset", "Wave table offset", 0, 0xFFFF, 0,
          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class, PROP_ATTACK,
      g_param_spec_double ("attack", "Attack",
          "Volume attack of the tone in seconds", 0.001, 4.0, 0.1,
          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class, PROP_PEAK_VOLUME,
      g_param_spec_double ("peak-volume", "Peak Volume", "Peak volume of tone",
          0.0, 1.0, 0.8,
          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class, PROP_DECAY,
      g_param_spec_double ("decay", "Decay",
          "Volume decay of the tone in seconds", 0.001, 4.0, 0.5,
          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class, PROP_SUSTAIN_VOLUME,
      g_param_spec_double ("sustain-volume", "Sustain Volume",
          "Sustain volume of tone", 0.0, 1.0, 0.4,
          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));

  g_object_class_install_property (gobject_class, PROP_RELEASE,
      g_param_spec_double ("release", "RELEASE",
          "Volume release of the tone in seconds", 0.001, 4.0, 0.5,
          G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE | G_PARAM_STATIC_STRINGS));
}
开发者ID:Buzztrax,项目名称:gst-buzztrax,代码行数:83,代码来源:wavetabsyn.c


示例3: gui_init

void gui_init(dt_iop_module_t *self)
{
  self->gui_data = malloc(sizeof(dt_iop_levels_gui_data_t));
  dt_iop_levels_gui_data_t *c = (dt_iop_levels_gui_data_t *)self->gui_data;
  dt_iop_levels_params_t *p = (dt_iop_levels_params_t *)self->params;

  dt_pthread_mutex_init(&c->lock, NULL);

  dt_pthread_mutex_lock(&c->lock);
  c->auto_levels[0] = NAN;
  c->auto_levels[1] = NAN;
  c->auto_levels[2] = NAN;
  c->hash = 0;
  dt_pthread_mutex_unlock(&c->lock);

  c->modes = NULL;

  c->mouse_x = c->mouse_y = -1.0;
  c->dragging = 0;
  c->activeToggleButton = NULL;
  c->last_picked_color = -1;
  self->widget = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_VERTICAL, 5));
  dt_gui_add_help_link(self->widget, dt_get_help_url(self->op));

  c->mode = dt_bauhaus_combobox_new(self);
  dt_bauhaus_widget_set_label(c->mode, NULL, _("mode"));

  dt_bauhaus_combobox_add(c->mode, C_("mode", "manual"));
  c->modes = g_list_append(c->modes, GUINT_TO_POINTER(LEVELS_MODE_MANUAL));

  dt_bauhaus_combobox_add(c->mode, _("automatic"));
  c->modes = g_list_append(c->modes, GUINT_TO_POINTER(LEVELS_MODE_AUTOMATIC));

  dt_bauhaus_combobox_set_default(c->mode, LEVELS_MODE_MANUAL);
  dt_bauhaus_combobox_set(c->mode, g_list_index(c->modes, GUINT_TO_POINTER(p->mode)));
  gtk_box_pack_start(GTK_BOX(self->widget), c->mode, TRUE, TRUE, 0);

  c->mode_stack = gtk_stack_new();
  gtk_stack_set_homogeneous(GTK_STACK(c->mode_stack),FALSE);
  gtk_box_pack_start(GTK_BOX(self->widget), c->mode_stack, TRUE, TRUE, 0);

  c->area = GTK_DRAWING_AREA(dtgtk_drawing_area_new_with_aspect_ratio(9.0 / 16.0));
  GtkWidget *vbox_manual = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_VERTICAL, 5));
  gtk_box_pack_start(GTK_BOX(vbox_manual), GTK_WIDGET(c->area), TRUE, TRUE, 0);

  gtk_widget_set_tooltip_text(GTK_WIDGET(c->area),_("drag handles to set black, gray, and white points. "
                                                    "operates on L channel."));

  gtk_widget_add_events(GTK_WIDGET(c->area), GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK
                                             | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
                                             | GDK_LEAVE_NOTIFY_MASK | darktable.gui->scroll_mask);
  g_signal_connect(G_OBJECT(c->area), "draw", G_CALLBACK(dt_iop_levels_area_draw), self);
  g_signal_connect(G_OBJECT(c->area), "button-press-event", G_CALLBACK(dt_iop_levels_button_press), self);
  g_signal_connect(G_OBJECT(c->area), "button-release-event", G_CALLBACK(dt_iop_levels_button_release), self);
  g_signal_connect(G_OBJECT(c->area), "motion-notify-event", G_CALLBACK(dt_iop_levels_motion_notify), self);
  g_signal_connect(G_OBJECT(c->area), "leave-notify-event", G_CALLBACK(dt_iop_levels_leave_notify), self);
  g_signal_connect(G_OBJECT(c->area), "scroll-event", G_CALLBACK(dt_iop_levels_scroll), self);

  GtkWidget *autobutton = gtk_button_new_with_label(_("auto"));
  gtk_widget_set_tooltip_text(autobutton, _("apply auto levels"));
  gtk_widget_set_size_request(autobutton, -1, DT_PIXEL_APPLY_DPI(24));

  c->blackpick = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_FLAT, NULL);
  gtk_widget_set_tooltip_text(c->blackpick, _("pick black point from image"));

  c->greypick = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_FLAT, NULL);
  gtk_widget_set_tooltip_text(c->greypick, _("pick medium gray point from image"));

  c->whitepick = dtgtk_togglebutton_new(dtgtk_cairo_paint_colorpicker, CPF_STYLE_FLAT, NULL);
  gtk_widget_set_tooltip_text(c->whitepick, _("pick white point from image"));

  GdkRGBA color = { 0 };
  color.alpha = 1.0;
  dtgtk_togglebutton_override_color(DTGTK_TOGGLEBUTTON(c->blackpick), &color);
  color.red = color.green = color.blue = 0.5;
  dtgtk_togglebutton_override_color(DTGTK_TOGGLEBUTTON(c->greypick), &color);
  color.red = color.green = color.blue = 1.0;
  dtgtk_togglebutton_override_color(DTGTK_TOGGLEBUTTON(c->whitepick), &color);

  GtkWidget *box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, DT_PIXEL_APPLY_DPI(10));
  gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(autobutton), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(c->blackpick), TRUE, TRUE, 0);
  gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(c->greypick), TRUE, TRUE, 0);
  gtk_box_pack_end(GTK_BOX(box), GTK_WIDGET(c->whitepick), TRUE, TRUE, 0);

  gtk_box_pack_start(GTK_BOX(vbox_manual), box, TRUE, TRUE, 0);

  gtk_widget_show_all(vbox_manual);
  gtk_stack_add_named(GTK_STACK(c->mode_stack), vbox_manual, "manual");

  c->percentile_black = dt_bauhaus_slider_new_with_range(self, 0.0f, 100.0f, .1f, p->percentiles[0], 3);
  gtk_widget_set_tooltip_text(c->percentile_black, _("black percentile"));
  dt_bauhaus_slider_set_format(c->percentile_black, "%.1f%%");
  dt_bauhaus_widget_set_label(c->percentile_black, NULL, _("black"));

  c->percentile_grey = dt_bauhaus_slider_new_with_range(self, 0.0f, 100.0f, .1f, p->percentiles[1], 3);
  gtk_widget_set_tooltip_text(c->percentile_grey, _("gray percentile"));
  dt_bauhaus_slider_set_format(c->percentile_grey, "%.1f%%");
  dt_bauhaus_widget_set_label(c->percentile_grey, NULL, _("gray"));

//.........这里部分代码省略.........
开发者ID:christte,项目名称:darktable,代码行数:101,代码来源:levels.c


示例4: _wapi_accept

guint32 _wapi_accept(guint32 fd, struct sockaddr *addr, socklen_t *addrlen)
{
	gpointer handle = GUINT_TO_POINTER (fd);
	gpointer new_handle;
	struct _WapiHandle_socket *socket_handle;
	struct _WapiHandle_socket new_socket_handle = {0};
	gboolean ok;
	int new_fd;

	if (addr != NULL && *addrlen < sizeof(struct sockaddr)) {
		WSASetLastError (WSAEFAULT);
		return(INVALID_SOCKET);
	}
	
	if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
		WSASetLastError (WSAENOTSOCK);
		return(INVALID_SOCKET);
	}
	
	ok = _wapi_lookup_handle (handle, WAPI_HANDLE_SOCKET,
				  (gpointer *)&socket_handle);
	if (ok == FALSE) {
		g_warning ("%s: error looking up socket handle %p",
			   __func__, handle);
		WSASetLastError (WSAENOTSOCK);
		return(INVALID_SOCKET);
	}
	
	do {
		new_fd = accept (fd, addr, addrlen);
	} while (new_fd == -1 && errno == EINTR &&
		 !_wapi_thread_cur_apc_pending());

	if (new_fd == -1) {
		gint errnum = errno;
		DEBUG ("%s: accept error: %s", __func__, strerror(errno));

		errnum = errno_to_WSA (errnum, __func__);
		WSASetLastError (errnum);
		
		return(INVALID_SOCKET);
	}

	if (new_fd >= _wapi_fd_reserve) {
		DEBUG ("%s: File descriptor is too big", __func__);

		WSASetLastError (WSASYSCALLFAILURE);
		
		close (new_fd);
		
		return(INVALID_SOCKET);
	}

	new_socket_handle.domain = socket_handle->domain;
	new_socket_handle.type = socket_handle->type;
	new_socket_handle.protocol = socket_handle->protocol;
	new_socket_handle.still_readable = 1;

	new_handle = _wapi_handle_new_fd (WAPI_HANDLE_SOCKET, new_fd,
					  &new_socket_handle);
	if(new_handle == _WAPI_HANDLE_INVALID) {
		g_warning ("%s: error creating socket handle", __func__);
		WSASetLastError (ERROR_GEN_FAILURE);
		return(INVALID_SOCKET);
	}

	DEBUG ("%s: returning newly accepted socket handle %p with",
		   __func__, new_handle);
	
	return(new_fd);
}
开发者ID:RavenB,项目名称:mono,代码行数:71,代码来源:sockets.c


示例5: _wapi_getsockopt

int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval,
		     socklen_t *optlen)
{
	gpointer handle = GUINT_TO_POINTER (fd);
	int ret;
	struct timeval tv;
	void *tmp_val;
	struct _WapiHandle_socket *socket_handle;
	gboolean ok;
	
	if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
		WSASetLastError (WSAENOTSOCK);
		return(SOCKET_ERROR);
	}

	tmp_val = optval;
	if (level == SOL_SOCKET &&
	    (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
		tmp_val = &tv;
		*optlen = sizeof (tv);
	}

	ret = getsockopt (fd, level, optname, tmp_val, optlen);
	if (ret == -1) {
		gint errnum = errno;
		DEBUG ("%s: getsockopt error: %s", __func__,
			   strerror (errno));

		errnum = errno_to_WSA (errnum, __func__);
		WSASetLastError (errnum);
		
		return(SOCKET_ERROR);
	}

	if (level == SOL_SOCKET &&
	    (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO)) {
		*((int *) optval)  = tv.tv_sec * 1000 + (tv.tv_usec / 1000);	// milli from micro
		*optlen = sizeof (int);
	}

	if (optname == SO_ERROR) {
		ok = _wapi_lookup_handle (handle, WAPI_HANDLE_SOCKET,
					  (gpointer *)&socket_handle);
		if (ok == FALSE) {
			g_warning ("%s: error looking up socket handle %p",
				   __func__, handle);

			/* can't extract the last error */
			*((int *) optval) = errno_to_WSA (*((int *)optval),
							  __func__);
		} else {
			if (*((int *)optval) != 0) {
				*((int *) optval) = errno_to_WSA (*((int *)optval),
								  __func__);
				socket_handle->saved_error = *((int *)optval);
			} else {
				*((int *)optval) = socket_handle->saved_error;
			}
		}
	}
	
	return(ret);
}
开发者ID:RavenB,项目名称:mono,代码行数:63,代码来源:sockets.c


示例6: g_hash_table_lookup

/* dok_tree_root_get_decl_by_id:
 */
DokTree *dok_tree_root_get_decl_by_id ( DokTree *tree,
                                        DokTreeID id )
{
  return g_hash_table_lookup(DOK_TREE_ROOT(tree)->decls_by_id, GUINT_TO_POINTER(id));
}
开发者ID:deglingo,项目名称:dokidoc,代码行数:7,代码来源:doktree.c


示例7: WSAIoctl

int
WSAIoctl (guint32 fd, gint32 command,
	  gchar *input, gint i_len,
	  gchar *output, gint o_len, glong *written,
	  void *unused1, void *unused2)
{
	gpointer handle = GUINT_TO_POINTER (fd);
	int ret;
	gchar *buffer = NULL;

	if (_wapi_handle_type (handle) != WAPI_HANDLE_SOCKET) {
		WSASetLastError (WSAENOTSOCK);
		return SOCKET_ERROR;
	}

	if (command == SIO_GET_EXTENSION_FUNCTION_POINTER) {
		int i = 0;
		WapiGuid *guid = (WapiGuid *)input;
		
		if (i_len < sizeof(WapiGuid)) {
			/* As far as I can tell, windows doesn't
			 * actually set an error here...
			 */
			WSASetLastError (WSAEINVAL);
			return(SOCKET_ERROR);
		}

		if (o_len < sizeof(gpointer)) {
			/* Or here... */
			WSASetLastError (WSAEINVAL);
			return(SOCKET_ERROR);
		}

		if (output == NULL) {
			/* Or here */
			WSASetLastError (WSAEINVAL);
			return(SOCKET_ERROR);
		}
		
		while(extension_functions[i].func != NULL) {
			if (!memcmp (guid, &extension_functions[i].guid,
				     sizeof(WapiGuid))) {
				memcpy (output, &extension_functions[i].func,
					sizeof(gpointer));
				*written = sizeof(gpointer);
				return(0);
			}

			i++;
		}
		
		WSASetLastError (WSAEINVAL);
		return(SOCKET_ERROR);
	}

	if (command == SIO_KEEPALIVE_VALS) {
		uint32_t onoff;
		uint32_t keepalivetime;
		uint32_t keepaliveinterval;

		if (i_len < (3 * sizeof (uint32_t))) {
			WSASetLastError (WSAEINVAL);
			return SOCKET_ERROR;
		}
		memcpy (&onoff, input, sizeof (uint32_t));
		memcpy (&keepalivetime, input + sizeof (uint32_t), sizeof (uint32_t));
		memcpy (&keepaliveinterval, input + 2 * sizeof (uint32_t), sizeof (uint32_t));
		ret = setsockopt (fd, SOL_SOCKET, SO_KEEPALIVE, &onoff, sizeof (uint32_t));
		if (ret < 0) {
			gint errnum = errno;
			errnum = errno_to_WSA (errnum, __func__);
			WSASetLastError (errnum);
			return SOCKET_ERROR;
		}
		if (onoff != 0) {
#if defined(TCP_KEEPIDLE) && defined(TCP_KEEPINTVL)
			/* Values are in ms, but we need s */
			uint32_t rem;

			/* keepalivetime and keepaliveinterval are > 0 (checked in managed code) */
			rem = keepalivetime % 1000;
			keepalivetime /= 1000;
			if (keepalivetime == 0 || rem >= 500)
				keepalivetime++;
			ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPIDLE, &keepalivetime, sizeof (uint32_t));
			if (ret == 0) {
				rem = keepaliveinterval % 1000;
				keepaliveinterval /= 1000;
				if (keepaliveinterval == 0 || rem >= 500)
					keepaliveinterval++;
				ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPINTVL, &keepaliveinterval, sizeof (uint32_t));
			}
			if (ret != 0) {
				gint errnum = errno;
				errnum = errno_to_WSA (errnum, __func__);
				WSASetLastError (errnum);
				return SOCKET_ERROR;
			}
			return 0;
#endif
//.........这里部分代码省略.........
开发者ID:RavenB,项目名称:mono,代码行数:101,代码来源:sockets.c


示例8: g_return_val_if_fail

struct mwChannel *mwChannel_find(struct mwChannelSet *cs, guint32 chan) {
  g_return_val_if_fail(cs != NULL, NULL);
  g_return_val_if_fail(cs->map != NULL, NULL);
  return g_hash_table_lookup(cs->map, GUINT_TO_POINTER(chan));
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:5,代码来源:channel.c


示例9: crm_get_peer

crm_node_t *
crm_get_peer(unsigned int id, const char *uname)
{
    crm_node_t *node = NULL;
    CRM_ASSERT(id > 0 || uname != NULL);

    crm_peer_init();

    if (uname != NULL) {
        node = g_hash_table_lookup(crm_peer_cache, uname);
    }

    if (node == NULL && id > 0) {
        node = g_hash_table_lookup(crm_peer_id_cache, GUINT_TO_POINTER(id));

        if (node && node->uname && uname) {
            crm_crit("Node %s and %s share the same cluster node id '%u'!", node->uname, uname, id);
            
            /* NOTE: Calling crm_new_peer() means the entry in 
             * crm_peer_id_cache will point to the new entity
             */

            /* TODO: Replace the old uname instead? */
            node = crm_new_peer(id, uname);
            CRM_ASSERT(node->uname != NULL);
        }
    }

    if (node == NULL) {
        node = crm_new_peer(id, uname);
        if(uname) {
            const char *uuid = get_uuid(uname);
            crm_update_peer(__FUNCTION__, 0, 0, 0, -1, 0, uuid, uname, NULL, NULL);
        }
    }

    CRM_ASSERT(node);

    if (node && uname && node->uname == NULL) {
        node->uname = crm_strdup(uname);
        crm_info("Node %u is now known as %s", id, uname);
        g_hash_table_insert(crm_peer_cache, node->uname, node);
        if (crm_status_callback) {
            crm_status_callback(crm_status_uname, node, NULL);
        }
    }

    if (node && node->uname && node->uuid == NULL) {
        const char *uuid = get_node_uuid(id, node->uname);

        if (node->uuid) {
            crm_info("Node %u has uuid %s", id, node->uuid);
        } else if (uuid) {
            node->uuid = crm_strdup(uuid);
        }
    }

    if (node && id > 0 && id != node->id) {
        g_hash_table_remove(crm_peer_id_cache, GUINT_TO_POINTER(node->id));
        g_hash_table_insert(crm_peer_id_cache, GUINT_TO_POINTER(id), node);
        node->id = id;
        crm_info("Node %s now has id: %u", crm_str(uname), id);
    }

    return node;
}
开发者ID:esimone74,项目名称:pacemaker,代码行数:66,代码来源:membership.c


示例10: menu_info_item_get

menu_info_item_t* menu_info_item_get(menu_info_t* mi, uint32_t index)
{
    return g_hash_table_lookup(mi->items, GUINT_TO_POINTER(index));
}
开发者ID:KoviRobi,项目名称:pasystray,代码行数:4,代码来源:menu_info.c


示例11: get_supported

static struct mwCipherInstance *
get_supported(struct mwChannel *chan, guint16 id) {

  guint32 cid = (guint32) id;
  return g_hash_table_lookup(chan->supported, GUINT_TO_POINTER(cid));
}
开发者ID:Seldom,项目名称:miranda-ng,代码行数:6,代码来源:channel.c


示例12: menu_info_item_add

void menu_info_item_add(menu_info_t* mi, uint32_t index, const char* name,
        const char* desc, const pa_cvolume* vol, int mute, char* tooltip,
        const char* icon, const char* address)
{
    menu_infos_t* mis = mi->menu_infos;
    menu_info_item_t* item = g_new(menu_info_item_t, 1);
    menu_info_item_init(item);
    item->menu_info = mi;

#ifdef DEBUG
    g_message("[menu_info] adding %s %u %p", menu_info_type_name(mi->type), index, item);
#endif

    item->index = index;
    item->name = g_strdup(name);
    item->desc = g_strdup(desc);
    item->volume = g_memdup(vol, sizeof(pa_cvolume));
    item->mute = mute;
    item->icon = g_strdup(icon);
    item->address = g_strdup(address);

    switch(item->menu_info->type)
    {
        case MENU_INPUT:
            item->submenu = menu_info_create(mis, MENU_SINK);
            item->submenu->parent = item;
            break;
        case MENU_OUTPUT:
            item->submenu = menu_info_create(mis, MENU_SOURCE);
            item->submenu->parent = item;
            break;
        default:
            break;
    }

    switch(mi->type)
    {
        case MENU_SERVER:
            item->widget = systray_add_radio_item(mi, desc, tooltip);
            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget),
                    (item->address == mi->default_name) ||
                    (item->address && mi->default_name &&
                     g_str_equal(mi->default_name, item->address)));
            break;
        case MENU_SINK:
            item->context = menu_info_item_context_menu(item);
            item->widget = systray_add_radio_item(mi, desc, tooltip);
            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget),
                    g_str_equal(mi->default_name, item->name));
            systray_add_item_to_all_submenus(item, &mis->menu_info[MENU_INPUT]);
            break;
        case MENU_SOURCE:
            item->context = menu_info_item_context_menu(item);
            item->widget = systray_add_radio_item(mi, desc, tooltip);
            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item->widget),
                    g_str_equal(mi->default_name, item->name));
            systray_add_item_to_all_submenus(item, &mis->menu_info[MENU_OUTPUT]);
            break;
        case MENU_INPUT:
            item->widget = systray_menu_add_submenu(mi->menu, item->submenu,
                    desc, tooltip, icon);
            systray_add_all_items_to_submenu(&mis->menu_info[MENU_SINK], item);
            break;
        case MENU_OUTPUT:
            item->widget = systray_menu_add_submenu(mi->menu, item->submenu,
                    desc, tooltip, icon);
            systray_add_all_items_to_submenu(&mis->menu_info[MENU_SOURCE], item);
            break;
    }

    g_signal_connect(item->widget, "button-press-event",
            G_CALLBACK(menu_info_item_clicked), item);
    gtk_widget_add_events(item->widget, GDK_SCROLL_MASK);
    g_signal_connect(item->widget, "scroll-event",
            G_CALLBACK(menu_info_item_scrolled), item);

    if(mi->type == MENU_SERVER)
        g_hash_table_insert(mi->items, item->name, item);
    else
        g_hash_table_insert(mi->items, GUINT_TO_POINTER(index), item);

    /* if this is the default sink, update status icon acording to volume */
    if(mi->type == MENU_SINK && item == menu_info_item_get_by_name(mi, mi->default_name))
        ui_update_statusicon(item);
}
开发者ID:KoviRobi,项目名称:pasystray,代码行数:85,代码来源:menu_info.c


示例13: menu_info_item_update

void menu_info_item_update(menu_info_t* mi, uint32_t index, const char* name,
        const char* desc, const pa_cvolume* vol, int mute, char* tooltip,
        const char* icon, const char* address)
{
    menu_info_item_t* mii;

    if(mi->type == MENU_SERVER)
        mii = menu_info_item_get_by_name(mi, name);
    else
        mii = menu_info_item_get(mi, index);

   if(mii == NULL)
       return menu_info_item_add(mi, index, name, desc, vol, mute, tooltip, icon, address);

#ifdef DEBUG
    g_message("[menu_info] updating %s %u %s",
            menu_info_type_name(mii->menu_info->type), index, desc);
#endif

    g_free(mii->name);
    mii->name = g_strdup(name);
    g_free(mii->desc);
    mii->desc = g_strdup(desc);
    g_free(mii->volume);
    mii->volume = g_memdup(vol, sizeof(pa_cvolume));
    mii->mute = mute;
    g_free(mii->address);
    mii->address = g_strdup(address);

    switch(mi->type)
    {
        case MENU_SERVER:
        case MENU_SINK:
        case MENU_SOURCE:
            gtk_menu_item_set_label(GTK_MENU_ITEM(mii->widget), desc);
            systray_set_tooltip(GTK_WIDGET(mii->widget), tooltip);

            // submenu to update (if any)
            menu_info_t* submenu = NULL;
            switch(mi->type)
            {
                case MENU_SINK:
                    submenu = &mi->menu_infos->menu_info[MENU_INPUT];
                    break;
                case MENU_SOURCE:
                    submenu = &mi->menu_infos->menu_info[MENU_OUTPUT];
                    break;
                default:
                    break;
            }

            // change labels in stream submenus
            if(submenu)
            {
                GHashTableIter iter;
                gpointer key;
                menu_info_item_t* item;
                menu_info_item_t* subitem;

                g_hash_table_iter_init(&iter, submenu->items);
                while(g_hash_table_iter_next(&iter, &key, (gpointer*)&item))
                    if((subitem = g_hash_table_lookup(item->submenu->items,
                                    GUINT_TO_POINTER(mii->index))))
                        if(!g_str_equal(subitem->desc, desc))
                            gtk_menu_item_set_label(
                                    GTK_MENU_ITEM(subitem->widget), desc);
            }

            break;

       case MENU_INPUT:
       case MENU_OUTPUT:
            gtk_menu_item_set_label(GTK_MENU_ITEM(mii->widget), desc);
            systray_set_tooltip(GTK_WIDGET(mii->widget), tooltip);
            break;
    }

    /* if this is the default sink, update status icon acording to volume */
    if(mi->type == MENU_SINK && mii == menu_info_item_get_by_name(mi, mi->default_name))
        ui_update_statusicon(mii);
}
开发者ID:KoviRobi,项目名称:pasystray,代码行数:81,代码来源:menu_info.c


示例14: mono_arm_start_gsharedvt_call

gpointer
mono_arm_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg,
							   double *caller_fregs, double *callee_fregs)
{
	int i;

	/*
	 * The caller/callee regs are mapped to slot 0..3, stack slot 0 is mapped to slot 4, etc.
	 */

	/* Set vtype ret arg */
	if (info->vret_slot != -1) {
		callee [info->vret_arg_reg] = &callee [info->vret_slot];
	}

	for (i = 0; i < info->map_count; ++i) {
		int src = info->map [i * 2];
		int dst = info->map [(i * 2) + 1];
		int arg_marshal = (src >> 24) & 0xff;

		switch (arg_marshal) {
		case GSHAREDVT_ARG_NONE:
			callee [dst] = caller [src];
			break;
		case GSHAREDVT_ARG_BYVAL_TO_BYREF:
			/* gsharedvt argument passed by addr in reg/stack slot */
			src = src & 0xffff;
			callee [dst] = caller + src;
			break;
		case GSHAREDVT_ARG_BYREF_TO_BYVAL: {
			/* gsharedvt argument passed by value */
			int nslots = (src >> 8) & 0xff;
			int src_slot = src & 0xff;
			int j;
			gpointer *addr = (gpointer*)caller [src_slot];

			for (j = 0; j < nslots; ++j)
				callee [dst + j] = addr [j];
			break;
		}
		case GSHAREDVT_ARG_BYREF_TO_BYVAL_I1: {
			int src_slot = src & 0xff;
			gpointer *addr = (gpointer*)caller [src_slot];

			callee [dst] = GINT_TO_POINTER ((int)*(gint8*)addr);
			break;
		}
		case GSHAREDVT_ARG_BYREF_TO_BYVAL_I2: {
			int src_slot = src & 0xff;
			gpointer *addr = (gpointer*)caller [src_slot];

			callee [dst] = GINT_TO_POINTER ((int)*(gint16*)addr);
			break;
		}
		case GSHAREDVT_ARG_BYREF_TO_BYVAL_U1: {
			int src_slot = src & 0xff;
			gpointer *addr = (gpointer*)caller [src_slot];

			callee [dst] = GUINT_TO_POINTER ((guint)*(guint8*)addr);
			break;
		}
		case GSHAREDVT_ARG_BYREF_TO_BYVAL_U2: {
			int src_slot = src & 0xff;
			gpointer *addr = (gpointer*)caller [src_slot];

			callee [dst] = GUINT_TO_POINTER ((guint)*(guint16*)addr);
			break;
		}
		default:
			g_assert_not_reached ();
			break;
		}
	}

	/* The slot based approach above is very complicated, use a nested switch instead for fp regs */
	// FIXME: Use this for the other cases as well
	if (info->have_fregs) {
		CallInfo *caller_cinfo = info->caller_cinfo;
		CallInfo *callee_cinfo = info->callee_cinfo;
		int aindex;

		for (aindex = 0; aindex < caller_cinfo->nargs; ++aindex) {
			ArgInfo *ainfo = &caller_cinfo->args [aindex];
			ArgInfo *ainfo2 = &callee_cinfo->args [aindex];

			switch (ainfo->storage) {
			case RegTypeFP: {
				switch (ainfo2->storage) {
				case RegTypeFP:
					callee_fregs [ainfo2->reg / 2] = caller_fregs [ainfo->reg / 2];
					break;
				case RegTypeGSharedVtInReg:
					callee [ainfo2->reg] = &caller_fregs [ainfo->reg / 2];
					break;
				case RegTypeGSharedVtOnStack: {
					int sslot = ainfo2->offset / 4;
					callee [sslot + 4] = &caller_fregs [ainfo->reg / 2];
					break;
				}
				default:
//.........这里部分代码省略.........
开发者ID:LogosBible,项目名称:mono,代码行数:101,代码来源:tramp-arm-gsharedvt.c


示例15: __get_pairs_by_component

static void __get_pairs_by_component(GQueue *out, GTree *t, unsigned int component) {
	g_tree_find_all(out, t, __component_find, GUINT_TO_POINTER(component));
}
开发者ID:szcom,项目名称:rtpengine,代码行数:3,代码来源:ice.c


示例16: nm_connection_editor_inter_page_set_value

void
nm_connection_editor_inter_page_set_value (NMConnectionEditor *editor, InterPageChangeType type, gpointer value)
{
	g_hash_table_insert (editor->inter_page_hash, GUINT_TO_POINTER (type), value);
}
开发者ID:atulhjp,项目名称:network-manager-applet,代码行数:5,代码来源:nm-connection-editor.c


示例17: callback_function_collect

static GnmValue *
callback_function_collect (GnmEvalPos const *ep, GnmValue const *value,
			   void *closure)
{
	gnm_float x = 0;
	collect_floats_t *cl = closure;
	gboolean ignore = FALSE;

	switch (value ? value->v_any.type : VALUE_EMPTY) {
	case VALUE_EMPTY:
		if (cl->flags & COLLECT_IGNORE_BLANKS)
			ignore = TRUE;
		else if (cl->flags & COLLECT_ZERO_BLANKS)
			x = 0;
		else
			return value_new_error_VALUE (ep);
		break;

	case VALUE_BOOLEAN:
		if (cl->flags & COLLECT_IGNORE_BOOLS)
			ignore = TRUE;
		else if (cl->flags & COLLECT_ZEROONE_BOOLS)
			x = value_get_as_float (value);
		else
			return value_new_error_VALUE (ep);
		break;

	case VALUE_CELLRANGE :
	case VALUE_ARRAY :
		/* Ranges and arrays are not singleton values treat as errors */

	case VALUE_ERROR:
		if (cl->flags & COLLECT_IGNORE_ERRORS)
			ignore = TRUE;
		else if (cl->flags & COLLECT_ZERO_ERRORS)
			x = 0;
		else
			return value_new_error_VALUE (ep);
		break;

	case VALUE_FLOAT:
		x = value_get_as_float (value);
		break;

	case VALUE_STRING:
		if (cl->flags & COLLECT_COERCE_STRINGS) {
			GnmValue *vc = format_match_number (value_peek_string (value),
							    NULL,
							    cl->date_conv);
			gboolean bad = !vc || VALUE_IS_BOOLEAN (vc);
			if (vc) {
				x = value_get_as_float (vc);
				value_release (vc);
			} else
				x = 0;

			if (bad)
				return value_new_error_VALUE (ep);
		} else if (cl->flags & COLLECT_IGNORE_STRINGS)
			ignore = TRUE;
		else if (cl->flags & COLLECT_ZERO_STRINGS)
			x = 0;
		else
			return value_new_error_VALUE (ep);
		break;

	default:
		g_warning ("Trouble in callback_function_collect. (%d)",
			   value->v_any.type);
		ignore = TRUE;
	}

	if (ignore) {
		if (cl->flags & COLLECT_INFO)
			cl->info = g_slist_prepend (cl->info, GUINT_TO_POINTER (cl->count));
		else {
			return NULL;
		}
	}

	if (cl->count == cl->alloc_count) {
		cl->alloc_count = cl->alloc_count * 2 + 20;
		cl->data = g_renew (gnm_float, cl->data, cl->alloc_count);
	}

	cl->data[cl->count++] = x;
	return NULL;
}
开发者ID:nzinfo,项目名称:gnumeric,代码行数:88,代码来源:collect.c


示例18: nm_connection_editor_inter_page_get_value

gboolean
nm_connection_editor_inter_page_get_value (NMConnectionEditor *editor, InterPageChangeType type, gpointer *value)
{
	return g_hash_table_lookup_extended (editor->inter_page_hash, GUINT_TO_POINTER (type), NULL, value);
}
开发者ID:atulhjp,项目名称:network-manager-applet,代码行数:5,代码来源:nm-connection-editor.c


示例19: preferences_add_id

static void
preferences_add_id (EmpathyPreferences *preferences, guint id)
{
	preferences->notify_ids = g_list_prepend (preferences->notify_ids,
						  GUINT_TO_POINTER (id));
}
开发者ID:gcorvala,项目名称:gsoc2008,代码行数:6,代码来源:empathy-preferences.c


示例20: preferences_add_id

static void preferences_add_id (PreferencesDialog *prefs, guint id){
	prefs->notify_ids = g_list_prepend (prefs->notify_ids, GUINT_TO_POINTER (id));
}
开发者ID:uberchicgeekchick,项目名称:get2gnow,代码行数:3,代码来源:preferences.c



注:本文中的GUINT_TO_POINTER函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GUI_ALLOC_h2p函数代码示例发布时间:2022-05-30
下一篇:
C++ GUINT32_TO_LE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap