gboolean
verify_const_declaration(IDL_tree const_tree) {
    struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(const_tree);
    const char *name = IDL_IDENT(dcl->ident).str;
    IDL_tree real_type;

    /* const -> list -> interface */
    if (!IDL_NODE_UP(IDL_NODE_UP(const_tree)) ||
        IDL_NODE_TYPE(IDL_NODE_UP(IDL_NODE_UP(const_tree)))
        != IDLN_INTERFACE) {
        IDL_tree_error(const_tree,
                       "const declaration \'%s\' outside interface",
                       name);
        return FALSE;
    }

    /* Could be a typedef; try to map it to the real type. */
    real_type = find_underlying_type(dcl->const_type);
    real_type = real_type ? real_type : dcl->const_type;
    if (IDL_NODE_TYPE(real_type) == IDLN_TYPE_INTEGER &&
        (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_SHORT ||
         IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG))
    {
        if (!IDL_TYPE_INTEGER(real_type).f_signed &&
            IDL_INTEGER(dcl->const_exp).value < 0)
        {
#ifndef G_HAVE_GINT64
            /*
             * For platforms without longlong support turned on we can get
             * confused by the high bit of the long value and think that it
             * represents a negative value in an unsigned declaration.
             * In that case we don't know if it is the programmer who is 
             * confused or the compiler. So we issue a warning instead of 
             * an error.
             */
            if (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG)
            {
                XPIDL_WARNING((const_tree, IDL_WARNING1,
                              "unsigned const declaration \'%s\' "
                              "initialized with (possibly) negative constant",
                              name));
                return TRUE;
            }
#endif
            IDL_tree_error(const_tree,
                           "unsigned const declaration \'%s\' initialized with "
                           "negative constant",
                           name);
            return FALSE;
        }
    } else {
        IDL_tree_error(const_tree,
                       "const declaration \'%s\' must be of type short or long",
                       name);
        return FALSE;
    }

    return TRUE;
}
示例#2
0
int IDL_ns_scope_levels_from_here (IDL_ns ns, IDL_tree ident, IDL_tree parent)
{
	IDL_tree p, scope_here, scope_ident;
	int levels;

	g_return_val_if_fail (ns != NULL, 1);
	g_return_val_if_fail (ident != NULL, 1);

	while (parent && !IDL_NODE_IS_SCOPED (parent))
		parent = IDL_NODE_UP (parent);

	if (parent == NULL)
		return 1;

	if ((scope_here = IDL_tree_get_scope (parent)) == NULL ||
	    (scope_ident = IDL_tree_get_scope (ident)) == NULL)
		return 1;

	assert (IDL_NODE_TYPE (scope_here) == IDLN_GENTREE);
	assert (IDL_NODE_TYPE (scope_ident) == IDLN_GENTREE);

	for (levels = 1; scope_ident;
	     ++levels, scope_ident = IDL_NODE_UP (scope_ident)) {
		p = IDL_ns_resolve_this_scope_ident (
			ns, scope_here, IDL_GENTREE (scope_ident).data);
		if (p == scope_ident)
			return levels;
	}

	return 1;
}
示例#3
0
void
orbit_output_typecode (OIDL_C_Info *ci,
		       IDL_tree     node)
{
	CBETCGenInfo tci;

	switch (IDL_NODE_TYPE (node)) {
	case IDLN_TYPE_DCL:
	case IDLN_TYPE_STRUCT:
	case IDLN_TYPE_UNION:
	case IDLN_TYPE_ENUM:
	case IDLN_EXCEPT_DCL:
	case IDLN_TYPE_SEQUENCE:
	case IDLN_INTERFACE:
		break;
	default:
		g_error ("You can't produce a typecode for a %s", 
			 IDL_tree_type_names[IDL_NODE_TYPE (node)]);
	}

	tci.ts            = node;
	tci.structname    = orbit_generate_tcstruct_name (node);
	tci.substructname = NULL;
	tci.array_gen_ctr = 0;

	cbe_tc_generate (ci, &tci);

	g_free (tci.structname);
}
static void
MateCORBA_imodule_setup_label_any (CORBA_TypeCode  tc,
			       IDL_tree        node,
			       CORBA_any      *label)
{
	if (!node) { /* default case */
		label->_type = TC_CORBA_octet;
		label->_value = MateCORBA_small_alloc (TC_CORBA_octet);
		*(CORBA_octet *) label->_value = -1;
		return;
	}

	label->_type = (CORBA_TypeCode)
				CORBA_Object_duplicate (
					(CORBA_Object) tc, NULL);
	label->_value = MateCORBA_small_alloc (tc);

	switch (IDL_NODE_TYPE (node)) {
	case IDLN_BOOLEAN:
	case IDLN_CHAR:
	case IDLN_INTEGER:
		MateCORBA_imodule_jam_int (node, tc, label->_value);
		break;

	case IDLN_FLOAT:
		g_assert (tc->kind == CORBA_tk_float);
		*(CORBA_float *) label->_value = IDL_FLOAT (node).value;
		break;
	case IDLN_BINOP:  /* drop through */
	case IDLN_UNARYOP: {
		IDL_tree val;

		if (IDL_NODE_TYPE (node) == IDLN_BINOP)
			val = _IDL_binop_eval (IDL_BINOP (node).op,
					       IDL_BINOP (node).left,
					       IDL_BINOP (node).right);
		else
			val = _IDL_unaryop_eval (IDL_BINOP (node).op,
					       IDL_UNARYOP (node).operand);

		MateCORBA_imodule_jam_int (val, tc, label->_value);
		IDL_tree_free (val);
		break;
	}
	case IDLN_IDENT: {
		CORBA_long val;

		g_assert (label->_type->kind == CORBA_tk_enum);
		for (val = 0; val < label->_type->sub_parts; val++)
			if (!strcmp (IDL_IDENT (node).str, label->_type->subnames [val]))
				break;
		g_assert (val < label->_type->sub_parts);
		*(CORBA_long *) label->_value = val;
		break;
	}
	default:
		g_assert_not_reached ();
		break;
	}
}
示例#5
0
static gboolean
write_attr_accessor(IDL_tree attr_tree, FILE * outfile,
                    gboolean getter, const char *className)
{
    char *attrname = ATTR_IDENT(attr_tree).str;

    fprintf(outfile, "function %cet%c%s(",
            getter ? 'G' : 'S',
            toupper(*attrname), attrname + 1);
    /* Setters for string, wstring, nsid, domstring, utf8string, 
     * cstring and astring get const. 
     */
    if (!getter &&
        (IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_STRING ||
         IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_WIDE_STRING ||
         IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "nsid") ||
         IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "domstring")  ||
         IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "utf8string") ||
         IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "cstring")    ||
         IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "astring")))
    {
        fputs("const ", outfile);
    }

    fprintf(outfile, "%s",
            (getter && !DIPPER_TYPE(ATTR_TYPE_DECL(attr_tree)))? "out " : "");
    fprintf(outfile, "a%c%s", toupper(attrname[0]), attrname + 1);
    if (!interface_write_type(ATTR_TYPE_DECL(attr_tree), getter, FALSE, FALSE, FALSE, NULL, outfile))
        return FALSE;
    fputc(')', outfile);
    return TRUE;
}
示例#6
0
static gboolean coder_get_type_info(IDL_tree tree, int attr, TypeInfo* type)
{
	const char* name = "";
	type->attr = attr;
	if(attr == IDL_PARAM_INOUT)
	{
		assert(!"Not supported.");
	}

	memset(type, 0x00, sizeof(TypeInfo));
	if(IDL_NODE_IS_TYPE(tree))
	{
		switch(IDL_NODE_TYPE(tree))
		{
			case IDLN_TYPE_INTEGER:
			{
				name = "int";
				break;
			}
			case IDLN_TYPE_STRING:
			{
				name = "String";
				break;
			}
			default:
			{
				assert(!"Not supported");
				break;
			}

		}
	}
	else if(IDL_NODE_TYPE(tree) == IDLN_IDENT)
	{
		name = IDL_IDENT(tree).str;
	}
	
	strcat(type->org_name, name);
	if(strcmp(name, "int") == 0)
	{
		strcat(type->name, "int");
	}
	else if(strcmp(name, "String") == 0)
	{
		strcat(type->name, attr == IDL_PARAM_OUT ? "" : "const ");
		strcat(type->name, "char*");
	}
	else if(strcmp(name, "FBusBinary") == 0)
	{
		type->is_binary = TRUE;
	}
	else
	{
		strcat(type->name, attr == IDL_PARAM_OUT ? "" : "const ");
		strcat(type->name, name);
		strcat(type->name, attr == IDL_PARAM_IN ? "*" : "");
	}

	return TRUE;
}
示例#7
0
文件: types.c 项目: ksandstr/muidl
bool is_signed(IDL_tree typ)
{
	assert(is_integral_type(typ));
	return IDL_NODE_TYPE(typ) == IDLN_TYPE_CHAR
		|| IDL_NODE_TYPE(typ) == IDLN_TYPE_WIDE_CHAR
		|| (IDL_NODE_TYPE(typ) == IDLN_TYPE_INTEGER
			&& IDL_TYPE_INTEGER(typ).f_signed);
}
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;
}
示例#9
0
/* If notype is true, just write the param name. */
static gboolean
write_param(IDL_tree param_tree, FILE *outfile)
{
    IDL_tree param_type_spec = IDL_PARAM_DCL(param_tree).param_type_spec;
    gboolean is_in = IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_IN;
    /* in string, wstring, nsid, domstring, utf8string, cstring and 
     * astring any explicitly marked [const] are const 
     */

    if (is_in &&
        (IDL_NODE_TYPE(param_type_spec) == IDLN_TYPE_STRING ||
         IDL_NODE_TYPE(param_type_spec) == IDLN_TYPE_WIDE_STRING ||
         IDL_tree_property_get(IDL_PARAM_DCL(param_tree).simple_declarator,
                               "const") ||
         IDL_tree_property_get(param_type_spec, "nsid") ||
         IDL_tree_property_get(param_type_spec, "domstring")  ||
         IDL_tree_property_get(param_type_spec, "utf8string") ||
         IDL_tree_property_get(param_type_spec, "cstring")    ||
         IDL_tree_property_get(param_type_spec, "astring"))) {
        fputs("const ", outfile);
    }
    else if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_OUT &&
             IDL_tree_property_get(IDL_PARAM_DCL(param_tree).simple_declarator, 
                                   "shared")) {
        fputs("const ", outfile);
    }

    if (!write_type(param_type_spec, !is_in, outfile))
        return FALSE;

    /* unless the type ended in a *, add a space */
    if (!STARRED_TYPE(param_type_spec))
        fputc(' ', outfile);

    /* out and inout params get a bonus '*' (unless this is type that has a 
     * 'dipper' class that is passed in to receive 'out' data) 
     */
    if (IDL_PARAM_DCL(param_tree).attr != IDL_PARAM_IN &&
        !DIPPER_TYPE(param_type_spec)) {
        fputc('*', outfile);
    }
    /* arrays get a bonus * too */
    /* XXX Should this be a leading '*' or a trailing "[]" ?*/
    if (IDL_tree_property_get(IDL_PARAM_DCL(param_tree).simple_declarator,
                              "array"))
        fputc('*', outfile);

    fputs(IDL_IDENT(IDL_PARAM_DCL(param_tree).simple_declarator).str, outfile);

    if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_OUT) {
        fputs(" NS_OUTPARAM", outfile);
    } else if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_INOUT) {
        fputs(" NS_INOUTPARAM", outfile);
    }

    return TRUE;
}
示例#10
0
void IDL_ns_push_scope (IDL_ns ns, IDL_tree ns_ident)
{
	IDL_NS_ASSERTS;

	assert (IDL_NODE_TYPE (ns_ident) == IDLN_GENTREE);
	assert (IDL_NODE_TYPE (IDL_GENTREE (ns_ident).data) == IDLN_IDENT);
	assert (IDL_NS (ns).current == IDL_NODE_UP (ns_ident));

	IDL_NS (ns).current = ns_ident;
}
static CORBA_UnionMemberSeq *
MateCORBA_imodule_get_union_members (GHashTable        *typecodes,
				 IDL_tree           tree,
				 CORBA_TypeCode     switchtc,
				 CORBA_Environment *ev)
{
	CORBA_UnionMemberSeq *members;
	IDL_tree              l;
	int                   num_members = 0;
	int                   i;

	g_return_val_if_fail (IDL_NODE_TYPE (tree) == IDLN_TYPE_UNION, NULL);

	for (l = IDL_TYPE_UNION (tree).switch_body; l; l = IDL_LIST (l).next)
		num_members += IDL_list_length (IDL_CASE_STMT (IDL_LIST (l).data).labels);

	members = CORBA_UnionMemberSeq__alloc ();

	members->_length  = members->_maximum = num_members;
	members->_buffer  = CORBA_UnionMemberSeq_allocbuf (members->_length);
	members->_release = CORBA_TRUE;

	for (i = 0, l = IDL_TYPE_UNION (tree).switch_body; l; l = IDL_LIST (l).next) {
		CORBA_TypeCode subtc;
		IDL_tree       member, label, dcl;

		member = IDL_CASE_STMT (IDL_LIST (l).data).element_spec;
		g_assert (IDL_NODE_TYPE (member) == IDLN_MEMBER);

		subtc = MateCORBA_imodule_get_typecode (
				typecodes, IDL_MEMBER (member).type_spec);
		dcl = IDL_LIST (IDL_MEMBER (member).dcls).data;

		for (label = IDL_CASE_STMT (IDL_LIST (l).data).labels; label;
		     label = IDL_LIST (label).next, i++) {
			CORBA_UnionMember *umember = &members->_buffer [i];

			MateCORBA_imodule_setup_label_any (
				switchtc, IDL_LIST (label).data, &umember->label);

			umember->label._release = CORBA_TRUE;

			umember->name     = CORBA_string_dup (IDL_IDENT (dcl).str);
			umember->type     = (CORBA_TypeCode)
						CORBA_Object_duplicate ((CORBA_Object) subtc, ev);
			umember->type_def = CORBA_OBJECT_NIL; /* Not used? */
		}

		CORBA_Object_release ((CORBA_Object) subtc, ev);
	}

	g_assert (i == num_members);

	return members;
}
示例#12
0
/*
  This function is called for each parent to check if the current parent introduced the
  overriden method. If yes, the parameter info is taken from this parent and put into the
  file.
 */
