⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.c

📁 CORBA上的libIDL源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	msg = g_strdup_vprintf (fmt, args);	yyerrorl (msg, ofs);	va_end (args);	g_free (msg);}void yywarninglv (int level, const char *fmt, int ofs, ...){	gchar *msg;	va_list args;	va_start (args, ofs);	msg = g_strdup_vprintf (fmt, args);	yywarningl (level, msg, ofs);	va_end (args);	g_free (msg);}void yyerrorv (const char *fmt, ...){	gchar *msg;	va_list args;	va_start (args, fmt);	msg = g_strdup_vprintf (fmt, args);	yyerror (msg);	va_end (args);	g_free (msg);}void yywarningv (int level, const char *fmt, ...){	gchar *msg;	va_list args;	va_start (args, fmt);	msg = g_strdup_vprintf (fmt, args);	yywarning (level, msg);	va_end (args);	g_free (msg);}void IDL_tree_error (IDL_tree p, const char *fmt, ...){	char *file_save = __IDL_cur_filename;	int line_save = __IDL_cur_line;	gchar *msg;	va_list args;	if (p) {		__IDL_cur_filename = p->_file;		__IDL_cur_line = p->_line;	} else {		__IDL_cur_filename = NULL;		__IDL_cur_line = -1;	}	va_start (args, fmt);	msg = g_strdup_vprintf (fmt, args);	yyerror (msg);	va_end (args);	g_free (msg);	__IDL_cur_filename = file_save;	__IDL_cur_line = line_save;}void IDL_tree_warning (IDL_tree p, int level, const char *fmt, ...){	char *file_save = __IDL_cur_filename;	int line_save = __IDL_cur_line;	gchar *msg;	va_list args;	if (p) {		__IDL_cur_filename = p->_file;		__IDL_cur_line = p->_line;	} else {		__IDL_cur_filename = NULL;		__IDL_cur_line = -1;	}	va_start (args, fmt);	msg = g_strdup_vprintf (fmt, args);	yywarning (level, msg);	va_end (args);	g_free (msg);	__IDL_cur_filename = file_save;	__IDL_cur_line = line_save;}int IDL_tree_get_node_info (IDL_tree p, char **what, char **who){	int dienow = 0;	assert (what != NULL);	assert (who != NULL);	switch (IDL_NODE_TYPE (p)) {	case IDLN_TYPE_STRUCT:		*what = "structure definition";		*who = IDL_IDENT (IDL_TYPE_STRUCT (p).ident).str;		break;	case IDLN_TYPE_UNION:		*what = "union definition";		*who = IDL_IDENT (IDL_TYPE_UNION (p).ident).str;		break;	case IDLN_TYPE_ARRAY:		*what = "array";		*who = IDL_IDENT (IDL_TYPE_ARRAY (p).ident).str;		break;	case IDLN_TYPE_ENUM:		*what = "enumeration definition";		*who = IDL_IDENT (IDL_TYPE_ENUM (p).ident).str;		break;	case IDLN_IDENT:		*what = "identifier";		*who = IDL_IDENT (p).str;		break;	case IDLN_TYPE_DCL:		*what = "type definition";		assert (IDL_TYPE_DCL (p).dcls != NULL);		assert (IDL_NODE_TYPE (IDL_TYPE_DCL (p).dcls) == IDLN_LIST);		assert (IDL_LIST (IDL_TYPE_DCL (p).dcls)._tail != NULL);		assert (IDL_NODE_TYPE (IDL_LIST (IDL_TYPE_DCL (p).dcls)._tail) == IDLN_LIST);		*who = IDL_IDENT (IDL_LIST (IDL_LIST (IDL_TYPE_DCL (p).dcls)._tail).data).str;		break;	case IDLN_MEMBER:		*what = "member declaration";		assert (IDL_MEMBER (p).dcls != NULL);		assert (IDL_NODE_TYPE (IDL_MEMBER (p).dcls) == IDLN_LIST);		assert (IDL_LIST (IDL_MEMBER (p).dcls)._tail != NULL);		assert (IDL_NODE_TYPE (IDL_LIST (IDL_MEMBER (p).dcls)._tail) == IDLN_LIST);		*who = IDL_IDENT (IDL_LIST (IDL_LIST (IDL_MEMBER (p).dcls)._tail).data).str;		break;	case IDLN_NATIVE:		*what = "native declaration";		assert (IDL_NATIVE (p).ident != NULL);		assert (IDL_NODE_TYPE (IDL_NATIVE (p).ident) == IDLN_IDENT);		*who = IDL_IDENT (IDL_NATIVE (p).ident).str;		break;	case IDLN_LIST:		if (!IDL_LIST (p).data)			break;		dienow = IDL_tree_get_node_info (IDL_LIST (p).data, what, who);		break;	case IDLN_ATTR_DCL:		*what = "interface attribute";		assert (IDL_ATTR_DCL (p).simple_declarations != NULL);		assert (IDL_NODE_TYPE (IDL_ATTR_DCL (p).simple_declarations) == IDLN_LIST);		assert (IDL_LIST (IDL_ATTR_DCL (p).simple_declarations)._tail != NULL);		assert (IDL_NODE_TYPE (IDL_LIST (			IDL_ATTR_DCL (p).simple_declarations)._tail) == IDLN_LIST);		*who = IDL_IDENT (IDL_LIST (IDL_LIST (			IDL_ATTR_DCL (p).simple_declarations)._tail).data).str;		break;	case IDLN_PARAM_DCL:		*what = "operation parameter";		assert (IDL_PARAM_DCL (p).simple_declarator != NULL);		assert (IDL_NODE_TYPE (IDL_PARAM_DCL (p).simple_declarator) == IDLN_IDENT);		*who = IDL_IDENT (IDL_PARAM_DCL (p).simple_declarator).str;		break;	case IDLN_CONST_DCL:		*what = "constant declaration for";		*who = IDL_IDENT (IDL_CONST_DCL (p).ident).str;		break;	case IDLN_EXCEPT_DCL:		*what = "exception";		*who = IDL_IDENT (IDL_EXCEPT_DCL (p).ident).str;		break;	case IDLN_OP_DCL:		*what = "interface operation";		*who = IDL_IDENT (IDL_OP_DCL (p).ident).str;		break;	case IDLN_MODULE:		*what = "module";		*who = IDL_IDENT (IDL_MODULE (p).ident).str;		break;	case IDLN_FORWARD_DCL:		*what = "forward declaration";		*who = IDL_IDENT (IDL_FORWARD_DCL (p).ident).str;		break;	case IDLN_INTERFACE:		*what = "interface";		*who = IDL_IDENT (IDL_INTERFACE (p).ident).str;		break;	default:		g_warning ("Node type: %s\n", IDL_NODE_TYPE_NAME (p));		*what = "unknown (internal error)";		break;	}	return dienow;}static IDL_tree IDL_node_new (IDL_tree_type type){	IDL_tree p;	p = g_new0 (IDL_tree_node, 1);	if (p == NULL) {		yyerror ("IDL_node_new: memory exhausted");		return NULL;	}	IDL_NODE_TYPE (p) = type;	IDL_NODE_REFS (p) = 1;	p->_file = __IDL_cur_filename;	p->_line = __IDL_cur_line;	return p;}void __IDL_assign_up_node (IDL_tree up, IDL_tree node){	if (node == NULL)		return;	assert (node != up);	switch (IDL_NODE_TYPE (node)) {	case IDLN_LIST:		if (IDL_NODE_UP (node) == NULL)			for (; node != NULL; node = IDL_LIST (node).next)				IDL_NODE_UP (node) = up;		break;	default:		if (IDL_NODE_UP (node) == NULL)			IDL_NODE_UP (node) = up;		break;	}}void __IDL_assign_location (IDL_tree node, IDL_tree from_node){	assert (node != NULL);	if (from_node) {		node->_file = from_node->_file;		node->_line = from_node->_line;	}}void __IDL_assign_this_location (IDL_tree node, char *filename, int line){	assert (node != NULL);	node->_file = filename;	node->_line = line;}IDL_tree IDL_list_new (IDL_tree data){	IDL_tree p = IDL_node_new (IDLN_LIST);	__IDL_assign_up_node (p, data);	IDL_LIST (p).data = data;	IDL_LIST (p)._tail = p;	return p;}IDL_tree IDL_list_concat (IDL_tree orig, IDL_tree append){	IDL_tree p;	if (orig == NULL)		return append;	if (append == NULL)		return orig;	IDL_LIST (IDL_LIST (orig)._tail).next = append;	IDL_LIST (append).prev = IDL_LIST (orig)._tail;	IDL_LIST (orig)._tail = IDL_LIST (append)._tail;	/* Set tails on original */	for (p = IDL_LIST (orig).next; p && p != append; p = IDL_LIST (p).next)		IDL_LIST (p)._tail = IDL_LIST (orig)._tail;	/* Set up nodes on appended list */	for (p = append; p; p = IDL_LIST (p).next)		IDL_NODE_UP (p) = IDL_NODE_UP (orig);	return orig;}IDL_tree IDL_list_remove (IDL_tree list, IDL_tree p){	IDL_tree new_list = list;	if (IDL_LIST (p).prev == NULL) {		assert (list == p);		new_list = IDL_LIST (p).next;		if (new_list)			IDL_LIST (new_list).prev = NULL;	} else {		IDL_tree prev = IDL_LIST (p).prev;		IDL_tree next = IDL_LIST (p).next;		IDL_LIST (prev).next = next;		if (next)			IDL_LIST (next).prev = prev;	}	IDL_LIST (p).prev = NULL;	IDL_LIST (p).next = NULL;	IDL_LIST (p)._tail = p;	/* Not all tails updated... */	return new_list;}IDL_tree IDL_gentree_new (GHashFunc hash_func, GCompareFunc key_compare_func, IDL_tree data){	IDL_tree p = IDL_node_new (IDLN_GENTREE);	__IDL_assign_up_node (p, data);	IDL_GENTREE (p).data = data;	IDL_GENTREE (p).hash_func = hash_func;	IDL_GENTREE (p).key_compare_func = key_compare_func;	IDL_GENTREE (p).siblings = g_hash_table_new (hash_func, key_compare_func);	IDL_GENTREE (p).children = g_hash_table_new (hash_func, key_compare_func);	g_hash_table_insert (IDL_GENTREE (p).siblings, data, p);	return p;}IDL_tree IDL_gentree_new_sibling (IDL_tree from, IDL_tree data){	IDL_tree p = IDL_node_new (IDLN_GENTREE);	__IDL_assign_up_node (p, data);	IDL_GENTREE (p).data = data;	IDL_GENTREE (p).hash_func = IDL_GENTREE (from).hash_func;	IDL_GENTREE (p).key_compare_func = IDL_GENTREE (from).key_compare_func;	IDL_GENTREE (p).siblings = IDL_GENTREE (from).siblings;	IDL_GENTREE (p).children = g_hash_table_new (IDL_GENTREE (from).hash_func,						     IDL_GENTREE (from).key_compare_func);	return p;}IDL_tree IDL_integer_new (IDL_longlong_t value){	IDL_tree p = IDL_node_new (IDLN_INTEGER);	IDL_INTEGER (p).value = value;	return p;}IDL_tree IDL_string_new (char *value){	IDL_tree p = IDL_node_new (IDLN_STRING);	IDL_STRING (p).value = value;	return p;}IDL_tree IDL_wide_string_new (wchar_t *value){	IDL_tree p = IDL_node_new (IDLN_WIDE_STRING);	IDL_WIDE_STRING (p).value = value;	return p;}IDL_tree IDL_char_new (char *value){	IDL_tree p = IDL_node_new (IDLN_CHAR);	IDL_CHAR (p).value = value;	return p;}IDL_tree IDL_wide_char_new (wchar_t *value){	IDL_tree p = IDL_node_new (IDLN_WIDE_CHAR);	IDL_WIDE_CHAR (p).value = value;	return p;}IDL_tree IDL_fixed_new (char *value){	IDL_tree p = IDL_node_new (IDLN_FIXED);	IDL_FIXED (p).value = value;	return p;}IDL_tree IDL_float_new (double value){	IDL_tree p = IDL_node_new (IDLN_FLOAT);	IDL_FLOAT (p).value = value;	return p;}IDL_tree IDL_boolean_new (unsigned value){	IDL_tree p = IDL_node_new (IDLN_BOOLEAN);	IDL_BOOLEAN (p).value = value;	return p;}IDL_tree IDL_ident_new (char *str){	IDL_tree p = IDL_node_new (IDLN_IDENT);	IDL_IDENT (p).str = str;	return p;}IDL_tree IDL_member_new (IDL_tree type_spec, IDL_tree dcls){	IDL_tree p = IDL_node_new (IDLN_MEMBER);	__IDL_assign_up_node (p, type_spec);	__IDL_assign_up_node (p, dcls);	IDL_MEMBER (p).type_spec = type_spec;	IDL_MEMBER (p).dcls = dcls;	return p;}IDL_tree IDL_native_new (IDL_tree ident){	IDL_tree p = IDL_node_new (IDLN_NATIVE);	__IDL_assign_up_node (p, ident);	__IDL_assign_location (p, ident);	IDL_NATIVE (p).ident = ident;	return p;}IDL_tree IDL_type_dcl_new (IDL_tree type_spec, IDL_tree dcls){	IDL_tree p = IDL_node_new (IDLN_TYPE_DCL);	__IDL_assign_up_node (p, type_spec);	__IDL_assign_up_node (p, dcls);	__IDL_assign_location (p, IDL_LIST (dcls).data);	IDL_TYPE_DCL (p).type_spec = type_spec;	IDL_TYPE_DCL (p).dcls = dcls;	return p;}IDL_tree IDL_type_float_new (enum IDL_float_type f_type){	IDL_tree p = IDL_node_new (IDLN_TYPE_FLOAT);	IDL_TYPE_FLOAT (p).f_type = f_type;	return p;}IDL_tree IDL_type_fixed_new (IDL_tree positive_int_const,			     IDL_tree integer_lit){	IDL_tree p = IDL_node_new (IDLN_TYPE_FIXED);	__IDL_assign_up_node (p, positive_int_const);	__IDL_assign_up_node (p, integer_lit);	IDL_TYPE_FIXED (p).positive_int_const = positive_int_const;	IDL_TYPE_FIXED (p).integer_lit = integer_lit;	return p;}IDL_tree IDL_type_integer_new (unsigned f_signed, enum IDL_integer_type f_type){	IDL_tree p = IDL_node_new (IDLN_TYPE_INTEGER);	IDL_TYPE_INTEGER (p).f_signed = f_signed;	IDL_TYPE_INTEGER (p).f_type = f_type;	return p;}IDL_tree IDL_type_char_new (void){	return IDL_node_new (IDLN_TYPE_CHAR);}IDL_tree IDL_type_wide_char_new (void){	return IDL_node_new (IDLN_TYPE_WIDE_CHAR);}IDL_tree IDL_type_boolean_new (void){	return IDL_node_new (IDLN_TYPE_BOOLEAN);}IDL_tree IDL_type_octet_new (void){	return IDL_node_new (IDLN_TYPE_OCTET);}IDL_tree IDL_type_any_new (void){	return IDL_node_new (IDLN_TYPE_ANY);}IDL_tree IDL_type_object_new (void){	return IDL_node_new (IDLN_TYPE_OBJECT);}IDL_tree IDL_type_typecode_new (void){	return IDL_node_new (IDLN_TYPE_TYPECODE);}IDL_tree IDL_type_string_new (IDL_tree positive_int_const){	IDL_tree p = IDL_node_new (IDLN_TYPE_STRING);	__IDL_assign_up_node (p, positive_int_const);	IDL_TYPE_STRING (p).positive_int_const = positive_int_const;	return p;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -