static void MateCORBA_imodule_jam_int (IDL_tree src, CORBA_TypeCode tc, gpointer dest) { CORBA_long val = 0; switch (IDL_NODE_TYPE (src)) { case IDLN_BOOLEAN: val = IDL_BOOLEAN (src).value ? 1 : 0; break; case IDLN_CHAR: val = IDL_CHAR (src).value [0]; break; case IDLN_INTEGER: val = IDL_INTEGER (src).value; break; default: g_assert_not_reached (); break; } switch (tc->kind) { case CORBA_tk_boolean: case CORBA_tk_char: case CORBA_tk_octet: *(CORBA_boolean *) dest = val; break; case CORBA_tk_short: case CORBA_tk_ushort: *(CORBA_short *) dest = val; break; case CORBA_tk_long: case CORBA_tk_ulong: *(CORBA_long *) dest = val; break; default: g_assert_not_reached (); break; } }
void orte_idl_print_node(IDL_tree node, int indent_level) { IDL_tree curnode; char *s; do_indent(indent_level); if(node == NULL) { g_print("(null)\n"); return; } g_print("[%d] ", IDL_NODE_REFS(node)); switch(IDL_NODE_TYPE(node)) { case IDLN_NONE: g_print("NONE\n"); break; case IDLN_LIST: g_print("LIST:\n"); for(curnode = node; curnode; curnode = IDL_LIST(curnode).next) { orte_idl_print_node(IDL_LIST(curnode).data, indent_level + INDENT_INCREMENT_1); } break; case IDLN_GENTREE: break; case IDLN_INTEGER: g_print("INTEGER: %" IDL_LL "d\n", IDL_INTEGER(node).value); break; case IDLN_STRING: g_print("STRING: %s\n", IDL_STRING(node).value); break; case IDLN_WIDE_STRING: g_print("WIDE STRING: %ls\n", IDL_WIDE_STRING(node).value); break; case IDLN_CHAR: g_print("CHAR: %s\n", IDL_CHAR(node).value); break; case IDLN_WIDE_CHAR: g_print("WIDE CHAR: %ls\n", IDL_WIDE_CHAR(node).value); break; case IDLN_FIXED: g_print("FIXED: %s\n", IDL_FIXED(node).value); break; case IDLN_FLOAT: g_print("FLOAT: %f\n", IDL_FLOAT(node).value); break; case IDLN_BOOLEAN: g_print("BOOLEAN: %s\n", (IDL_BOOLEAN(node).value)?"True":"False"); break; case IDLN_IDENT: s = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(node), "_", 0); g_print("IDENT: %s NSQ: %s RID: \"%s\"\n", IDL_IDENT(node).str, s, IDL_IDENT_REPO_ID(node) ? IDL_IDENT_REPO_ID(node) : ""); g_free(s); break; case IDLN_TYPE_DCL: g_print("TYPE DCL:\n"); orte_idl_print_node(IDL_TYPE_DCL(node).type_spec, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("decls:\n"); orte_idl_print_node(IDL_TYPE_DCL(node).dcls, indent_level + INDENT_INCREMENT_2); break; case IDLN_CONST_DCL: g_print("CONST DCL:\n"); orte_idl_print_node(IDL_CONST_DCL(node).const_type, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("ident:\n"); orte_idl_print_node(IDL_CONST_DCL(node).ident, indent_level + INDENT_INCREMENT_2); do_indent(indent_level + INDENT_INCREMENT_1); g_print("const_exp:\n"); orte_idl_print_node(IDL_CONST_DCL(node).const_exp, indent_level + INDENT_INCREMENT_2); break; case IDLN_EXCEPT_DCL: g_print("EXCEPT DCL:\n"); orte_idl_print_node(IDL_EXCEPT_DCL(node).ident, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("members:\n"); orte_idl_print_node(IDL_EXCEPT_DCL(node).members, indent_level + INDENT_INCREMENT_2); break; case IDLN_ATTR_DCL: g_print("ATTR_DCL (%s):\n", (IDL_ATTR_DCL(node).f_readonly)?"readonly":"rw"); orte_idl_print_node(IDL_ATTR_DCL(node).param_type_spec, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("simple_declarations:\n"); orte_idl_print_node(IDL_ATTR_DCL(node).simple_declarations, indent_level + INDENT_INCREMENT_2); break; case IDLN_OP_DCL: g_print("OP DCL (%s):\n", (IDL_OP_DCL(node).f_oneway)?"oneway":"normal"); orte_idl_print_node(IDL_OP_DCL(node).ident, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("op_type_spec:\n"); orte_idl_print_node(IDL_OP_DCL(node).op_type_spec, indent_level + INDENT_INCREMENT_2); do_indent(indent_level + INDENT_INCREMENT_1); g_print("parameter_dcls:\n"); orte_idl_print_node(IDL_OP_DCL(node).parameter_dcls, indent_level + INDENT_INCREMENT_2); do_indent(indent_level + INDENT_INCREMENT_1); g_print("raises_expr:\n"); orte_idl_print_node(IDL_OP_DCL(node).raises_expr, indent_level + INDENT_INCREMENT_2); do_indent(indent_level + INDENT_INCREMENT_1); g_print("context_expr:\n"); orte_idl_print_node(IDL_OP_DCL(node).context_expr, indent_level + INDENT_INCREMENT_2); break; case IDLN_PARAM_DCL: g_print("PARAM DCL: "); switch(IDL_PARAM_DCL(node).attr) { case IDL_PARAM_IN: g_print("(in)\n"); break; case IDL_PARAM_OUT: g_print("(out)\n"); break; case IDL_PARAM_INOUT: g_print("(inout)\n"); break; } orte_idl_print_node(IDL_PARAM_DCL(node).param_type_spec, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("simple_declarator:\n"); orte_idl_print_node(IDL_PARAM_DCL(node).simple_declarator, indent_level + INDENT_INCREMENT_2); break; case IDLN_FORWARD_DCL: g_print("FORWARD DCL:\n"); orte_idl_print_node(IDL_FORWARD_DCL(node).ident, indent_level + INDENT_INCREMENT_1); break; case IDLN_INTERFACE: g_print("INTERFACE:\n"); orte_idl_print_node(IDL_INTERFACE(node).ident, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("inheritance_spec:\n"); orte_idl_print_node(IDL_INTERFACE(node).inheritance_spec, indent_level + INDENT_INCREMENT_2); do_indent(indent_level + INDENT_INCREMENT_1); g_print("body:\n"); orte_idl_print_node(IDL_INTERFACE(node).body, indent_level + INDENT_INCREMENT_2); break; case IDLN_MODULE: g_print("MODULE:\n"); orte_idl_print_node(IDL_MODULE(node).ident, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("definition_list:\n"); orte_idl_print_node(IDL_MODULE(node).definition_list, indent_level + INDENT_INCREMENT_2); break; case IDLN_TYPE_INTEGER: if(!IDL_TYPE_INTEGER(node).f_signed) g_print("TYPE unsigned "); switch(IDL_TYPE_INTEGER(node).f_type) { case IDL_INTEGER_TYPE_SHORT: g_print("short\n"); break; case IDL_INTEGER_TYPE_LONG: g_print("long\n"); break; case IDL_INTEGER_TYPE_LONGLONG: g_print("long long\n"); break; } break; case IDLN_TYPE_FLOAT: switch(IDL_TYPE_FLOAT(node).f_type) { case IDL_FLOAT_TYPE_FLOAT: g_print("TYPE float\n"); break; case IDL_FLOAT_TYPE_DOUBLE: g_print("TYPE double\n"); break; case IDL_FLOAT_TYPE_LONGDOUBLE: g_print("TYPE long double\n"); break; } break; case IDLN_TYPE_FIXED: g_print("TYPE fixed:\n"); orte_idl_print_node(IDL_TYPE_FIXED(node).positive_int_const, indent_level + INDENT_INCREMENT_1); orte_idl_print_node(IDL_TYPE_FIXED(node).integer_lit, indent_level + INDENT_INCREMENT_1); break; case IDLN_TYPE_STRING: g_print("TYPE string:\n"); orte_idl_print_node(IDL_TYPE_STRING(node).positive_int_const, indent_level + INDENT_INCREMENT_1); break; case IDLN_TYPE_WIDE_STRING: g_print("TYPE wide string:\n"); orte_idl_print_node(IDL_TYPE_WIDE_STRING(node).positive_int_const, indent_level + INDENT_INCREMENT_1); break; case IDLN_TYPE_ENUM: g_print("TYPE enum:\n"); orte_idl_print_node(IDL_TYPE_ENUM(node).ident, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("enumerator_list:\n"); orte_idl_print_node(IDL_TYPE_ENUM(node).enumerator_list, indent_level + INDENT_INCREMENT_2); break; case IDLN_TYPE_ARRAY: g_print("TYPE array:\n"); orte_idl_print_node(IDL_TYPE_ARRAY(node).ident, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("size_list:\n"); orte_idl_print_node(IDL_TYPE_ARRAY(node).size_list, indent_level + INDENT_INCREMENT_2); break; case IDLN_TYPE_SEQUENCE: g_print("TYPE sequence:\n"); orte_idl_print_node(IDL_TYPE_SEQUENCE(node).simple_type_spec, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("positive_int_const:\n"); orte_idl_print_node(IDL_TYPE_SEQUENCE(node).positive_int_const, indent_level + INDENT_INCREMENT_2); break; case IDLN_TYPE_STRUCT: g_print("TYPE struct:\n"); orte_idl_print_node(IDL_TYPE_STRUCT(node).ident, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("member_list:\n"); orte_idl_print_node(IDL_TYPE_STRUCT(node).member_list, indent_level + INDENT_INCREMENT_2); break; case IDLN_TYPE_UNION: g_print("TYPE union:\n"); orte_idl_print_node(IDL_TYPE_UNION(node).ident, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("switch_type_spec:\n"); orte_idl_print_node(IDL_TYPE_UNION(node).switch_type_spec, indent_level + INDENT_INCREMENT_2); do_indent(indent_level + INDENT_INCREMENT_1); g_print("switch_body:\n"); orte_idl_print_node(IDL_TYPE_UNION(node).switch_body, indent_level + INDENT_INCREMENT_2); break; case IDLN_MEMBER: g_print("MEMBER:\n"); orte_idl_print_node(IDL_MEMBER(node).type_spec, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("dcls:\n"); orte_idl_print_node(IDL_MEMBER(node).dcls, indent_level + INDENT_INCREMENT_2); break; case IDLN_CASE_STMT: g_print("CASE_STMT:\n"); orte_idl_print_node(IDL_CASE_STMT(node).labels, indent_level + INDENT_INCREMENT_1); do_indent(indent_level + INDENT_INCREMENT_1); g_print("element_spec:\n"); orte_idl_print_node(IDL_CASE_STMT(node).element_spec, indent_level + INDENT_INCREMENT_2); break; case IDLN_BINOP: g_print("BINOP "); switch(IDL_BINOP(node).op) { case IDL_BINOP_OR: g_print("or:\n"); break; case IDL_BINOP_XOR: g_print("xor:\n"); break; case IDL_BINOP_AND: g_print("and:\n"); break; case IDL_BINOP_SHR: g_print("shr:\n"); break; case IDL_BINOP_SHL: g_print("shl:\n"); break; case IDL_BINOP_ADD: g_print("add:\n"); break; case IDL_BINOP_SUB: g_print("sub:\n"); break; case IDL_BINOP_MULT: g_print("mult:\n"); break; case IDL_BINOP_DIV: g_print("div:\n"); break; case IDL_BINOP_MOD: g_print("mod:\n"); break; } do_indent(indent_level + INDENT_INCREMENT_1); g_print("left:\n"); orte_idl_print_node(IDL_BINOP(node).left, indent_level + INDENT_INCREMENT_2); do_indent(indent_level + INDENT_INCREMENT_1); g_print("right:\n"); orte_idl_print_node(IDL_BINOP(node).right, indent_level + INDENT_INCREMENT_2); break; case IDLN_UNARYOP: g_print("UNARYOP "); switch(IDL_UNARYOP(node).op) { case IDL_UNARYOP_PLUS: g_print("plus:\n"); break; case IDL_UNARYOP_MINUS: g_print("minus:\n"); break; case IDL_UNARYOP_COMPLEMENT: g_print("complement:\n"); break; } orte_idl_print_node(IDL_UNARYOP(node).operand, indent_level + INDENT_INCREMENT_1); break; case IDLN_TYPE_CHAR: g_print("TYPE char\n"); break; case IDLN_TYPE_WIDE_CHAR: g_print("TYPE wide char\n"); break; case IDLN_TYPE_BOOLEAN: g_print("TYPE boolean\n"); break; case IDLN_TYPE_OCTET: g_print("TYPE octet\n"); break; case IDLN_TYPE_OBJECT: g_print("TYPE object\n"); break; case IDLN_TYPE_ANY: g_print("TYPE any\n"); break; case IDLN_TYPE_TYPECODE: g_print("TYPE TypeCode\n"); break; case IDLN_CODEFRAG: g_print("CODEFRAG\n"); break; default: g_print("unhandled %d\n", IDL_NODE_TYPE(node)); } }
/* Writes the value of the constant in 'tree' to file handle 'of' */ static char * orbit_cbe_get_const(IDL_tree tree) { char *opc = NULL, *retval, *ctmp; GString *tmpstr = g_string_new(NULL); switch(IDL_NODE_TYPE(tree)) { case IDLN_BOOLEAN: g_string_printf(tmpstr, "%s", IDL_BOOLEAN(tree).value?"CORBA_TRUE":"CORBA_FALSE"); break; case IDLN_CHAR: g_string_printf(tmpstr, "'\\x%X'", *(unsigned char *)IDL_CHAR(tree).value); break; case IDLN_FLOAT: g_string_printf(tmpstr, "%f", IDL_FLOAT(tree).value); break; case IDLN_INTEGER: g_string_printf(tmpstr, "%" IDL_LL "d", IDL_INTEGER(tree).value); break; case IDLN_STRING: g_string_printf(tmpstr, "\"%s\"", IDL_STRING(tree).value); break; case IDLN_WIDE_CHAR: g_string_printf(tmpstr, "L'%ls'", IDL_WIDE_CHAR(tree).value); break; case IDLN_WIDE_STRING: g_string_printf(tmpstr, "L\"%ls\"", IDL_WIDE_STRING(tree).value); break; case IDLN_BINOP: g_string_printf(tmpstr, "("); ctmp = orbit_cbe_get_const(IDL_BINOP(tree).left); g_string_append(tmpstr, ctmp); g_free(ctmp); switch(IDL_BINOP(tree).op) { case IDL_BINOP_OR: opc = "|"; break; case IDL_BINOP_XOR: opc = "^"; break; case IDL_BINOP_AND: opc = "&"; break; case IDL_BINOP_SHR: opc = ">>"; break; case IDL_BINOP_SHL: opc = "<<"; break; case IDL_BINOP_ADD: opc = "+"; break; case IDL_BINOP_SUB: opc = "-"; break; case IDL_BINOP_MULT: opc = "*"; break; case IDL_BINOP_DIV: opc = "/"; break; case IDL_BINOP_MOD: opc = "%"; break; } g_string_append_printf(tmpstr, " %s ", opc); ctmp = orbit_cbe_get_const(IDL_BINOP(tree).right); g_string_append_printf(tmpstr, "%s)", ctmp); g_free(ctmp); break; case IDLN_UNARYOP: switch(IDL_UNARYOP(tree).op) { case IDL_UNARYOP_PLUS: opc = "+"; break; case IDL_UNARYOP_MINUS: opc = "-"; break; case IDL_UNARYOP_COMPLEMENT: opc = "~"; break; } ctmp = orbit_cbe_get_const(IDL_UNARYOP(tree).operand); g_string_printf(tmpstr, "%s%s", opc, ctmp); g_free(ctmp); break; case IDLN_IDENT: { char *id; id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(tree), "_", 0); g_string_printf(tmpstr, "%s", id); g_free(id); } break; default: g_error("We were asked to print a constant for %s", IDL_tree_type_names[tree->_type]); break; } retval = tmpstr->str; g_string_free(tmpstr, FALSE); return retval; }