static
void VoyagerDoWriteParamsForOverridenMethod(IDL_tree curif, InheritedOutputInfo2 *ioi)
{
  IDL_tree curitem;
  char* overridenMethodName;

  if(curif == ioi->realif)
    return;

  overridenMethodName=ioi->chrOverridenMethodName;

  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)){
          IDL_tree  sub;
          
          g_assert (IDL_NODE_TYPE(curop) == IDLN_OP_DCL);

          /* return typespec */
          orbit_cbe_write_param_typespec (ioi->of, curop);
          
          /* The methodname */
          fprintf (ioi->of, " %s%s_%s", "NOMLINK impl_",
                   ioi->chrClassName, overridenMethodName);
          
          fprintf (ioi->of, "(%s* nomSelf, ", ioi->chrClassName);
          
          /* Write the params including the typespec */          
          for (sub = IDL_OP_DCL (curop).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
            IDL_tree parm = IDL_LIST (sub).data;
            
            orbit_cbe_write_param_typespec (ioi->of, parm);
            
            fprintf (ioi->of, " %s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
          }
          
          if (IDL_OP_DCL (curop).context_expr)
            fprintf (ioi->of, "CORBA_Context _ctx, ");
          
          fprintf (ioi->of, "CORBA_Environment *ev)");
        }
        break;
      }
	default:
	  break;
    }
  }
}
示例#13
0
/*
 *  AS_DECL writes 'NS_IMETHOD foo(string bar, long sil)'
 *  AS_IMPL writes 'NS_IMETHODIMP className::foo(string bar, long sil)'
 *  AS_CALL writes 'foo(bar, sil)'
 */
