3 #include "orbit-idl-c-backend.h"
8 cs_output_stub (IDL_tree tree,
15 gboolean has_retval, has_args;
17 g_return_if_fail (idx != NULL);
19 iface_id = IDL_ns_ident_to_qstring (
20 IDL_IDENT_TO_NS (IDL_INTERFACE (
21 IDL_get_parent_node (tree, IDLN_INTERFACE, NULL)
23 opname = IDL_ns_ident_to_qstring (IDL_IDENT_TO_NS (IDL_OP_DCL (tree).ident), "_", 0);
25 has_retval = IDL_OP_DCL (tree).op_type_spec != NULL;
26 has_args = IDL_OP_DCL (tree).parameter_dcls != NULL;
28 orbit_cbe_op_write_proto (of, tree, "", FALSE);
33 orbit_cbe_write_param_typespec (of, tree);
34 fprintf (of, " " ORBIT_RETVAL_VAR_NAME ";\n");
37 fprintf (ci->fh, "POA_%s__epv *%s;\n", iface_id, ORBIT_EPV_VAR_NAME);
38 fprintf (ci->fh, "gpointer _ORBIT_servant;\n");
41 fprintf (ci->fh, "if ((%s = ORBit_c_stub_invoke\n", ORBIT_EPV_VAR_NAME);
42 fprintf (ci->fh, " (_obj, %s__classid, &_ORBIT_servant,\n", iface_id);
43 fprintf (ci->fh, " G_STRUCT_OFFSET (POA_%s__epv, %s)))) {\n",
44 iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
46 fprintf (ci->fh, "if (ORBit_small_flags & ORBIT_SMALL_FAST_LOCALS && \n");
47 fprintf (ci->fh, " ORBIT_STUB_IsBypass (_obj, %s__classid) && \n", iface_id);
48 fprintf (ci->fh, " (%s = (POA_%s__epv*) ORBIT_STUB_GetEpv (_obj, %s__classid))->%s) {\n",
49 ORBIT_EPV_VAR_NAME, iface_id, iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
51 fprintf (ci->fh, "ORBIT_STUB_PreCall (_obj);\n");
53 fprintf (ci->fh, "%s%s->%s (_ORBIT_servant, ",
54 IDL_OP_DCL (tree).op_type_spec? ORBIT_RETVAL_VAR_NAME " = ":"",
56 IDL_IDENT (IDL_OP_DCL (tree).ident).str);
58 for (node = IDL_OP_DCL (tree).parameter_dcls; node; node = IDL_LIST (node).next)
59 fprintf (ci->fh, "%s, ",
60 IDL_IDENT (IDL_PARAM_DCL (IDL_LIST (node).data).simple_declarator).str);
62 if (IDL_OP_DCL (tree).context_expr)
63 fprintf (ci->fh, "_ctx, ");
65 fprintf (ci->fh, "ev);\n");
67 fprintf (ci->fh, "ORBit_stub_post_invoke (_obj, %s);\n", ORBIT_EPV_VAR_NAME);
69 fprintf (of, " } else { /* remote marshal */\n");
72 /* remote invocation part */
74 orbit_cbe_flatten_args (tree, of, "_args");
76 fprintf (of, "ORBit_c_stub_invoke (_obj, "
77 "&%s__iinterface.methods, %d, ", iface_id, *idx);
80 fprintf (of, "&_ORBIT_retval, ");
82 fprintf (of, "NULL, ");
85 fprintf (of, "_args, ");
87 fprintf (of, "NULL, ");
89 if (IDL_OP_DCL (tree).context_expr)
90 fprintf (ci->fh, "_ctx, ");
92 fprintf (ci->fh, "NULL, ");
96 fprintf (of, "%s__classid, G_STRUCT_OFFSET (POA_%s__epv, %s),\n",
97 iface_id, iface_id, IDL_IDENT (IDL_OP_DCL (tree).ident).str);
98 fprintf (of, "(ORBitSmallSkeleton) _ORBIT_skel_small_%s);\n\n", opname);
101 fprintf (of, "return " ORBIT_RETVAL_VAR_NAME ";\n");
111 cs_output_stubs (IDL_tree tree,
118 switch (IDL_NODE_TYPE (tree)) {
120 cs_output_stubs (IDL_MODULE (tree).definition_list, ci, idx);
125 for (sub = tree; sub; sub = IDL_LIST (sub).next)
126 cs_output_stubs (IDL_LIST (sub).data, ci, idx);
129 case IDLN_ATTR_DCL: {
132 for (node = IDL_ATTR_DCL (tree).simple_declarations; node; node = IDL_LIST (node).next) {
135 ai = IDL_LIST (node).data->data;
137 cs_output_stubs (ai->op1, ci, idx);
140 cs_output_stubs (ai->op2, ci, idx);
144 case IDLN_INTERFACE: {
147 cs_output_stubs (IDL_INTERFACE (tree).body, ci, &real_idx);
151 cs_output_stub (tree, ci, idx);
159 orbit_idl_output_c_stubs (IDL_tree tree,
160 OIDL_Run_Info *rinfo,
163 fprintf (ci->fh, OIDL_C_WARNING);
164 fprintf (ci->fh, "#include <string.h>\n");
165 fprintf (ci->fh, "#define ORBIT2_STUBS_API\n");
166 fprintf (ci->fh, "#include \"%s.h\"\n\n", ci->base_name);
168 cs_output_stubs (tree, ci, NULL);