Пример #1
0
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");
}
IDL_tree
MateCORBA_imodule_get_typespec (IDL_tree tree)
{
	IDL_tree retval = NULL;

	if (!tree)
		return NULL;

	switch (IDL_NODE_TYPE (tree)) {
	case IDLN_TYPE_INTEGER:
	case IDLN_TYPE_FLOAT:
	case IDLN_TYPE_FIXED:
	case IDLN_TYPE_CHAR:
	case IDLN_TYPE_WIDE_CHAR:
	case IDLN_TYPE_STRING:
	case IDLN_TYPE_WIDE_STRING:
	case IDLN_TYPE_BOOLEAN:
	case IDLN_TYPE_OCTET:
	case IDLN_TYPE_ANY:
	case IDLN_TYPE_OBJECT:
	case IDLN_TYPE_ENUM:
	case IDLN_TYPE_SEQUENCE:
	case IDLN_TYPE_ARRAY:
	case IDLN_TYPE_STRUCT:
	case IDLN_TYPE_UNION:
	case IDLN_EXCEPT_DCL:
	case IDLN_FORWARD_DCL:
	case IDLN_INTERFACE:
	case IDLN_NATIVE:
 	case IDLN_TYPE_TYPECODE:
		retval = tree;
		break;
	case IDLN_TYPE_DCL:
		retval = MateCORBA_imodule_get_typespec (
				IDL_TYPE_DCL (tree).type_spec);
		break;
	case IDLN_PARAM_DCL:
		retval = MateCORBA_imodule_get_typespec (
				IDL_PARAM_DCL (tree).param_type_spec);
		break;
	case IDLN_MEMBER:
		retval = MateCORBA_imodule_get_typespec (
				IDL_MEMBER (tree).type_spec);
		break;
	case IDLN_LIST:
	case IDLN_IDENT:
		retval = MateCORBA_imodule_get_typespec (
				IDL_get_parent_node (tree, IDLN_ANY, NULL));
		break;
	default:
		g_error ("Cannot get typespec for %s",
				IDL_tree_type_names [IDL_NODE_TYPE (tree)]);
		break;
	}

	return retval;
}
Пример #3
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)++;
}
Пример #4
0
/*
  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);
}
Пример #5
0
IDL_tree
orte_cbe_get_typespec(IDL_tree node)
{
  if(node == NULL)
    return NULL;

  switch(IDL_NODE_TYPE(node)) {
  case IDLN_TYPE_INTEGER:
  case IDLN_TYPE_FLOAT:
  case IDLN_TYPE_FIXED:
  case IDLN_TYPE_CHAR:
  case IDLN_TYPE_WIDE_CHAR:
  case IDLN_TYPE_STRING:
  case IDLN_TYPE_WIDE_STRING:
  case IDLN_TYPE_BOOLEAN:
  case IDLN_TYPE_OCTET:
  case IDLN_TYPE_ANY:
  case IDLN_TYPE_OBJECT:
  case IDLN_TYPE_ENUM:
  case IDLN_TYPE_SEQUENCE:
  case IDLN_TYPE_ARRAY:
  case IDLN_TYPE_STRUCT:
  case IDLN_TYPE_UNION:
  case IDLN_EXCEPT_DCL:
  case IDLN_FORWARD_DCL:
  case IDLN_INTERFACE:
  case IDLN_NATIVE:
  case IDLN_TYPE_TYPECODE:
    return node;
    break;
  case IDLN_TYPE_DCL:
    return orte_cbe_get_typespec(IDL_TYPE_DCL(node).type_spec);
    break;
  case IDLN_PARAM_DCL:
    return orte_cbe_get_typespec(IDL_PARAM_DCL(node).param_type_spec);
    break;
  case IDLN_MEMBER:
    return orte_cbe_get_typespec(IDL_MEMBER(node).type_spec);
    break;
  case IDLN_LIST:
  case IDLN_IDENT:
    return orte_cbe_get_typespec(IDL_get_parent_node(node, IDLN_ANY, NULL));
    break;
  default:
    g_error("Unhandled node type %s!", IDL_tree_type_names[IDL_NODE_TYPE(node)]);
    return NULL;
  }
}
void
MateCORBA_imodule_traverse_parents (IDL_tree tree,
				GFunc    callback,
				gpointer user_data)
{
	GHashTable *visited_nodes = g_hash_table_new (NULL, g_direct_equal);

	g_return_if_fail (tree != NULL);
	g_return_if_fail (callback != NULL);

	if (IDL_NODE_TYPE (tree) != IDLN_INTERFACE)
		tree = IDL_get_parent_node (tree, IDLN_INTERFACE, NULL);

	if (!tree)
		return;

	MateCORBA_imodule_traverse_helper (tree, callback, user_data, visited_nodes);

	g_hash_table_destroy (visited_nodes);
}
Пример #7
0
void
IDL_tree_traverse_parents_full (IDL_tree      p,
				GFunc         f,
				gconstpointer func_data,
				gboolean      include_self)
{
	GHashTable *visited_nodes = g_hash_table_new (NULL, g_direct_equal);

	if (!(p && f))
		return;

	if (IDL_NODE_TYPE(p) != IDLN_INTERFACE)
		p = IDL_get_parent_node (p, IDLN_INTERFACE, NULL);

	if (!p)
		return;

	IDL_tree_traverse_helper (p, f, func_data, visited_nodes, include_self);

	g_hash_table_destroy (visited_nodes);
}
static void
MateCORBA_imodule_traverse_helper (IDL_tree    tree,
			       GFunc       callback,
			       gpointer    user_data,
			       GHashTable *visited_nodes)
{
	IDL_tree curitem;

	if (g_hash_table_lookup (visited_nodes, tree))
		return;

	g_hash_table_insert (visited_nodes, tree, GINT_TO_POINTER (1));

	for (curitem = IDL_INTERFACE (tree).inheritance_spec; curitem;
	     curitem = IDL_LIST (curitem).next)
		MateCORBA_imodule_traverse_helper (
				IDL_get_parent_node (IDL_LIST (curitem).data, IDLN_INTERFACE, NULL),
				callback, user_data, visited_nodes);

	callback (tree, user_data);
}
Пример #9
0
/*
  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;
}
Пример #10
0
static void
IDL_tree_traverse_helper(IDL_tree p, GFunc f,
			 gconstpointer func_data,
			 GHashTable *visited_nodes,
			 gboolean    include_self)
{
	IDL_tree curitem;

	if (g_hash_table_lookup (visited_nodes, p))
		return;

	g_hash_table_insert (visited_nodes, p, ((gpointer)1));

	for (curitem = IDL_INTERFACE (p).inheritance_spec; curitem;
	     curitem = IDL_LIST (curitem).next) {
		IDL_tree_traverse_helper (IDL_get_parent_node 
			(IDL_LIST (curitem).data, IDLN_INTERFACE, NULL), f, func_data, visited_nodes, TRUE);
	}

	if (include_self)
		f(p, (gpointer)func_data);
}
Пример #11
0
gboolean
orte_cbe_type_is_fixed_length(IDL_tree ts)
{
  gboolean is_fixed = TRUE;
  IDL_tree curitem;

  ts = orte_cbe_get_typespec(ts);
  switch(IDL_NODE_TYPE(ts)) {
  case IDLN_TYPE_FLOAT:
  case IDLN_TYPE_INTEGER:
  case IDLN_TYPE_ENUM:
  case IDLN_TYPE_CHAR:
  case IDLN_TYPE_WIDE_CHAR:
  case IDLN_TYPE_OCTET:
  case IDLN_TYPE_BOOLEAN:
    return TRUE;
    break;
  case IDLN_TYPE_SEQUENCE:
  case IDLN_TYPE_STRING:
  case IDLN_TYPE_WIDE_STRING:
  case IDLN_TYPE_OBJECT:
  case IDLN_FORWARD_DCL:
  case IDLN_INTERFACE:
  case IDLN_TYPE_ANY:
  case IDLN_NATIVE:
  case IDLN_TYPE_TYPECODE:
    return FALSE;
    break;
  case IDLN_TYPE_UNION:
    for(curitem = IDL_TYPE_UNION(ts).switch_body; curitem;
	curitem = IDL_LIST(curitem).next) {
      is_fixed &= orte_cbe_type_is_fixed_length(IDL_LIST(IDL_CASE_STMT(IDL_LIST(curitem).data).element_spec).data);
    }
    return is_fixed;
    break;
  case IDLN_EXCEPT_DCL:
  case IDLN_TYPE_STRUCT:
    for(curitem = IDL_TYPE_STRUCT(ts).member_list; curitem;
	curitem = IDL_LIST(curitem).next) {
      is_fixed &= orte_cbe_type_is_fixed_length(IDL_LIST(curitem).data);
    }
    return is_fixed;
    break;
  case IDLN_TYPE_ARRAY:
    return orte_cbe_type_is_fixed_length(IDL_TYPE_DCL(IDL_get_parent_node(ts, IDLN_TYPE_DCL, NULL)).type_spec);
    break;
  case IDLN_TYPE_DCL:
    return orte_cbe_type_is_fixed_length(IDL_TYPE_DCL(ts).type_spec);
    break;
  case IDLN_IDENT:
  case IDLN_LIST:
    return orte_cbe_type_is_fixed_length(IDL_NODE_UP(ts));
    break;
  case IDLN_MEMBER:
    return orte_cbe_type_is_fixed_length(IDL_MEMBER(ts).type_spec);
    break;
  default:
    g_warning("I'm not sure if type %s is fixed-length", IDL_tree_type_names[IDL_NODE_TYPE(ts)]);
    return FALSE;
  }
}
gboolean
MateCORBA_imodule_type_is_fixed_length (IDL_tree tree)
{
	gboolean is_fixed = TRUE;
	IDL_tree iter;
	IDL_tree typespec;

	typespec = MateCORBA_imodule_get_typespec (tree);

	switch (IDL_NODE_TYPE (typespec)) {
	case IDLN_TYPE_FLOAT:
	case IDLN_TYPE_INTEGER:
	case IDLN_TYPE_ENUM:
	case IDLN_TYPE_CHAR:
	case IDLN_TYPE_WIDE_CHAR:
	case IDLN_TYPE_OCTET:
	case IDLN_TYPE_BOOLEAN:
		is_fixed = TRUE;
		break;
	case IDLN_TYPE_SEQUENCE:
	case IDLN_TYPE_STRING:
	case IDLN_TYPE_WIDE_STRING:
	case IDLN_TYPE_OBJECT:
	case IDLN_FORWARD_DCL:
	case IDLN_INTERFACE:
	case IDLN_TYPE_ANY:
	case IDLN_NATIVE:
	case IDLN_TYPE_TYPECODE:
		is_fixed = FALSE;
		break;
	case IDLN_TYPE_UNION:
		for (iter = IDL_TYPE_UNION (typespec).switch_body;
		     iter; iter = IDL_LIST (iter).next)
			is_fixed &= MateCORBA_imodule_type_is_fixed_length (
					IDL_LIST (IDL_CASE_STMT (
						IDL_LIST (iter).data).element_spec).data);
		break;
	case IDLN_EXCEPT_DCL:
	case IDLN_TYPE_STRUCT:
		for (iter = IDL_TYPE_STRUCT (typespec).member_list;
		     iter; iter = IDL_LIST (iter).next)
			is_fixed &= MateCORBA_imodule_type_is_fixed_length (IDL_LIST (iter).data);
		break;
	case IDLN_TYPE_ARRAY:
		is_fixed = MateCORBA_imodule_type_is_fixed_length (
				IDL_TYPE_DCL (IDL_get_parent_node (
						typespec, IDLN_TYPE_DCL, NULL)).type_spec);
		break;
	case IDLN_TYPE_DCL:
		is_fixed = MateCORBA_imodule_type_is_fixed_length (
				IDL_TYPE_DCL (typespec).type_spec);
		break;
	case IDLN_IDENT:
	case IDLN_LIST:
		is_fixed = MateCORBA_imodule_type_is_fixed_length (IDL_NODE_UP (typespec));
		break;
	case IDLN_MEMBER:
		is_fixed = MateCORBA_imodule_type_is_fixed_length (IDL_MEMBER (typespec).type_spec);
		break;
	default:
		g_error ("Cannot determine if type %s is fixed-length",
				IDL_tree_type_names [IDL_NODE_TYPE (typespec)]);
		break;
	}

	return is_fixed;
}
static int
MateCORBA_imodule_find_c_align (IDL_tree node)
{
	int c_align = 1;

	node = MateCORBA_imodule_get_typespec (node);	

	switch (IDL_NODE_TYPE (node)) {
	case IDLN_TYPE_INTEGER:
		switch (IDL_TYPE_INTEGER (node).f_type) {
		case IDL_INTEGER_TYPE_SHORT:
			c_align = MATECORBA_ALIGNOF_CORBA_SHORT;
			break;
		case IDL_INTEGER_TYPE_LONG:
			c_align = MATECORBA_ALIGNOF_CORBA_LONG;
			break;
		case IDL_INTEGER_TYPE_LONGLONG:
			c_align = MATECORBA_ALIGNOF_CORBA_LONG_LONG;
			break;
		}
		break;
	case IDLN_TYPE_FLOAT:
		switch (IDL_TYPE_FLOAT (node).f_type) {
		case IDL_FLOAT_TYPE_FLOAT:
			c_align = MATECORBA_ALIGNOF_CORBA_FLOAT;
			break;
		case IDL_FLOAT_TYPE_DOUBLE:
			c_align = MATECORBA_ALIGNOF_CORBA_DOUBLE;
			break;
		case IDL_FLOAT_TYPE_LONGDOUBLE:
			c_align = MATECORBA_ALIGNOF_CORBA_LONG_DOUBLE;
			break;
		}
		break;
	case IDLN_TYPE_ENUM:
		c_align = MATECORBA_ALIGNOF_CORBA_LONG;
		break;
	case IDLN_TYPE_CHAR: /* drop through */
	case IDLN_TYPE_BOOLEAN:
	case IDLN_TYPE_OCTET:
		c_align = MATECORBA_ALIGNOF_CORBA_CHAR;
		break;
	case IDLN_TYPE_WIDE_CHAR:
		c_align = MATECORBA_ALIGNOF_CORBA_SHORT;
		break;
	case IDLN_TYPE_UNION: {
		IDL_tree l = IDL_TYPE_UNION (node).switch_body;

		c_align = MATECORBA_ALIGNOF_CORBA_STRUCT;

		for (; l; l = IDL_LIST (l).next) {
			IDL_tree subtype = IDL_MEMBER (IDL_CASE_STMT (
					IDL_LIST (l).data).element_spec).type_spec;

			c_align = MAX (c_align, MateCORBA_imodule_find_c_align (subtype));
		}
		}
		break;
	case IDLN_EXCEPT_DCL: /* drop through */
	case IDLN_TYPE_STRUCT: {
		IDL_tree l = IDL_TYPE_STRUCT (node).member_list;
					
		for (; l; l = IDL_LIST (l).next) {
			IDL_tree member = IDL_MEMBER (IDL_LIST (l).data).type_spec;

			c_align = MAX (c_align, MateCORBA_imodule_find_c_align (member));
		}
		}
		break;
	case IDLN_TYPE_STRING: /* drop through */
	case IDLN_TYPE_WIDE_STRING:
	case IDLN_TYPE_OBJECT:
	case IDLN_TYPE_TYPECODE:
	case IDLN_FORWARD_DCL:
	case IDLN_INTERFACE:
		c_align = MATECORBA_ALIGNOF_CORBA_POINTER;
		break;
	case IDLN_TYPE_ARRAY: {
		IDL_tree subtype;

		subtype = IDL_TYPE_DCL (
				IDL_get_parent_node (
					node, IDLN_TYPE_DCL, NULL)).type_spec;

		c_align = MateCORBA_imodule_find_c_align (subtype);
		}
		break;
	case IDLN_TYPE_SEQUENCE:
		c_align = MAX (MAX (MATECORBA_ALIGNOF_CORBA_STRUCT,
				    MATECORBA_ALIGNOF_CORBA_LONG),
				    MATECORBA_ALIGNOF_CORBA_POINTER);
		break;
	case IDLN_TYPE_ANY:
		c_align =  MAX (MATECORBA_ALIGNOF_CORBA_STRUCT,
			        MATECORBA_ALIGNOF_CORBA_POINTER);
		break;
	default:
		g_error ("Can't find alignment %s\n", 
			 IDL_tree_type_names [IDL_NODE_TYPE (node)]);
		break;
	}

	return c_align;
}
Пример #14
0
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)++;
}
Пример #15
0
static GSList *
orbit_find_c_align (GSList *max, IDL_tree node)
{
	node = orbit_cbe_get_typespec (node);	

	switch (IDL_NODE_TYPE (node)) {
	case IDLN_TYPE_INTEGER:
		switch (IDL_TYPE_INTEGER (node).f_type) {
		case IDL_INTEGER_TYPE_SHORT:
			orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_SHORT");
			break;
		case IDL_INTEGER_TYPE_LONG:
			orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_LONG");
			break;
		case IDL_INTEGER_TYPE_LONGLONG:
			orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_LONG_LONG");
			break;
		}
		break;
	case IDLN_TYPE_FLOAT:
		switch (IDL_TYPE_FLOAT (node).f_type) {
		case IDL_FLOAT_TYPE_FLOAT:
			orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_FLOAT");
			break;
		case IDL_FLOAT_TYPE_DOUBLE:
			orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_DOUBLE");
			break;
		case IDL_FLOAT_TYPE_LONGDOUBLE:
			orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_LONG_DOUBLE");
			break;
		}
		break;
	case IDLN_TYPE_ENUM:
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_LONG");
		break;
	case IDLN_TYPE_CHAR: /* drop through */
	case IDLN_TYPE_BOOLEAN:
	case IDLN_TYPE_OCTET:
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_CHAR");
		break;
	case IDLN_TYPE_WIDE_CHAR:
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_SHORT");
		break;
	case IDLN_TYPE_UNION: {
		IDL_tree l = IDL_TYPE_UNION (node).switch_body;

		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_STRUCT");

		for (; l; l = IDL_LIST (l).next) {
			IDL_tree subtype = IDL_MEMBER (IDL_CASE_STMT (
				IDL_LIST (l).data).element_spec).type_spec;
			max = orbit_find_c_align (max, subtype);
		}
		break;
	}
	case IDLN_EXCEPT_DCL: /* drop through */
	case IDLN_TYPE_STRUCT: {
		IDL_tree l = IDL_TYPE_STRUCT (node).member_list;
					
		for (; l; l = IDL_LIST (l).next) {
			IDL_tree member = IDL_MEMBER (IDL_LIST (l).data).type_spec;

			max = orbit_find_c_align (max, member);
		}
		break;
	}
	case IDLN_TYPE_STRING: /* drop through */
	case IDLN_TYPE_WIDE_STRING:
	case IDLN_TYPE_OBJECT:
	case IDLN_TYPE_TYPECODE:
	case IDLN_FORWARD_DCL:
	case IDLN_INTERFACE:
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_POINTER");
		break;
	case IDLN_TYPE_ARRAY: {
		IDL_tree subtype = IDL_TYPE_DCL (
			IDL_get_parent_node (node, IDLN_TYPE_DCL, NULL)).type_spec;
		max = orbit_find_c_align (max, subtype);
		break;
	}
	case IDLN_TYPE_SEQUENCE:
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_STRUCT");
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_LONG");
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_POINTER");
		break;
	case IDLN_TYPE_ANY:
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_STRUCT");
		orbit_add_align (&max, "ORBIT_ALIGNOF_CORBA_POINTER");
		break;
	default:
		g_error ("Can't find alignment %s\n", 
			 IDL_tree_type_names[IDL_NODE_TYPE (node)]);
		break;
	}

	return max;
}
Пример #16
0
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)");
}