static gboolean
write_attr_accessor(IDL_tree attr_tree, FILE * outfile,
                    gboolean getter, int mode, const char *className)
{
    char *attrname = ATTR_IDENT(attr_tree).str;
    const char *binaryname;
    IDL_tree ident = IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data;

    if (mode == AS_DECL) {
        if (IDL_tree_property_get(ident, "deprecated"))
            fputs("NS_DEPRECATED ", outfile);
        if (is_method_scriptable(attr_tree, ident))
            fputs("NS_SCRIPTABLE ", outfile);

        fputs("NS_IMETHOD ", outfile);
    } else if (mode == AS_IMPL) {
        fprintf(outfile, "NS_IMETHODIMP %s::", className);
    }
    fprintf(outfile, "%cet",
            getter ? 'G' : 'S');
    binaryname = IDL_tree_property_get(ATTR_DECLS(attr_tree), "binaryname");
    if (binaryname) {
        fprintf(outfile, "%s(",
                binaryname);
    } else {
        fprintf(outfile, "%c%s(",
                toupper(*attrname),
                attrname + 1);
    }
    if (mode == AS_DECL || mode == AS_IMPL) {
        /* Setters for string, wstring, nsid, domstring, utf8string, 
         * cstring and astring get const. 
         */
        if (!getter &&
            (IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_STRING ||
             IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_WIDE_STRING ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "nsid") ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "domstring")  ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "utf8string") ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "cstring")    ||
             IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "astring")))
        {
            fputs("const ", outfile);
        }

        if (!write_type(ATTR_TYPE_DECL(attr_tree), getter, outfile))
            return FALSE;
        fprintf(outfile, "%s%s",
                (STARRED_TYPE(attr_tree) ? "" : " "),
                (getter && !DIPPER_TYPE(ATTR_TYPE_DECL(attr_tree)))? "*" : "");
    }
    fprintf(outfile, "a%c%s)", toupper(attrname[0]), attrname + 1);
    return TRUE;
}
/*
 * If p is an ident for an interface, and we don't have an entry in the
 * interface map yet, add one.
 */
