IDL_tree IDL_ns_place_new (IDL_ns ns, IDL_tree ident) { IDL_tree p, up_save; gboolean does_conflict; IDL_NS_ASSERTS; p = IDL_ns_lookup_cur_scope (ns, ident, &does_conflict); if (p != NULL && does_conflict) return NULL; /* The namespace tree is separate from the primary parse tree, so keep the primary tree node's parent the same */ up_save = IDL_NODE_UP (ident); p = IDL_gentree_chain_child (IDL_NS (ns).current, ident); IDL_NODE_UP (ident) = up_save; if (p == NULL) return NULL; assert (IDL_NODE_TYPE (p) == IDLN_GENTREE); IDL_IDENT_TO_NS (ident) = p; assert (IDL_NODE_UP (IDL_IDENT_TO_NS (ident)) == IDL_NS (ns).current); /* Generate default repository ID */ IDL_IDENT_REPO_ID (ident) = IDL_ns_ident_make_repo_id (__IDL_root_ns, p, NULL, NULL, NULL); return p; }
IDL_tree IDL_ns_lookup_this_scope (IDL_ns ns, IDL_tree scope, IDL_tree ident, gboolean *conflict) { IDL_tree p, q; IDL_NS_ASSERTS; if (conflict) *conflict = TRUE; if (scope == NULL) return NULL; assert (IDL_NODE_TYPE (scope) == IDLN_GENTREE); /* Search this namespace */ if (g_hash_table_lookup_extended ( IDL_GENTREE (scope).children, ident, NULL, (gpointer)&p)) { assert (IDL_GENTREE (p).data != NULL); assert (IDL_NODE_TYPE (IDL_GENTREE (p).data) == IDLN_IDENT); return p; } /* If there are inherited namespaces, look in those before giving up */ q = IDL_GENTREE (scope)._import; if (!q) return NULL; assert (IDL_NODE_TYPE (q) == IDLN_LIST); for (; q != NULL; q = IDL_LIST (q).next) { IDL_tree r; assert (IDL_LIST (q).data != NULL); assert (IDL_NODE_TYPE (IDL_LIST (q).data) == IDLN_IDENT); assert (IDL_IDENT_TO_NS (IDL_LIST (q).data) != NULL); assert (IDL_NODE_TYPE (IDL_IDENT_TO_NS (IDL_LIST (q).data)) == IDLN_GENTREE); /* Search imported namespace scope q */ if (g_hash_table_lookup_extended ( IDL_GENTREE (IDL_IDENT_TO_NS (IDL_LIST (q).data)).children, ident, NULL, (gpointer)&p)) { assert (IDL_GENTREE (p).data != NULL); assert (IDL_NODE_TYPE (IDL_GENTREE (p).data) == IDLN_IDENT); /* This needs more work, it won't do full ambiguity detection */ if (conflict && !is_inheritance_conflict (p)) *conflict = FALSE; return p; } /* Search up one level */ if (IDL_NODE_TYPE (IDL_NODE_UP (IDL_LIST (q).data)) == IDLN_INTERFACE && (r = IDL_ns_lookup_this_scope ( ns, IDL_IDENT_TO_NS (IDL_LIST (q).data), ident, conflict))) return r; } return NULL; }
/* Return true if adds went okay */ static int IDL_ns_load_idents_to_tables (IDL_tree interface_ident, IDL_tree ident_scope, GTree *ident_heap, GHashTable *visited_interfaces) { IDL_tree q, scope; InsertHeapData data; assert (ident_scope != NULL); assert (IDL_NODE_TYPE (ident_scope) == IDLN_IDENT); scope = IDL_IDENT_TO_NS (ident_scope); if (!scope) return TRUE; assert (IDL_NODE_TYPE (scope) == IDLN_GENTREE); assert (IDL_GENTREE (scope).data != NULL); assert (IDL_NODE_TYPE (IDL_GENTREE (scope).data) == IDLN_IDENT); assert (IDL_NODE_UP (IDL_GENTREE (scope).data) != NULL); assert (IDL_NODE_TYPE (IDL_NODE_UP (IDL_GENTREE (scope).data)) == IDLN_INTERFACE); if (is_visited_interface (visited_interfaces, scope)) return TRUE; /* Search this namespace */ data.interface_ident = interface_ident; data.ident_heap = ident_heap; data.insert_conflict = 0; g_hash_table_foreach (IDL_GENTREE (scope).children, (GHFunc)insert_heap_cb, &data); /* If there are inherited namespaces, look in those before giving up */ q = IDL_GENTREE (scope)._import; if (!q) data.insert_conflict = 0; else assert (IDL_NODE_TYPE (q) == IDLN_LIST); /* Add inherited namespace identifiers into heap */ for (; q != NULL; q = IDL_LIST (q).next) { int r; assert (IDL_LIST (q).data != NULL); assert (IDL_NODE_TYPE (IDL_LIST (q).data) == IDLN_IDENT); assert (IDL_IDENT_TO_NS (IDL_LIST (q).data) != NULL); assert (IDL_NODE_TYPE (IDL_IDENT_TO_NS (IDL_LIST (q).data)) == IDLN_GENTREE); assert (IDL_NODE_TYPE (IDL_NODE_UP (IDL_LIST (q).data)) == IDLN_INTERFACE); if (!(r = IDL_ns_load_idents_to_tables (interface_ident, IDL_LIST (q).data, ident_heap, visited_interfaces))) data.insert_conflict = 1; } mark_visited_interface (visited_interfaces, scope); return data.insert_conflict == 0; }
static void cc_output_skel (IDL_tree tree, OIDL_C_Info *ci, int *idx) { IDL_tree intf; gboolean has_args; gboolean has_retval; char *opname; char *ifname; g_return_if_fail (idx != NULL); intf = IDL_get_parent_node (tree, IDLN_INTERFACE, NULL); has_args = IDL_OP_DCL (tree).parameter_dcls != NULL; has_retval = IDL_OP_DCL (tree).op_type_spec != NULL; opname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_OP_DCL (tree).ident), "_", 0); ifname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_INTERFACE (intf).ident), "_", 0); fprintf (ci->fh, "void _ORBIT_skel_small_%s(" "POA_%s *_o_servant, " "gpointer _o_retval," "gpointer *_o_args," "CORBA_Context _o_ctx," "CORBA_Environment *_o_ev,\n", opname, ifname); orbit_cbe_op_write_proto (ci->fh, tree, "_impl_", TRUE); fprintf (ci->fh, ") {\n"); if (has_retval) { fprintf (ci->fh, "*("); orbit_cbe_write_param_typespec (ci->fh, tree); fprintf (ci->fh, " *)_o_retval = "); } fprintf (ci->fh, "_impl_%s (_o_servant, ", IDL_IDENT (IDL_OP_DCL (tree).ident).str); orbit_cbe_unflatten_args (tree, ci->fh, "_o_args"); if (IDL_OP_DCL (tree).context_expr) fprintf (ci->fh, "_o_ctx, "); fprintf (ci->fh, "_o_ev);\n"); fprintf (ci->fh, "}\n"); g_free (opname); g_free (ifname); (*idx)++; }
static void VoyagerOutputOverridenMethodTemplate(IDL_tree curif, InheritedOutputInfo2 *ioi) { char *id, *realid; IDL_tree curitem; char* overridenMethodName; if(curif == ioi->realif) return; overridenMethodName=ioi->chrOverridenMethodName; realid = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(ioi->realif).ident), "_", 0); id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(curif).ident), "_", 0); for(curitem = IDL_INTERFACE(curif).body; curitem; curitem = IDL_LIST(curitem).next) { IDL_tree curop = IDL_LIST(curitem).data; switch(IDL_NODE_TYPE(curop)) { case IDLN_OP_DCL: { /* Check if the current method (introduced by some parent) is the one to be overriden. */ if(!strcmp(overridenMethodName, IDL_IDENT(IDL_OP_DCL(curop).ident).str)){ fprintf(ioi->of, "/* Call parent */\n"); fprintf(ioi->of, "/* %s_%s_parent_resolved()*/\n", realid, IDL_IDENT(IDL_OP_DCL(curop).ident).str); #if 0 fprintf(ioi->of, "#define %s_%s() \\\n %s_%s()\n", realid, IDL_IDENT(IDL_OP_DCL(curop).ident).str, id, IDL_IDENT(IDL_OP_DCL(curop).ident).str); #endif } break; } default: break; } } g_free(id); g_free(realid); }
/* If insertion was made, return true, else there was a collision */ static gboolean heap_insert_ident (IDL_tree interface_ident, GTree *heap, IDL_tree any) { IDL_tree p; assert (any != NULL); assert (heap != NULL); if ((p = g_tree_lookup (heap, any))) { char *newi; char *i1, *i2; char *what1 = "identifier", *what2 = what1; char *who1, *who2; IDL_tree q; assert (IDL_NODE_TYPE (p) == IDLN_IDENT); newi = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (interface_ident), "::", 0); i1 = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (p), "::", 0); i2 = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (any), "::", 0); q = p; while (q && (IDL_NODE_TYPE (q) == IDLN_IDENT || IDL_NODE_TYPE (q) == IDLN_LIST)) q = IDL_NODE_UP (q); assert (q != NULL); IDL_tree_get_node_info (q, &what1, &who1); q = any; while (q && (IDL_NODE_TYPE (q) == IDLN_IDENT || IDL_NODE_TYPE (q) == IDLN_LIST)) q = IDL_NODE_UP (q); assert (q != NULL); IDL_tree_get_node_info (q, &what2, &who2); yyerrorv ("Ambiguous inheritance in interface `%s' from %s `%s' and %s `%s'", newi, what1, i1, what2, i2); IDL_tree_error (p, "%s `%s' conflicts with", what1, i1); IDL_tree_error (any, "%s `%s'", what2, i2); g_free (newi); g_free (i1); g_free (i2); return FALSE; } g_tree_insert (heap, any, any); return TRUE; }
static void cc_output_class_id (IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci) { char *iface_id; iface_id = IDL_ns_ident_to_qstring ( IDL_IDENT_TO_NS (IDL_INTERFACE (tree).ident), "_", 0); fprintf (ci->fh, "\n#ifndef ORBIT_IDL_C_IMODULE_%s\n",ci->c_base_name); fprintf (ci->fh, "CORBA_unsigned_long %s__classid = 0;\n", iface_id); fprintf (ci->fh, "#endif\n"); g_free (iface_id); }
static void VoyagerWriteProtoForParentCall (FILE *of, IDL_tree op, const char *nom_prefix, gboolean for_epv) { char *id; char * id2; char * ptr; IDL_tree tmptree; g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL); // orbit_cbe_write_param_typespec (of, op); id = IDL_ns_ident_to_qstring ( IDL_IDENT_TO_NS (IDL_INTERFACE ( IDL_get_parent_node (op, IDLN_INTERFACE, NULL)).ident), "_", 0); id2=g_strdup(IDL_IDENT (IDL_OP_DCL (op).ident).str); if((ptr=strstr(id2, NOM_OVERRIDE_STRING))!=NULL) *ptr='\0'; fprintf (of, " /* %s, %s line %d */\n", __FILE__, __FUNCTION__, __LINE__); fprintf (of, " %s%s_%s_parent", nom_prefix ? nom_prefix : "", id, id2); fprintf (of, "("); fprintf (of, "nomSelf, "); tmptree = IDL_get_parent_node(op, IDLN_INTERFACE, NULL); if(IDL_INTERFACE(tmptree).inheritance_spec) { InheritedOutputInfo2 ioi; ioi.of = of; ioi.realif = tmptree; ioi.chrOverridenMethodName=id2; ioi.chrOverridenMethodName=""; IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerWriteParamsForParentCall, &ioi); } g_free(id2); g_free (id); fprintf (of, " ev);\n"); }
void orte_idl_attr_fake_ops(IDL_tree attr, IDL_ns ns) { IDL_tree attr_name, ident, curnode, op1, op2, intf; GString *attrname; OIDL_Attr_Info *setme; g_assert(attr && IDL_NODE_TYPE(attr) == IDLN_ATTR_DCL); attrname = g_string_new(NULL); for(curnode = IDL_ATTR_DCL(attr).simple_declarations; curnode; curnode = IDL_LIST(curnode).next) { op1 = op2 = NULL; attr_name = IDL_LIST(curnode).data; g_string_printf(attrname, "_get_%s", IDL_IDENT(attr_name).str); ident = IDL_ident_new(g_strdup(attrname->str)); IDL_IDENT_TO_NS(ident) = IDL_IDENT_TO_NS(attr_name); op1 = IDL_op_dcl_new(0, IDL_ATTR_DCL(attr).param_type_spec, ident, NULL, NULL, NULL); IDL_NODE_UP(op1) = IDL_NODE_UP(attr); intf = IDL_NODE_UP (IDL_NODE_UP (op1)); IDL_NS(ns).current = IDL_IDENT_TO_NS (IDL_INTERFACE (intf).ident); IDL_ns_place_new(ns, ident); if(!IDL_ATTR_DCL(attr).f_readonly) { g_string_printf(attrname, "_set_%s", IDL_IDENT(attr_name).str); ident = IDL_ident_new(g_strdup(attrname->str)); IDL_IDENT_TO_NS(ident) = IDL_IDENT_TO_NS(attr_name); op2 = IDL_op_dcl_new(0, NULL, ident, NULL, NULL, NULL); IDL_NODE_UP(op2) = IDL_NODE_UP(attr); intf = IDL_NODE_UP (IDL_NODE_UP (op2)); IDL_NS(ns).current = IDL_IDENT_TO_NS (IDL_INTERFACE (intf).ident); IDL_ns_place_new(ns, ident); IDL_OP_DCL(op2).parameter_dcls = IDL_list_new( IDL_param_dcl_new(IDL_PARAM_IN, IDL_ATTR_DCL(attr).param_type_spec, IDL_ident_new(g_strdup("value")))); } setme = g_new0(OIDL_Attr_Info, 1); setme->op1 = op1; setme->op2 = op2; attr_name->data = setme; } g_string_free(attrname, TRUE); }
/* This function returns the interface name from the given tree. It returns the first name found. Works for what it's build for (getting the toplevel name for single class IDL files). No idea what happens with files containing several interfaces... */ static void VoyagerFindInterfaceName(IDL_tree tree, char** iface_id) { if (!tree) return; switch (IDL_NODE_TYPE (tree)) { case IDLN_MODULE: break; case IDLN_LIST: { IDL_tree sub; for (sub = tree; sub; sub = IDL_LIST (sub).next){ VoyagerFindInterfaceName((IDL_LIST (sub).data), iface_id); } break; } case IDLN_ATTR_DCL: { break; } case IDLN_INTERFACE: { VoyagerFindInterfaceName(IDL_INTERFACE (tree).body, iface_id); break; } case IDLN_OP_DCL: { char *priviface_id = IDL_ns_ident_to_qstring ( IDL_IDENT_TO_NS (IDL_INTERFACE ( IDL_get_parent_node (tree, IDLN_INTERFACE, NULL) ).ident), "_", 0); //printf("----------> %s\n", priviface_id); if(priviface_id) *iface_id=priviface_id; /* This is a copy */ break; } default: break; } return; }
/* Overriden methods are introduced by some parent class. This function gets the parent node and climbs down the list of classes to find the one introducing the method. A support function called for every node while traversing actually writes the info. */ static void VoyagerWriteParamsForOverridenMethod(FILE *of, IDL_tree op, const char *nom_prefix, gboolean for_epv) { char *id; char * id2; char * ptr; IDL_tree tmptree; g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL); id = IDL_ns_ident_to_qstring ( IDL_IDENT_TO_NS (IDL_INTERFACE ( IDL_get_parent_node (op, IDLN_INTERFACE, NULL)).ident), "_", 0); id2=g_strdup(IDL_IDENT (IDL_OP_DCL (op).ident).str); if((ptr=strstr(id2, NOM_OVERRIDE_STRING))!=NULL) *ptr='\0'; tmptree = IDL_get_parent_node(op, IDLN_INTERFACE, NULL); if(IDL_INTERFACE(tmptree).inheritance_spec) { InheritedOutputInfo2 ioi; ioi.of = of; ioi.realif = tmptree; ioi.chrOverridenMethodName=id2; ioi.chrClassName=id; /* The current class name. In the called function the parent is searched introducing the method. When this parent is found, the current class info isn't easy to get again but it's needed. */ IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerDoWriteParamsForOverridenMethod, &ioi); } g_free(id2); g_free (id); }
gchar *IDL_ns_ident_to_qstring (IDL_tree ns_ident, const char *join, int levels) { IDL_tree l, q; int len, joinlen; char *s; int count = 0, start_level; if (levels < 0 || levels > 64) return NULL; if (ns_ident == NULL) return NULL; if (IDL_NODE_TYPE (ns_ident) == IDLN_IDENT) ns_ident = IDL_IDENT_TO_NS (ns_ident); assert (IDL_NODE_TYPE (ns_ident) == IDLN_GENTREE); l = IDL_ns_qualified_ident_new (ns_ident); if (l == NULL) return NULL; if (join == NULL) join = ""; joinlen = strlen (join); for (len = 0, q = l; q != NULL; q = IDL_LIST (q).next) { IDL_tree i = IDL_LIST (q).data; assert (IDL_NODE_TYPE (q) == IDLN_LIST); assert (IDL_NODE_TYPE (i) == IDLN_IDENT); if (IDL_IDENT (i).str != NULL) len += strlen (IDL_IDENT (i).str) + joinlen; ++count; } if (levels == 0) start_level = 0; else start_level = count - levels; assert (start_level >= 0 && start_level < count); s = g_malloc (len + 1); if (s == NULL) { IDL_tree_free (l); return NULL; } s[0] = '\0'; for (q = l; q != NULL; q = IDL_LIST (q).next) { IDL_tree i = IDL_LIST (q).data; if (start_level > 0) { --start_level; continue; } if (s[0] != '\0') strcat (s, join); strcat (s, IDL_IDENT (i).str); } IDL_tree_free (l); return s; }
static void cs_output_stub (IDL_tree tree, OIDL_C_Info *ci, int *idx) { FILE *of = ci->fh; char *iface_id; char *opname; gboolean has_retval, has_args; g_return_if_fail (idx != NULL); iface_id = IDL_ns_ident_to_qstring ( IDL_IDENT_TO_NS (IDL_INTERFACE ( IDL_get_parent_node (tree, IDLN_INTERFACE, NULL) ).ident), "_", 0); opname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_OP_DCL (tree).ident), "_", 0); has_retval = IDL_OP_DCL (tree).op_type_spec != NULL; has_args = IDL_OP_DCL (tree).parameter_dcls != NULL; #ifdef USE_LIBIDL_CODE orbit_cbe_op_write_proto (of, tree, "", FALSE); fprintf (of, "{\n"); if (has_retval) { orbit_cbe_write_param_typespec (of, tree); fprintf (of, " " ORBIT_RETVAL_VAR_NAME ";\n"); } fprintf (ci->fh, "POA_%s__epv *%s;\n", iface_id, ORBIT_EPV_VAR_NAME); fprintf (ci->fh, "gpointer _ORBIT_servant;\n"); /* in-proc part */ fprintf (ci->fh, "if ((%s = ORBit_c_stub_invoke\n", ORBIT_EPV_VAR_NAME); fprintf (ci->fh, " (_obj, %s__classid, &_ORBIT_servant,\n", iface_id); fprintf (ci->fh, " G_STRUCT_OFFSET (POA_%s__epv, %s)))) {\n", iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str); fprintf (ci->fh, "if (ORBit_small_flags & ORBIT_SMALL_FAST_LOCALS && \n"); fprintf (ci->fh, " ORBIT_STUB_IsBypass (_obj, %s__classid) && \n", iface_id); fprintf (ci->fh, " (%s = (POA_%s__epv*) ORBIT_STUB_GetEpv (_obj, %s__classid))->%s) {\n", ORBIT_EPV_VAR_NAME, iface_id, iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str); fprintf (ci->fh, "ORBIT_STUB_PreCall (_obj);\n"); fprintf (ci->fh, "%s%s->%s (_ORBIT_servant, ", IDL_OP_DCL (tree).op_type_spec? ORBIT_RETVAL_VAR_NAME " = ":"", ORBIT_EPV_VAR_NAME, IDL_IDENT (IDL_OP_DCL (tree).ident).str); for (node = IDL_OP_DCL (tree).parameter_dcls; node; node = IDL_LIST (node).next) fprintf (ci->fh, "%s, ", IDL_IDENT (IDL_PARAM_DCL (IDL_LIST (node).data).simple_declarator).str); if (IDL_OP_DCL (tree).context_expr) fprintf (ci->fh, "_ctx, "); fprintf (ci->fh, "ev);\n"); fprintf (ci->fh, "ORBit_stub_post_invoke (_obj, %s);\n", ORBIT_EPV_VAR_NAME); fprintf (of, " } else { /* remote marshal */\n"); /* remote invocation part */ if (has_args) orbit_cbe_flatten_args (tree, of, "_args"); fprintf (of, "ORBit_c_stub_invoke (_obj, " "&%s__iinterface.methods, %d, ", iface_id, *idx); if (has_retval) fprintf (of, "&_ORBIT_retval, "); else fprintf (of, "NULL, "); if (has_args) fprintf (of, "_args, "); else fprintf (of, "NULL, "); if (IDL_OP_DCL (tree).context_expr) fprintf (ci->fh, "_ctx, "); else fprintf (ci->fh, "NULL, "); fprintf (of, "ev, "); fprintf (of, "%s__classid, G_STRUCT_OFFSET (POA_%s__epv, %s),\n", iface_id, iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str); fprintf (of, "(ORBitSmallSkeleton) _ORBIT_skel_small_%s);\n\n", opname); if (has_retval) fprintf (of, "return " ORBIT_RETVAL_VAR_NAME ";\n"); fprintf (of, "}\n"); #else /*** This is Voyager stuff... ***/ if(strstr(opname, NOM_INSTANCEVAR_STRING)==NULL && strstr(opname, NOM_OVERRIDE_STRING)==NULL) { /* Skip specially marked methods containing "__INSTANCEVAR__ */ fprintf (of, "NOM_Scope "); orbit_cbe_op_write_proto (of, tree, "NOMLINK impl_", FALSE); fprintf (of, "\n{\n"); fprintf (of, "/* %sData* nomThis=%sGetData(nomSelf); */\n", iface_id, iface_id); if (has_retval) { fprintf (of, " "); orbit_cbe_write_param_typespec (of, tree); fprintf (of, " " ORBIT_RETVAL_VAR_NAME ";\n\n"); fprintf (of, " return " ORBIT_RETVAL_VAR_NAME ";\n"); } else fprintf (of, "\n"); /* Beautyfication... */ fprintf (of, "}\n\n"); } if(strstr(opname, NOM_OVERRIDE_STRING)!=NULL) { /* There's an overriden method here */ fprintf (of, "\n/* %s, %s line %d */\n", __FILE__, __FUNCTION__, __LINE__); fprintf (of, "NOM_Scope "); VoyagerWriteParamsForOverridenMethod (of, tree, "", FALSE); fprintf (of, "\n{\n"); fprintf (of, "/* %sData* nomThis=%sGetData(nomSelf); */\n", iface_id, iface_id); if (has_retval) { fprintf (of, " "); orbit_cbe_write_param_typespec (of, tree); fprintf (of, " " ORBIT_RETVAL_VAR_NAME ";\n\n"); fprintf (of, " return " ORBIT_RETVAL_VAR_NAME ";\n"); } else fprintf (of, "\n"); /* Beautyfication... */ fprintf (of, "#if 0\n"); if (has_retval) fprintf (of, " return "); VoyagerWriteProtoForParentCall (of, tree, "", FALSE); fprintf (of, "#endif\n"); #if 0 /* Inherited */ tmptree = IDL_get_parent_node(tree, IDLN_INTERFACE, NULL);; if(IDL_INTERFACE(tmptree).inheritance_spec) { char * ptr=opname; char * str; printf("!!!! %s\n", opname); InheritedOutputInfo ioi; ioi.of = ci->fh; ioi.realif = tmptree; // str= IDL_ns_ident_to_qstring( IDL_IDENT_TO_NS (IDL_INTERFACE(tree).ident), "_", 0); if((ptr=strchr(opname, '_'))!=NULL) ptr++; str=g_strdup(ptr); if((ptr=strchr(str, '_'))!=NULL) *ptr='\0'; ioi.chrOverridenMethodName=str; IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, (GFunc)VoyagerOutputOverridenMethodTemplate, &ioi); if(NULL!=ptr) *ptr='_'; } #endif fprintf (of, "}\n\n"); } #endif g_free (iface_id); (*idx)++; }
/* 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; }
/** Gets the "type" of {tree} as known in C. The return value was alloc'd via g_malloc, and must be g_free'd. **/ gulong orbit_cbe_get_typespec_size(IDL_tree tree) { gulong retval=0; if(!tree) { return 0; } switch(IDL_NODE_TYPE(tree)) { #if 0 case IDLN_MEMBER: return orbit_cbe_get_typespec_str(IDL_MEMBER(tree).type_spec); break; case IDLN_TYPE_ANY: retval = sizeof(CORBA_any); break; #endif case IDLN_TYPE_FLOAT: switch(IDL_TYPE_FLOAT(tree).f_type) { case IDL_FLOAT_TYPE_FLOAT: retval = sizeof(CORBA_float); break; case IDL_FLOAT_TYPE_DOUBLE: retval = sizeof(CORBA_double); break; case IDL_FLOAT_TYPE_LONGDOUBLE: retval = sizeof(CORBA_long_double); break; } break; #if 0 case IDLN_TYPE_FIXED: return g_strdup_printf( "CORBA_fixed_%" IDL_LL "d_%" IDL_LL "d", IDL_INTEGER(IDL_TYPE_FIXED(tree).positive_int_const).value, IDL_INTEGER(IDL_TYPE_FIXED(tree).integer_lit).value); break; #endif case IDLN_TYPE_INTEGER: if(!IDL_TYPE_INTEGER(tree).f_signed) { /* unsigned types */ switch(IDL_TYPE_INTEGER(tree).f_type) { case IDL_INTEGER_TYPE_SHORT: retval=sizeof(CORBA_unsigned_short); break; case IDL_INTEGER_TYPE_LONGLONG: retval=sizeof(CORBA_unsigned_long_long); break; case IDL_INTEGER_TYPE_LONG: retval=sizeof(CORBA_unsigned_long); break; } } else{ switch(IDL_TYPE_INTEGER(tree).f_type) { /* signed types */ case IDL_INTEGER_TYPE_SHORT: retval=sizeof(CORBA_short); break; case IDL_INTEGER_TYPE_LONGLONG: retval=sizeof(CORBA_long_long); break; case IDL_INTEGER_TYPE_LONG: retval=sizeof(CORBA_long); break; } } break; case IDLN_TYPE_OCTET: retval = sizeof(CORBA_octet); break; case IDLN_TYPE_STRING: retval = sizeof(CORBA_string); /* this is non-standard! */ break; case IDLN_TYPE_BOOLEAN: retval = sizeof(CORBA_boolean); break; case IDLN_TYPE_CHAR: retval = sizeof(CORBA_char); break; case IDLN_TYPE_OBJECT: retval = sizeof(CORBA_Object); break; case IDLN_NATIVE: retval = sizeof(gpointer); break; #if 0 case IDLN_TYPE_WIDE_STRING: retval = "CORBA_wstring"; /* this is non-standard! */ break; case IDLN_TYPE_WIDE_CHAR: retval = "CORBA_wchar"; break; case IDLN_TYPE_STRUCT: return orbit_cbe_get_typespec_str(IDL_TYPE_STRUCT(tree).ident); case IDLN_EXCEPT_DCL: return orbit_cbe_get_typespec_str(IDL_EXCEPT_DCL(tree).ident); case IDLN_TYPE_ARRAY: return orbit_cbe_get_typespec_str(IDL_TYPE_ARRAY(tree).ident); case IDLN_TYPE_UNION: return orbit_cbe_get_typespec_str(IDL_TYPE_UNION(tree).ident); case IDLN_TYPE_ENUM: return orbit_cbe_get_typespec_str(IDL_TYPE_ENUM(tree).ident); case IDLN_IDENT: return IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(tree), "_", 0); case IDLN_PARAM_DCL: return orbit_cbe_get_typespec_str(IDL_PARAM_DCL(tree).param_type_spec); case IDLN_TYPE_SEQUENCE: { IDL_tree subtype = IDL_TYPE_SEQUENCE(tree).simple_type_spec; char *ctmp, *base; ctmp = orbit_cbe_get_typespec_str(subtype); /* We should have built-in alias to make this next line not needed */ base = orbit_cbe_type_is_builtin(subtype) ? ctmp + strlen("CORBA_") : ctmp; retval = g_strdup_printf( "CORBA_sequence_%s", base); g_free(ctmp); return retval; } break; case IDLN_FORWARD_DCL: case IDLN_INTERFACE: return orbit_cbe_get_typespec_str(IDL_INTERFACE(tree).ident); case IDLN_TYPE_TYPECODE: retval = "CORBA_TypeCode"; break; #endif default: // retval=sizeof(gpointer); // g_error("We were asked to get a typesize for a %s (%s, %s line %d)", // IDL_tree_type_names[IDL_NODE_TYPE(tree)], __FILE__, __FUNCTION__, __LINE__); g_print("We were asked to get a typesize for a %s -> %s (%s line %d)\n", IDL_tree_type_names[IDL_NODE_TYPE(tree)], IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(tree), "_", 0), __FUNCTION__, __LINE__); g_print("HACK: Returning sizeof(gpointer) now...\n", IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(tree), "_", 0)); retval=sizeof(gpointer); break; } return retval; }
static void cc_output_itypes (GSList *list, OIDL_C_Info *ci) { GSList *l; FILE *of = ci->fh; for (l = list; l; l = l->next) { CCSmallInterfaceTraverseInfo iti; Interface *i = l->data; char *id; GSList *m; id = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS ( IDL_INTERFACE (i->tree).ident), "_", 0); for (m = i->methods; m; m = m->next) cc_output_method_bits (m->data, id, ci); if (i->methods) { fprintf (of, "\n#ifdef ORBIT_IDL_C_IMODULE_%s\n", ci->c_base_name); fprintf (of, "static\n"); fprintf (of, "#endif\n"); fprintf (of, "ORBit_IMethod %s__imethods [] = {\n", id); if (!(m = i->methods)) fprintf (of, "{{0}}"); else for (; m; m = m->next) { cc_output_method (of, m->data, id); if (m->next) fprintf(of, ", "); } fprintf (of, "};"); } fprintf (of, "static CORBA_string %s__base_itypes[] = {\n", id); iti.of = of; iti.cur_node = i->tree; iti.cur_id = id; iti.parents = 0; IDL_tree_traverse_parents(i->tree, (GFunc)cc_output_base_itypes, &iti); fprintf (of, "\"IDL:omg.org/CORBA/Object:1.0\"\n};"); fprintf (of, "\n#ifdef ORBIT_IDL_C_IMODULE_%s\n", ci->c_base_name); fprintf (of, "static\n"); fprintf (of, "#endif\n"); fprintf (of, "ORBit_IInterface %s__iinterface = {\n", id); fprintf (of, "TC_%s,", id); fprintf (of, "{%d, %d, %s__imethods, FALSE},\n", g_slist_length (i->methods), g_slist_length (i->methods), id); fprintf (of, "{%d, %d, %s__base_itypes, FALSE}\n", iti.parents + 1, iti.parents + 1, id); fprintf (of, "};\n\n"); g_free (id); } for (l = list; l; l = l->next) { g_slist_free (((Interface *)l->data)->methods); g_free (l->data); } g_slist_free (list); }
void orbit_cbe_op_write_proto (FILE *of, IDL_tree op, const char *nom_prefix, gboolean for_epv) { IDL_tree sub; char *id; char * id2; char * ptr; g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL); orbit_cbe_write_param_typespec (of, op); id = IDL_ns_ident_to_qstring ( IDL_IDENT_TO_NS (IDL_INTERFACE ( IDL_get_parent_node (op, IDLN_INTERFACE, NULL)).ident), "_", 0); #ifdef USE_LIBIDL_CODE if (for_epv) fprintf (of, " (*%s%s)", nom_prefix ? nom_prefix : "", IDL_IDENT(IDL_OP_DCL(op).ident).str); else fprintf (of, " %s%s_%s", nom_prefix ? nom_prefix : "", id, IDL_IDENT(IDL_OP_DCL(op).ident).str); #else id2=g_strdup(IDL_IDENT (IDL_OP_DCL (op).ident).str); if((ptr=strstr(id2, NOM_OVERRIDE_STRING))!=NULL) *ptr='\0'; if (for_epv) fprintf (of, " (*%s%s)", nom_prefix ? nom_prefix : "", IDL_IDENT(IDL_OP_DCL(op).ident).str); else fprintf (of, " %s%s_%s", nom_prefix ? nom_prefix : "", id, id2); g_free(id2); #endif fprintf (of, "("); if (for_epv) fprintf (of, "PortableServer_Servant _servant, "); else #ifdef USE_LIBIDL_CODE fprintf (of, "%s _obj, ", id); #else fprintf (of, "%s* nomSelf, ", id); #endif g_free (id); for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) { IDL_tree parm = IDL_LIST (sub).data; orbit_cbe_write_param_typespec (of, parm); fprintf (of, " %s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str); } if (IDL_OP_DCL (op).context_expr) fprintf (of, "CORBA_Context _ctx, "); fprintf (of, "CORBA_Environment *ev)"); }
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)); } }
/** Gets the "type" of {tree} as known in C. The return value was alloc'd via g_malloc, and must be g_free'd. **/ char * orbit_cbe_get_typespec_str(IDL_tree tree) { char *retval = NULL; GString *tmpstr = NULL; if(!tree) { return g_strdup("void"); } switch(IDL_NODE_TYPE(tree)) { case IDLN_MEMBER: return orbit_cbe_get_typespec_str(IDL_MEMBER(tree).type_spec); break; case IDLN_TYPE_ANY: retval = "CORBA_any"; break; case IDLN_TYPE_FLOAT: switch(IDL_TYPE_FLOAT(tree).f_type) { case IDL_FLOAT_TYPE_FLOAT: retval = "CORBA_float"; break; case IDL_FLOAT_TYPE_DOUBLE: retval = "CORBA_double"; break; case IDL_FLOAT_TYPE_LONGDOUBLE: retval = "CORBA_long_double"; break; } break; case IDLN_TYPE_FIXED: return g_strdup_printf( "CORBA_fixed_%" IDL_LL "d_%" IDL_LL "d", IDL_INTEGER(IDL_TYPE_FIXED(tree).positive_int_const).value, IDL_INTEGER(IDL_TYPE_FIXED(tree).integer_lit).value); break; case IDLN_TYPE_INTEGER: tmpstr = g_string_new(NULL); g_string_append(tmpstr, "CORBA_"); if(!IDL_TYPE_INTEGER(tree).f_signed) g_string_append(tmpstr, "unsigned_"); switch(IDL_TYPE_INTEGER(tree).f_type) { case IDL_INTEGER_TYPE_SHORT: g_string_append(tmpstr, "short"); break; case IDL_INTEGER_TYPE_LONGLONG: g_string_append(tmpstr, "long_"); /* FALLTHROUGH */ case IDL_INTEGER_TYPE_LONG: g_string_append(tmpstr, "long"); break; } break; case IDLN_TYPE_STRING: retval = "CORBA_string"; /* this is non-standard! */ break; case IDLN_TYPE_OCTET: retval = "CORBA_octet"; break; case IDLN_TYPE_WIDE_STRING: retval = "CORBA_wstring"; /* this is non-standard! */ break; case IDLN_TYPE_CHAR: retval = "CORBA_char"; break; case IDLN_TYPE_WIDE_CHAR: retval = "CORBA_wchar"; break; case IDLN_TYPE_BOOLEAN: retval = "CORBA_boolean"; break; case IDLN_TYPE_STRUCT: return orbit_cbe_get_typespec_str(IDL_TYPE_STRUCT(tree).ident); case IDLN_EXCEPT_DCL: return orbit_cbe_get_typespec_str(IDL_EXCEPT_DCL(tree).ident); case IDLN_TYPE_ARRAY: return orbit_cbe_get_typespec_str(IDL_TYPE_ARRAY(tree).ident); case IDLN_TYPE_UNION: return orbit_cbe_get_typespec_str(IDL_TYPE_UNION(tree).ident); case IDLN_TYPE_ENUM: return orbit_cbe_get_typespec_str(IDL_TYPE_ENUM(tree).ident); case IDLN_IDENT: return IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(tree), "_", 0); case IDLN_PARAM_DCL: return orbit_cbe_get_typespec_str(IDL_PARAM_DCL(tree).param_type_spec); case IDLN_TYPE_SEQUENCE: { IDL_tree subtype = IDL_TYPE_SEQUENCE(tree).simple_type_spec; char *ctmp, *base; ctmp = orbit_cbe_get_typespec_str(subtype); /* We should have built-in alias to make this next line not needed */ base = orbit_cbe_type_is_builtin(subtype) ? ctmp + strlen("CORBA_") : ctmp; retval = g_strdup_printf( "CORBA_sequence_%s", base); g_free(ctmp); return retval; } break; case IDLN_NATIVE: retval = "gpointer"; break; case IDLN_FORWARD_DCL: case IDLN_INTERFACE: return orbit_cbe_get_typespec_str(IDL_INTERFACE(tree).ident); case IDLN_TYPE_OBJECT: retval = "CORBA_Object"; break; case IDLN_TYPE_TYPECODE: retval = "CORBA_TypeCode"; break; default: g_error("We were asked to get a typename for a %s", IDL_tree_type_names[IDL_NODE_TYPE(tree)]); break; } if (retval) return g_strdup (retval); else return g_string_free (tmpstr, FALSE); }