static gboolean
add_interface_maybe(IDL_tree_func_data *tfd, gpointer user_data)
{
    TreeState *state = user_data;
    IDL_tree up;
    if (IDL_NODE_TYPE(tfd->tree) == IDLN_IDENT) {
        IDL_tree_type node_type = IDL_NODE_TYPE((up = IDL_NODE_UP(tfd->tree)));
        if (node_type == IDLN_INTERFACE || node_type == IDLN_FORWARD_DCL) {

            /* We only want to add a new entry if there is no entry by this 
             * name or if the previously found entry was just a forward 
             * declaration and the new entry is not.
             */

            char *iface = IDL_IDENT(tfd->tree).str;
            NewInterfaceHolder *old_holder = (NewInterfaceHolder *) 
                    g_hash_table_lookup(IFACE_MAP(state), iface);
            if (old_holder && old_holder->is_forward_dcl &&
                node_type != IDLN_FORWARD_DCL)
            {
                g_hash_table_remove(IFACE_MAP(state), iface);
                DeleteNewInterfaceHolder(old_holder);
                old_holder = NULL;
            }
            if (!old_holder) {
                /* XXX should we parse here and store a struct nsID *? */
                char *iid = (char *)IDL_tree_property_get(tfd->tree, "uuid");
                char *name_space = (char *)
                            IDL_tree_property_get(tfd->tree, "namespace");
                NewInterfaceHolder *holder =
                        CreateNewInterfaceHolder(iface, name_space, iid,
                                     (gboolean) node_type == IDLN_FORWARD_DCL);
                if (!holder)
                    return FALSE;
                g_hash_table_insert(IFACE_MAP(state),
                                    holder->full_name, holder);
                IFACES(state)++;
#ifdef DEBUG_shaver_ifaces
                fprintf(stderr, "adding interface #%d: %s/%s\n", IFACES(state),
                        iface, iid[0] ? iid : "<unresolved>");
#endif
            }
        } else {
#ifdef DEBUG_shaver_ifaces
            fprintf(stderr, "ident %s isn't an interface (%s)\n",
                    IDL_IDENT(tfd->tree).str, IDL_NODE_TYPE_NAME(up));
#endif
        }
    }

    return TRUE;
}
static CORBA_StructMemberSeq *
MateCORBA_imodule_get_struct_members (GHashTable        *typecodes,
				  IDL_tree           tree,
				  CORBA_Environment *ev)
{
	CORBA_StructMemberSeq *members;
	IDL_tree               l;
	int                    num_members = 0;
	int                    i;

	g_return_val_if_fail (IDL_NODE_TYPE (tree) == IDLN_TYPE_STRUCT ||
			      IDL_NODE_TYPE (tree) == IDLN_EXCEPT_DCL, NULL);

	for (l = IDL_TYPE_STRUCT (tree).member_list; l; l = IDL_LIST (l).next)
		num_members += IDL_list_length (IDL_MEMBER (IDL_LIST (l).data).dcls);

	members = CORBA_StructMemberSeq__alloc ();

	members->_length  = members->_maximum = num_members;
	members->_buffer  = CORBA_StructMemberSeq_allocbuf (members->_length);
	members->_release = CORBA_TRUE;

	for (i = 0, l = IDL_TYPE_STRUCT (tree).member_list; l; l = IDL_LIST (l).next) {
		CORBA_TypeCode subtc;
		IDL_tree       dcl;

		subtc = MateCORBA_imodule_get_typecode (
				typecodes, IDL_MEMBER (IDL_LIST (l).data).type_spec);

		for (dcl = IDL_MEMBER (IDL_LIST (l).data).dcls; dcl;
		     dcl = IDL_LIST (dcl).next, i++) {
			CORBA_StructMember *member = &members->_buffer [i];
			CORBA_string        name;

			if (IDL_NODE_TYPE (dcl) == IDLN_IDENT)
				name = IDL_IDENT (dcl).str;
			else /* IDLN_TYPE_ARRAY */
				name = IDL_IDENT (IDL_TYPE_ARRAY (dcl).ident).str;

			member->name     = CORBA_string_dup (name);
			member->type     = (CORBA_TypeCode)
						CORBA_Object_duplicate ((CORBA_Object) subtc, ev);
			member->type_def = CORBA_OBJECT_NIL; /* Not used? */
		}

		CORBA_Object_release ((CORBA_Object) subtc, ev);
	}

	g_assert (i == num_members);

	return members;
}
static gboolean
do_typedef(TreeState *state)
{
    IDL_tree type = IDL_TYPE_DCL(state->tree).type_spec;
    IDL_tree dcls = IDL_TYPE_DCL(state->tree).dcls;
    IDL_tree complex;
    GSList *doc_comments;

    if (IDL_NODE_TYPE(type) == IDLN_TYPE_SEQUENCE) {
        XPIDL_WARNING((state->tree, IDL_WARNING1,
                       "sequences not supported, ignored"));
    } else {
        if (IDL_NODE_TYPE(complex = IDL_LIST(dcls).data) == IDLN_TYPE_ARRAY) {
            IDL_tree dim = IDL_TYPE_ARRAY(complex).size_list;
            doc_comments = IDL_IDENT(IDL_TYPE_ARRAY(complex).ident).comments;

            if (doc_comments != NULL)
                printlist(state->file, doc_comments);

            fputs("typedef ", state->file);
            if (!write_type(type, FALSE, state->file))
                return FALSE;
            fputs(" ", state->file);

            fprintf(state->file, "%s",
                    IDL_IDENT(IDL_TYPE_ARRAY(complex).ident).str);
            do {
                fputc('[', state->file);
                if (IDL_LIST(dim).data) {
                    fprintf(state->file, "%ld",
                            (long)IDL_INTEGER(IDL_LIST(dim).data).value);
                }
                fputc(']', state->file);
            } while ((dim = IDL_LIST(dim).next) != NULL);
        } else {
            doc_comments = IDL_IDENT(IDL_LIST(dcls).data).comments;

            if (doc_comments != NULL)
                printlist(state->file, doc_comments);

            fputs("typedef ", state->file);
            if (!write_type(type, FALSE, state->file))
                return FALSE;
            fputs(" ", state->file);
            fputs(IDL_IDENT(IDL_LIST(dcls).data).str, state->file);
        }
        fputs(";\n\n", state->file);
    }
    return TRUE;
}
示例#17
0
static void
orbit_output_tcstruct_sub_parts (FILE *fh, IDL_tree node)
{
	int length = 0;

	switch (IDL_NODE_TYPE (node)) {
	case IDLN_TYPE_STRUCT:
	case IDLN_EXCEPT_DCL: {
		IDL_tree l;

		for (l = IDL_TYPE_STRUCT (node).member_list; l; l = IDL_LIST (l).next) {
			IDL_tree member;

			member = IDL_LIST (l).data;

			g_assert (IDL_NODE_TYPE (member) == IDLN_MEMBER);

			length += IDL_list_length (IDL_MEMBER (member).dcls);
		}
		}
		break;
	case IDLN_TYPE_UNION: {
		IDL_tree l;

		for (l = IDL_TYPE_UNION (node).switch_body; l; l = IDL_LIST (l).next) {
			IDL_tree case_stmt;

			case_stmt = IDL_LIST (l).data;

			g_assert (IDL_NODE_TYPE (case_stmt) == IDLN_CASE_STMT);

			length += IDL_list_length (IDL_CASE_STMT (case_stmt).labels);
		}
		}
		break;
	case IDLN_TYPE_ENUM:
		length = IDL_list_length (IDL_TYPE_ENUM (node).enumerator_list);
		break;
	case IDLN_IDENT:
	case IDLN_TYPE_SEQUENCE:
	case IDLN_TYPE_ARRAY:
		length = 1;
		break;
	default:
		length = 0;
		break;
	}

	fprintf (fh, "%d\n", length);
}
示例#18
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;
  }
}
示例#19
0
static int is_visited_interface (GHashTable *visited_interfaces, IDL_tree scope)
{
	assert (scope != NULL);
	assert (IDL_NODE_TYPE (scope) == IDLN_GENTREE);
	/* If already visited, do not visit again */
	return g_hash_table_lookup_extended (visited_interfaces, scope, NULL, NULL);
}
示例#20
0
static void
orte_idl_tree_fake_ops (IDL_tree tree, IDL_ns ns)
{
	IDL_tree node;

	if (!tree)
		return;

	switch(IDL_NODE_TYPE(tree)) {
	case IDLN_MODULE:
		orte_idl_tree_fake_ops (IDL_MODULE (tree).definition_list, ns);
		break;
	case IDLN_INTERFACE:
		orte_idl_tree_fake_ops (IDL_INTERFACE (tree).body, ns);
		break;
	case IDLN_LIST:
		for (node = tree; node; node = IDL_LIST (node).next)
			orte_idl_tree_fake_ops (IDL_LIST (node).data, ns);
		break;
	case IDLN_ATTR_DCL:
		orte_idl_attr_fake_ops (tree, ns);
		break;
	default:
		break;
	}
}
CORBA_TypeCode
MateCORBA_imodule_create_alias_typecode (GHashTable    *typecodes,
				     IDL_tree       tree,
				     CORBA_TypeCode original_type)
{
	CORBA_Environment env;
	CORBA_TypeCode    retval;

	CORBA_exception_init (&env);

	g_return_val_if_fail (IDL_NODE_TYPE (tree) == IDLN_IDENT, NULL);
	g_return_val_if_fail (g_hash_table_lookup (typecodes,
						   IDL_IDENT (tree).repo_id) == NULL, NULL);

	retval = CORBA_ORB_create_alias_tc (NULL,
			IDL_IDENT (tree).repo_id,
			IDL_IDENT (tree).str,
			original_type, &env);

	MateCORBA_imodule_register_typecode (
			typecodes, IDL_IDENT (tree).repo_id, retval);

	if (env._major != CORBA_NO_EXCEPTION)
		g_warning ("MateCORBA_imodule_create_alias_typecode: exception %s", env._id);

	CORBA_exception_free (&env);

	return retval;
}
示例#22
0
static gboolean
cc_output_tc_walker (IDL_tree_func_data *tfd,
		     OIDL_C_Info        *ci)
{
	IDL_tree tree = tfd->tree;

	switch(IDL_NODE_TYPE (tree)) {
	case IDLN_CONST_DCL:
	case IDLN_ATTR_DCL:
	case IDLN_OP_DCL:
		return FALSE; /* dont recurse into these */

	case IDLN_TYPE_SEQUENCE:
		if (!tfd->step) {
			cc_typecode_prep_sequence (tree, ci);
			break;
		}
		/* drop through */

	case IDLN_INTERFACE:
	case IDLN_EXCEPT_DCL:
	case IDLN_TYPE_STRUCT:
	case IDLN_TYPE_UNION:
	case IDLN_TYPE_DCL:
	case IDLN_TYPE_ENUM:
	case IDLN_TYPE_FIXED:
		if (tfd->step)
			orbit_output_typecode (ci, tree);
		break;
	default:
		break;
	}

	return TRUE; /* continue walking */
}
static CORBA_EnumMemberSeq *
MateCORBA_imodule_get_enum_members (IDL_tree           tree,
				CORBA_Environment *ev)
{
	CORBA_EnumMemberSeq *members;
	IDL_tree             l;
	int                  num_members = 0;
	int                  i;

	g_return_val_if_fail (IDL_NODE_TYPE (tree) == IDLN_TYPE_ENUM, NULL);

	num_members = IDL_list_length (IDL_TYPE_ENUM (tree).enumerator_list);

	members = CORBA_EnumMemberSeq__alloc ();

	members->_length  = members->_maximum = num_members;
	members->_buffer  = CORBA_EnumMemberSeq_allocbuf (members->_length);
	members->_release = CORBA_TRUE;

	for (i = 0, l = IDL_TYPE_ENUM (tree).enumerator_list; l; i++, l = IDL_LIST (l).next)
		members->_buffer [i] = CORBA_string_dup (IDL_IDENT (IDL_LIST (l).data).str);

	g_assert (i == num_members);

	return members;
}
示例#24
0
static void
output_deps (IDL_tree tree, 
	     OIDL_Run_Info *rinfo, 
	     OIDL_C_Info *ci)
{
	if (!tree)
		return;

	switch (IDL_NODE_TYPE (tree)) {
	case IDLN_SRCFILE: {
		char *idlfn = IDL_SRCFILE (tree).filename;
		fprintf (ci->fh, " \\\n\t%s", idlfn);
		break;
	}

	case IDLN_MODULE:
		output_deps (IDL_MODULE (tree).definition_list, rinfo, ci);
		break;

	case IDLN_LIST: {
		IDL_tree sub;

		for (sub = tree; sub; sub = IDL_LIST (sub).next)
			output_deps (IDL_LIST (sub).data, rinfo, ci);
		break;
	}

	case IDLN_INTERFACE:
		output_deps (IDL_INTERFACE (tree).body, rinfo, ci);
		break;

	default:
		break;
	}
}
示例#25
0
static void
orbit_output_tcstruct_repo_id (FILE *fh, IDL_tree node, int array_gen_ctr)
{
	switch (IDL_NODE_TYPE (node)) {
	case IDLN_TYPE_STRUCT:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_TYPE_STRUCT (node).ident).repo_id);
		break;
	case IDLN_TYPE_UNION:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_TYPE_UNION (node).ident).repo_id);
		break;
	case IDLN_TYPE_ENUM:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_TYPE_ENUM (node).ident).repo_id);
		break;
	case IDLN_INTERFACE:
	case IDLN_FORWARD_DCL:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_INTERFACE (node).ident).repo_id);
		break;
	case IDLN_EXCEPT_DCL:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_EXCEPT_DCL (node).ident).repo_id);
		break;
	case IDLN_IDENT:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (node).repo_id);
		break;
	case IDLN_TYPE_ARRAY:
		if (!array_gen_ctr)
			fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_TYPE_ARRAY (node).ident).repo_id);
		else
			fprintf (fh, "NULL");
		break;
	default:
		fprintf (fh, "NULL");
		break;
	}
}
示例#26
0
static
void VoyagerWriteParamsForParentCall(IDL_tree curif, InheritedOutputInfo2 *ioi)
{
  IDL_tree curitem;
  char* overridenMethodName;

  if(curif == ioi->realif)
    return;

  overridenMethodName=ioi->chrOverridenMethodName;

  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)){
          IDL_tree  sub;

          for (sub = IDL_OP_DCL (curop).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
            IDL_tree parm = IDL_LIST (sub).data;
            fprintf (ioi->of, "%s, ", IDL_IDENT (IDL_PARAM_DCL (parm).simple_declarator).str);
          }
        }
        break;
      }
	default:
	  break;
    }
  }
}
示例#27
0
static void
orbit_output_tcstruct_subnames (FILE *fh, IDL_tree node, int subnames_id)
{
	switch (IDL_NODE_TYPE (node)) {
	case IDLN_TYPE_ENUM:
		if (IDL_TYPE_ENUM (node).enumerator_list)
			fprintf (fh, "(char **)anon_subnames_array%d", subnames_id);
		else
			fprintf (fh, "NULL");
		break;
	case IDLN_TYPE_UNION:
		if (IDL_TYPE_UNION (node).switch_body)
			fprintf (fh, "(char **)anon_subnames_array%d", subnames_id);
		else
			fprintf (fh, "NULL");
		break;
	case IDLN_TYPE_STRUCT:
	case IDLN_EXCEPT_DCL:
		if (IDL_TYPE_STRUCT (node).member_list)
			fprintf (fh, "(char **)anon_subnames_array%d", subnames_id);
		else
			fprintf (fh, "NULL");
		break;
	default:
		fprintf (fh, "NULL");
		break;
	}
}
示例#28
0
int IDL_ns_check_for_ambiguous_inheritance (IDL_tree interface_ident, IDL_tree p)
{
	/* We use a sorted heap to check for namespace collisions,
	   since we must do case-insensitive collision checks.
	   visited_interfaces is a hash of visited interface nodes, so
	   we only visit common ancestors once. */
	GTree *ident_heap;
	GHashTable *visited_interfaces;
	int is_ambiguous = 0;

	if (!p)
		return 0;

	ident_heap = g_tree_new (IDL_ident_cmp);
	visited_interfaces = g_hash_table_new (g_direct_hash, g_direct_equal);

	assert (IDL_NODE_TYPE (p) == IDLN_LIST);
	for (; p;  p = IDL_LIST (p).next) {
		if (!IDL_ns_load_idents_to_tables (interface_ident, IDL_LIST (p).data,
						   ident_heap, visited_interfaces))
			is_ambiguous = 1;
	}

	g_tree_destroy (ident_heap);
	g_hash_table_destroy (visited_interfaces);

	return is_ambiguous;
}
示例#29
0
static void
orbit_output_tcstruct_subtypes (FILE *fh, IDL_tree node, int subtypes_id)
{
	switch (IDL_NODE_TYPE (node)) {
	case IDLN_EXCEPT_DCL:
	case IDLN_TYPE_STRUCT:
		if (IDL_TYPE_STRUCT (node).member_list)
			fprintf (fh, "(CORBA_TypeCode *)anon_subtypes_array%d", subtypes_id);
		else
			fprintf (fh, "NULL");
		break;
	case IDLN_TYPE_UNION:
		if (IDL_TYPE_UNION (node).switch_body)
			fprintf (fh, "(CORBA_TypeCode *)anon_subtypes_array%d", subtypes_id);
		else
			fprintf (fh, "NULL");
		break;
	case IDLN_TYPE_SEQUENCE:
	case IDLN_TYPE_ARRAY:
	case IDLN_IDENT:
		fprintf (fh, "(CORBA_TypeCode *)anon_subtypes_array%d", subtypes_id);
		break;
	default:
		fprintf (fh, "NULL");
		break;
	}
}
示例#30
0
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;
}