コード例 #1
2
/*
 * Common method verification code, called by *op_dcl in the various backends.
 */
gboolean
verify_method_declaration(IDL_tree method_tree)
{
    struct _IDL_OP_DCL *op = &IDL_OP_DCL(method_tree);
    IDL_tree iface;
    IDL_tree iter;
    gboolean notxpcom;
    gboolean scriptable_interface;
    gboolean scriptable_method;
    gboolean seen_retval = FALSE;
    const char *method_name = IDL_IDENT(IDL_OP_DCL(method_tree).ident).str;

    /* We don't support attributes named IID, conflicts with static GetIID 
     * member. The conflict is due to certain compilers (VC++) choosing a
     * different vtable order, placing GetIID at the beginning regardless
     * of it's placement
     */
    if (strcmp(method_name, "GetIID") == 0) {
        IDL_tree_error(method_tree,
                       "Methods named GetIID not supported, causes vtable "
                       "ordering problems");
        return FALSE;
    }
    if (op->f_varargs) {
        /* We don't currently support varargs. */
        IDL_tree_error(method_tree, "varargs are not currently supported");
        return FALSE;
    }

    /* 
     * Verify that we've been called on an interface, and decide if the
     * interface was marked [scriptable].
     */
    if (IDL_NODE_UP(method_tree) && IDL_NODE_UP(IDL_NODE_UP(method_tree)) &&
        IDL_NODE_TYPE(iface = IDL_NODE_UP(IDL_NODE_UP(method_tree))) 
        == IDLN_INTERFACE)
    {
        scriptable_interface =
            (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable")
             != NULL);
    } else {
        IDL_tree_error(method_tree,
                       "verify_method_declaration called on a non-interface?");
        return FALSE;
    }

    /*
     * Require that any method in an interface marked as [scriptable], that
     * *isn't* scriptable because it refers to some native type, be marked
     * [noscript] or [notxpcom].
     *
     * Also check that iid_is points to nsid, and length_is, size_is points
     * to unsigned long.
     */
    notxpcom = IDL_tree_property_get(op->ident, "notxpcom") != NULL;

    scriptable_method = scriptable_interface &&
        !notxpcom &&
        IDL_tree_property_get(op->ident, "noscript") == NULL;

    /* Loop through the parameters and check. */
    for (iter = op->parameter_dcls; iter; iter = IDL_LIST(iter).next) {
        IDL_tree param = IDL_LIST(iter).data;
        IDL_tree param_type =
            IDL_PARAM_DCL(param).param_type_spec;
        IDL_tree simple_decl =
            IDL_PARAM_DCL(param).simple_declarator;
        const char *param_name = IDL_IDENT(simple_decl).str;
        
        /*
         * Reject this method if it should be scriptable and some parameter is
         * native that isn't marked with either nsid, domstring, utf8string, 
         * cstring, astring or iid_is.
         */
        if (scriptable_method &&
            UP_IS_NATIVE(param_type) &&
            IDL_tree_property_get(param_type, "nsid") == NULL &&
            IDL_tree_property_get(simple_decl, "iid_is") == NULL &&
            IDL_tree_property_get(param_type, "domstring") == NULL &&
            IDL_tree_property_get(param_type, "utf8string") == NULL &&
            IDL_tree_property_get(param_type, "cstring") == NULL &&
            IDL_tree_property_get(param_type, "astring") == NULL)
        {
            IDL_tree_error(method_tree,
                           "methods in [scriptable] interfaces that are "
                           "non-scriptable because they refer to native "
                           "types (parameter \"%s\") must be marked "
                           "[noscript]", param_name);
            return FALSE;
        }

        /* 
         * nsid's parameters that aren't ptr's or ref's are not currently 
         * supported in xpcom or non-xpcom (marked with [notxpcom]) methods 
         * as input parameters
         */
        if (!(notxpcom && IDL_PARAM_DCL(param).attr != IDL_PARAM_IN) &&
            IDL_tree_property_get(param_type, "nsid") != NULL &&
            IDL_tree_property_get(param_type, "ptr") == NULL &&
            IDL_tree_property_get(param_type, "ref") == NULL) 
        {
            IDL_tree_error(method_tree,
                           "Feature currently not supported: "
                           "parameter \"%s\" is of type nsid and "
                           "must be marked either [ptr] or [ref] "
                           "or method \"%s\" must be marked [notxpcom] "
                           "and must not be an input parameter",
                           param_name,
                           method_name);
            return FALSE;
        }
        /*
         * Sanity checks on return values.
         */
        if (IDL_tree_property_get(simple_decl, "retval") != NULL) {
            if (IDL_LIST(iter).next != NULL) {
                IDL_tree_error(method_tree,
                               "only the last parameter can be marked [retval]");
                return FALSE;
            }
            if (op->op_type_spec) {
                IDL_tree_error(method_tree,
                               "can't have [retval] with non-void return type");
                return FALSE;
            }
            /* In case XPConnect relaxes the retval-is-last restriction. */
            if (seen_retval) {
                IDL_tree_error(method_tree,
                               "can't have more than one [retval] parameter");
                return FALSE;
            }
            seen_retval = TRUE;
        }

        /*
         * Confirm that [shared] attributes are only used with string, wstring,
         * or native (but not nsid, domstring, utf8string, cstring or astring) 
         * and can't be used with [array].
         */
        if (IDL_tree_property_get(simple_decl, "shared") != NULL) {
            IDL_tree real_type;
            real_type = find_underlying_type(param_type);
            real_type = real_type ? real_type : param_type;

            if (IDL_tree_property_get(simple_decl, "array") != NULL) {
                IDL_tree_error(method_tree,
                               "[shared] parameter \"%s\" cannot "
                               "be of array type", param_name);
                return FALSE;
            }                

            if (!(IDL_NODE_TYPE(real_type) == IDLN_TYPE_STRING ||
                  IDL_NODE_TYPE(real_type) == IDLN_TYPE_WIDE_STRING ||
                  (UP_IS_NATIVE(real_type) &&
                   !IDL_tree_property_get(real_type, "nsid") &&
                   !IDL_tree_property_get(real_type, "domstring")  &&
                   !IDL_tree_property_get(real_type, "utf8string") &&
                   !IDL_tree_property_get(real_type, "cstring")    &&
                   !IDL_tree_property_get(real_type, "astring"))))
            {
                IDL_tree_error(method_tree,
                               "[shared] parameter \"%s\" must be of type "
                               "string, wstring or native", param_name);
                return FALSE;
            }
        }

        /*
         * inout is not allowed with "domstring", "UTF8String", "CString" 
         * and "AString" types
         */
        if (IDL_PARAM_DCL(param).attr == IDL_PARAM_INOUT &&
            UP_IS_NATIVE(param_type) &&
            (IDL_tree_property_get(param_type, "domstring")  != NULL ||
             IDL_tree_property_get(param_type, "utf8string") != NULL ||
             IDL_tree_property_get(param_type, "cstring")    != NULL ||
             IDL_tree_property_get(param_type, "astring")    != NULL )) {
            IDL_tree_error(method_tree,
                           "[domstring], [utf8string], [cstring], [astring] "
                           "types cannot be used as inout parameters");
            return FALSE;
        }


        /*
         * arrays of domstring, utf8string, cstring, astring types not allowed
         */
        if (IDL_tree_property_get(simple_decl, "array") != NULL &&
            UP_IS_NATIVE(param_type) &&
            (IDL_tree_property_get(param_type, "domstring")  != NULL ||
             IDL_tree_property_get(param_type, "utf8string") != NULL ||
             IDL_tree_property_get(param_type, "cstring")    != NULL ||
             IDL_tree_property_get(param_type, "astring")    != NULL)) {
            IDL_tree_error(method_tree,
                           "[domstring], [utf8string], [cstring], [astring] "
                           "types cannot be used in array parameters");
            return FALSE;
        }                

        if (!check_param_attribute(method_tree, param, IID_IS) ||
            !check_param_attribute(method_tree, param, LENGTH_IS) ||
            !check_param_attribute(method_tree, param, SIZE_IS))
            return FALSE;

        /* 
         * Run additional error checks on the parameter type if targetting an 
         * older version of XPConnect.
         */

        if (!verify_type_fits_version(param_type, method_tree))
            return FALSE;
        
    }
    
    /* XXX q: can return type be nsid? */
    /* Native return type? */
    if (scriptable_method &&
        op->op_type_spec != NULL && UP_IS_NATIVE(op->op_type_spec) &&
        IDL_tree_property_get(op->op_type_spec, "nsid") == NULL &&
        IDL_tree_property_get(op->op_type_spec, "domstring") == NULL &&
        IDL_tree_property_get(op->op_type_spec, "utf8string") == NULL &&
        IDL_tree_property_get(op->op_type_spec, "cstring") == NULL &&
        IDL_tree_property_get(op->op_type_spec, "astring") == NULL)
    {
        IDL_tree_error(method_tree,
                       "methods in [scriptable] interfaces that are "
                       "non-scriptable because they return native "
                       "types must be marked [noscript]");
        return FALSE;
    }


    /* 
     * nsid's parameters that aren't ptr's or ref's are not currently 
     * supported in xpcom
     */
    if (!notxpcom &&
        op->op_type_spec != NULL &&
        IDL_tree_property_get(op->op_type_spec, "nsid") != NULL &&
        IDL_tree_property_get(op->op_type_spec, "ptr") == NULL &&
        IDL_tree_property_get(op->op_type_spec, "ref") == NULL) 
    {
        IDL_tree_error(method_tree,
                       "Feature currently not supported: "
                       "return value is of type nsid and "
                       "must be marked either [ptr] or [ref], "
                       "or else method \"%s\" must be marked [notxpcom] ",
                       method_name);
        return FALSE;
    }

    /* 
     * Run additional error checks on the return type if targetting an 
     * older version of XPConnect.
     */

    if (op->op_type_spec != NULL &&
        !verify_type_fits_version(op->op_type_spec, method_tree))
    {
        return FALSE;
    }

    return TRUE;
}
コード例 #2
0
ファイル: orte-idl-utils.c プロジェクト: CTU-IIG/orte
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);
}
コード例 #3
0
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);

}
コード例 #4
0
ファイル: orbit-idl-c-typecode.c プロジェクト: 3v3vuln/ORBit2
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;
	}
}
コード例 #5
0
ファイル: orbit-idl-c-deps.c プロジェクト: 3v3vuln/ORBit2
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;
	}
}
コード例 #6
0
ファイル: orte-idl-driver.c プロジェクト: jiajw0426/easyscada
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;
	}
}
コード例 #7
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;
    }
  }
}
コード例 #8
0
static GSList *
cc_build_interfaces (GSList *list, IDL_tree tree)
{
	if (!tree)
		return list;

	switch (IDL_NODE_TYPE (tree)) {
	case IDLN_MODULE:
		list = cc_build_interfaces (
			list, IDL_MODULE (tree).definition_list);
		break;
	case IDLN_LIST: {
		IDL_tree sub;
		for (sub = tree; sub; sub = IDL_LIST (sub).next)
			list = cc_build_interfaces (
				list, IDL_LIST (sub).data);
		break;
	}
	case IDLN_ATTR_DCL: {
		IDL_tree curitem;
      
		for (curitem = IDL_ATTR_DCL (tree).simple_declarations;
		     curitem; curitem = IDL_LIST (curitem).next) {
			OIDL_Attr_Info *ai = IDL_LIST (curitem).data->data;
	
			list = cc_build_interfaces (list, ai->op1);
			if (ai->op2)
				list = cc_build_interfaces (list, ai->op2);
		}
		break;
	}
	case IDLN_INTERFACE: {
		Interface *i = g_new0 (Interface, 1);

		i->tree = tree;

		list = g_slist_append (list, i);

		list = cc_build_interfaces (list, IDL_INTERFACE(tree).body);

		break;
	}
	case IDLN_OP_DCL: {
		Interface *i;

		g_return_val_if_fail (list != NULL, NULL);

		i = ( g_slist_last(list) )->data;
		i->methods = g_slist_append (i->methods, tree);
		break;
	}
	case IDLN_EXCEPT_DCL:
		break;
	default:
		break;
	}

	return list;
}
コード例 #9
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");
}
コード例 #10
0
static CORBA_TypeCode orbit_idl_tree_type_to_typecode_interface(IDL_tree type)
{
	CORBA_TypeCode typecode = CORBA_ORB_create_interface_tc(
		orbit_get_orb(),
		IDL_IDENT(IDL_INTERFACE(type).ident).repo_id,
		IDL_IDENT(IDL_INTERFACE(type).ident).str,
		orbit_get_environment());

#if 0
	if (typecode != NULL)
	{
		typecode->parent.interface = 0;
		typecode->parent.refs = ORBIT_REFCNT_STATIC;	/* correct? */
	}
#endif

	return typecode;
}
コード例 #11
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;
    }
  }
}
コード例 #12
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)++;
}
コード例 #13
0
static void
cc_output_base_itypes(IDL_tree node, CCSmallInterfaceTraverseInfo *iti)
{
	if (iti->cur_node == node)
		return;

	fprintf (iti->of, "\"%s\",\n",
		 IDL_IDENT(IDL_INTERFACE(node).ident).repo_id);

	iti->parents++;
}
コード例 #14
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;
}
コード例 #15
0
/* Find all the interfaces referenced in the tree (uses add_interface_maybe) */
static gboolean
find_interfaces(IDL_tree_func_data *tfd, gpointer user_data)
{
    IDL_tree node = NULL;

    switch (IDL_NODE_TYPE(tfd->tree)) {
      case IDLN_ATTR_DCL:
        node = IDL_ATTR_DCL(tfd->tree).param_type_spec;
        break;
      case IDLN_OP_DCL:
         IDL_tree_walk_in_order(IDL_OP_DCL(tfd->tree).parameter_dcls, find_interfaces,
                               user_data);
        node = IDL_OP_DCL(tfd->tree).op_type_spec;
        break;
      case IDLN_PARAM_DCL:
        node = IDL_PARAM_DCL(tfd->tree).param_type_spec;
        break;
      case IDLN_INTERFACE:
        node = IDL_INTERFACE(tfd->tree).inheritance_spec;
        if (node)
            xpidl_list_foreach(node, add_interface_maybe, user_data);
        node = IDL_INTERFACE(tfd->tree).ident;
        break;
      case IDLN_FORWARD_DCL:
        node = IDL_FORWARD_DCL(tfd->tree).ident;
        break;
      default:
        node = NULL;
    }

    if (node && IDL_NODE_TYPE(node) == IDLN_IDENT) {
        IDL_tree_func_data new_tfd;
        new_tfd.tree = node;
        add_interface_maybe(&new_tfd, user_data);
    }

    return TRUE;
}
コード例 #16
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);
}
コード例 #17
0
/*
 * Verify that the interface declaration is correct
 */
gboolean
verify_interface_declaration(IDL_tree interface_tree)
{
    IDL_tree iter;
    /* 
     * If we have the scriptable attribute then make sure all of our direct
     * parents have it as well.
     * NOTE: We don't recurse since all interfaces will fall through here
     */
    if (IDL_tree_property_get(IDL_INTERFACE(interface_tree).ident, 
        "scriptable")) {
        for (iter = IDL_INTERFACE(interface_tree).inheritance_spec; iter; 
            iter = IDL_LIST(iter).next) {
            if (IDL_tree_property_get(
                IDL_INTERFACE(iter).ident, "scriptable") == 0) {
                XPIDL_WARNING((interface_tree,IDL_WARNING1,
                    "%s is scriptable but inherits from the non-scriptable interface %s\n",
                    IDL_IDENT(IDL_INTERFACE(interface_tree).ident).str,
                    IDL_IDENT(IDL_INTERFACE(iter).ident).str));
            }
        }
    }
    return TRUE;
}
コード例 #18
0
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);
}
コード例 #19
0
static void
cc_output_skels (IDL_tree       tree,
		 OIDL_Run_Info *rinfo,
		 OIDL_C_Info   *ci,
		 int           *idx)
{
	if (!tree || (tree->declspec & IDLF_DECLSPEC_PIDL))
		return;

	switch (IDL_NODE_TYPE (tree)) {
	case IDLN_MODULE:
		cc_output_skels (IDL_MODULE (tree).definition_list, rinfo, ci, idx);
		break;
	case IDLN_LIST: {
		IDL_tree node;

		for (node = tree; node; node = IDL_LIST (node).next)
			cc_output_skels (IDL_LIST (node).data, rinfo, ci, idx);
		break;
		}
	case IDLN_ATTR_DCL: {
		OIDL_Attr_Info *ai = tree->data;
		IDL_tree        node;
      
		for (node = IDL_ATTR_DCL (tree).simple_declarations; node; node = IDL_LIST (node).next) {
			ai = IDL_LIST (node).data->data;
	
			cc_output_skels (ai->op1, rinfo, ci, idx);
			if (ai->op2)
				cc_output_skels (ai->op2, rinfo, ci, idx);
		}
		break;
		}
	case IDLN_INTERFACE: {
		int real_idx = 0;

		cc_output_skels (IDL_INTERFACE (tree).body, rinfo, ci, &real_idx);
		}
		break;
	case IDLN_OP_DCL:
		cc_output_skel (tree, ci, idx);
		break;
	default:
		break;
	}
}
コード例 #20
0
static void
cs_output_stubs (IDL_tree     tree,
		 OIDL_C_Info *ci,
		 int         *idx)
{
	if (!tree)
		return;
	switch (IDL_NODE_TYPE (tree)) {
	case IDLN_MODULE:
		cs_output_stubs (IDL_MODULE (tree).definition_list, ci, idx);
		break;
	case IDLN_LIST: {
		IDL_tree sub;
		for (sub = tree; sub; sub = IDL_LIST (sub).next)
			cs_output_stubs (IDL_LIST (sub).data, ci, idx);
		break;
		}
	case IDLN_ATTR_DCL: {
		IDL_tree node;
      
		for (node = IDL_ATTR_DCL (tree).simple_declarations; node; node = IDL_LIST (node).next) {
			OIDL_Attr_Info *ai;
			ai = IDL_LIST (node).data->data;
	
			cs_output_stubs (ai->op1, ci, idx);
			if (ai->op2)
				cs_output_stubs (ai->op2, ci, idx);
		}
		break;
		}
	case IDLN_INTERFACE: {
		int real_idx = 0;
		cs_output_stubs (IDL_INTERFACE (tree).body, ci, &real_idx);
		break;
		}
	case IDLN_OP_DCL:
		cs_output_stub (tree, ci, idx);
		break;
	default:
		break;
	}
}
コード例 #21
0
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);
}
コード例 #22
0
ファイル: orte-idl-utils.c プロジェクト: CTU-IIG/orte
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);
}
コード例 #23
0
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);
}
コード例 #24
0
ファイル: orte-idl-utils.c プロジェクト: CTU-IIG/orte
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));
  }
}
コード例 #25
0
static gboolean
interface(TreeState *state)
{
    IDL_tree iface = state->tree, iter, orig;
    char *className = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
    char *classNameUpper = NULL;
    char *classNameImpl = NULL;
    char *cp;
    gboolean ok = TRUE;
    gboolean keepvtable;
    const char *iid;
    const char *name_space;
    struct nsID id;
    char iid_parsed[UUID_LENGTH];
    GSList *doc_comments = IDL_IDENT(IDL_INTERFACE(iface).ident).comments;

    if (!verify_interface_declaration(iface))
        return FALSE;

#define FAIL    do {ok = FALSE; goto out;} while(0)

    fprintf(state->file,   "\n/* starting interface:    %s */\n",
            className);

    name_space = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "namespace");
    if (name_space) {
        fprintf(state->file, "/* namespace:             %s */\n",
                name_space);
        fprintf(state->file, "/* fully qualified name:  %s.%s */\n",
                name_space,className);
    }

    iid = IDL_tree_property_get(IDL_INTERFACE(iface).ident, "uuid");
    if (iid) {
        /* Redundant, but a better error than 'cannot parse.' */
        if (strlen(iid) != 36) {
            IDL_tree_error(state->tree, "IID %s is the wrong length\n", iid);
            FAIL;
        }

        /*
         * Parse uuid and then output resulting nsID to string, to validate
         * uuid and normalize resulting .h files.
         */
        if (!xpidl_parse_iid(&id, iid)) {
            IDL_tree_error(state->tree, "cannot parse IID %s\n", iid);
            FAIL;
        }
        if (!xpidl_sprint_iid(&id, iid_parsed)) {
            IDL_tree_error(state->tree, "error formatting IID %s\n", iid);
            FAIL;
        }

        /* #define NS_ISUPPORTS_IID_STR "00000000-0000-0000-c000-000000000046" */
        fputs("#define ", state->file);
        write_classname_iid_define(state->file, className);
        fprintf(state->file, "_STR \"%s\"\n", iid_parsed);
        fputc('\n', state->file);

        /* #define NS_ISUPPORTS_IID { {0x00000000 .... 0x46 }} */
        fprintf(state->file, "#define ");
        write_classname_iid_define(state->file, className);
        fprintf(state->file, " \\\n"
                "  {0x%.8x, 0x%.4x, 0x%.4x, \\\n"
                "    { 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, "
                "0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x }}\n",
                id.m0, id.m1, id.m2,
                id.m3[0], id.m3[1], id.m3[2], id.m3[3],
                id.m3[4], id.m3[5], id.m3[6], id.m3[7]);
        fputc('\n', state->file);
    } else {
        IDL_tree_error(state->tree, "interface %s lacks a uuid attribute\n", 
            className);
        FAIL;
    }

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

    /*
     * NS_NO_VTABLE is defined in nsISupportsUtils.h, and defined on windows
     * to __declspec(novtable) on windows.  This optimization is safe
     * whenever the constructor calls no virtual methods.  Writing in IDL
     * almost guarantees this, except for the case when a %{C++ block occurs in
     * the interface.  We detect that case, and emit a macro call that disables
     * the optimization.
     */
    keepvtable = FALSE;
    for (iter = IDL_INTERFACE(state->tree).body;
         iter != NULL;
         iter = IDL_LIST(iter).next)
    {
        IDL_tree data = IDL_LIST(iter).data;
        if (IDL_NODE_TYPE(data) == IDLN_CODEFRAG)
            keepvtable = TRUE;
    }
    
    /* The interface declaration itself. */
    fprintf(state->file,
            "class %s%s",
            (keepvtable ? "" : "NS_NO_VTABLE "), className);
    
    if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
        fputs(" : ", state->file);
        if (IDL_LIST(iter).next != NULL) {
            IDL_tree_error(iter,
                           "multiple inheritance is not supported by xpidl");
            FAIL;
        }
        fprintf(state->file, "public %s", IDL_IDENT(IDL_LIST(iter).data).str);
    }
    fputs(" {\n"
          " public: \n\n", state->file);
    if (iid) {
        fputs("  NS_DEFINE_STATIC_IID_ACCESSOR(", state->file);
        write_classname_iid_define(state->file, className);
        fputs(")\n\n", state->file);
    }

    orig = state->tree; /* It would be nice to remove this state-twiddling. */

    state->tree = IDL_INTERFACE(iface).body;

    if (state->tree && !xpidl_process_node(state))
        FAIL;

    fputs("};\n", state->file);
    fputc('\n', state->file);

    /*
     * #define NS_DECL_NSIFOO - create method prototypes that can be used in
     * class definitions that support this interface.
     *
     * Walk the tree explicitly to prototype a reworking of xpidl to get rid of
     * the callback mechanism.
     */
    state->tree = orig;
    fputs("/* Use this macro when declaring classes that implement this "
          "interface. */\n", state->file);
    fputs("#define NS_DECL_", state->file);
    classNameUpper = xpidl_strdup(className);
    for (cp = classNameUpper; *cp != '\0'; cp++)
        *cp = toupper(*cp);
    fprintf(state->file, "%s \\\n", classNameUpper);
    if (IDL_INTERFACE(state->tree).body == NULL) {
        write_indent(state->file);
        fputs("/* no methods! */\n", state->file);
    }

    for (iter = IDL_INTERFACE(state->tree).body;
         iter != NULL;
         iter = IDL_LIST(iter).next)
    {
        IDL_tree data = IDL_LIST(iter).data;

        switch(IDL_NODE_TYPE(data)) {
          case IDLN_OP_DCL:
            write_indent(state->file);
            write_method_signature(data, state->file, AS_DECL, NULL);
            break;

          case IDLN_ATTR_DCL:
            write_indent(state->file);
            if (!write_attr_accessor(data, state->file, TRUE, AS_DECL, NULL))
                FAIL;
            if (!IDL_ATTR_DCL(data).f_readonly) {
                fputs("; \\\n", state->file); /* Terminate the previous one. */
                write_indent(state->file);
                if (!write_attr_accessor(data, state->file,
                                         FALSE, AS_DECL, NULL))
                    FAIL;
                /* '; \n' at end will clean up. */
            }
            break;

          case IDLN_CONST_DCL:
            /* ignore it here; it doesn't contribute to the macro. */
            continue;

          case IDLN_CODEFRAG:
            XPIDL_WARNING((iter, IDL_WARNING1,
                           "%%{ .. %%} code fragment within interface "
                           "ignored when generating NS_DECL_%s macro; "
                           "if the code fragment contains method "
                           "declarations, the macro probably isn't "
                           "complete.", classNameUpper));
            continue;

          default:
            IDL_tree_error(iter,
                           "unexpected node type %d! "
                           "Please file a bug against the xpidl component.",
                           IDL_NODE_TYPE(data));
            FAIL;
        }

        if (IDL_LIST(iter).next != NULL) {
            fprintf(state->file, "; \\\n");
        } else {
            fprintf(state->file, "; \n");
        }
    }
    fputc('\n', state->file);

    /* XXX abstract above and below into one function? */
    /*
     * #define NS_FORWARD_NSIFOO - create forwarding methods that can delegate
     * behavior from in implementation to another object.  As generated by
     * idlc.
     */
    fprintf(state->file,
            "/* Use this macro to declare functions that forward the "
            "behavior of this interface to another object. */\n"
            "#define NS_FORWARD_%s(_to) \\\n",
            classNameUpper);
    if (IDL_INTERFACE(state->tree).body == NULL) {
        write_indent(state->file);
        fputs("/* no methods! */\n", state->file);
    }

    for (iter = IDL_INTERFACE(state->tree).body;
         iter != NULL;
         iter = IDL_LIST(iter).next)
    {
        IDL_tree data = IDL_LIST(iter).data;

        switch(IDL_NODE_TYPE(data)) {
          case IDLN_OP_DCL:
            write_indent(state->file);
            write_method_signature(data, state->file, AS_DECL, NULL);
            fputs(" { return _to ", state->file);
            write_method_signature(data, state->file, AS_CALL, NULL);
            break;

          case IDLN_ATTR_DCL:
            write_indent(state->file);
            if (!write_attr_accessor(data, state->file, TRUE, AS_DECL, NULL))
                FAIL;
            fputs(" { return _to ", state->file);
            if (!write_attr_accessor(data, state->file, TRUE, AS_CALL, NULL))
                FAIL;
            if (!IDL_ATTR_DCL(data).f_readonly) {
                fputs("; } \\\n", state->file); /* Terminate the previous one. */
                write_indent(state->file);
                if (!write_attr_accessor(data, state->file,
                                         FALSE, AS_DECL, NULL))
                    FAIL;
                fputs(" { return _to ", state->file);
                if (!write_attr_accessor(data, state->file,
                                         FALSE, AS_CALL, NULL))
                    FAIL;
                /* '; } \n' at end will clean up. */
            }
            break;

          case IDLN_CONST_DCL:
          case IDLN_CODEFRAG:
              continue;

          default:
            FAIL;
        }

        if (IDL_LIST(iter).next != NULL) {
            fprintf(state->file, "; } \\\n");
        } else {
            fprintf(state->file, "; } \n");
        }
    }
    fputc('\n', state->file);


    /* XXX abstract above and below into one function? */
    /*
     * #define NS_FORWARD_SAFE_NSIFOO - create forwarding methods that can delegate
     * behavior from in implementation to another object.  As generated by
     * idlc.
     */
    fprintf(state->file,
            "/* Use this macro to declare functions that forward the "
            "behavior of this interface to another object in a safe way. */\n"
            "#define NS_FORWARD_SAFE_%s(_to) \\\n",
            classNameUpper);
    if (IDL_INTERFACE(state->tree).body == NULL) {
        write_indent(state->file);
        fputs("/* no methods! */\n", state->file);
    }

    for (iter = IDL_INTERFACE(state->tree).body;
         iter != NULL;
         iter = IDL_LIST(iter).next)
    {
        IDL_tree data = IDL_LIST(iter).data;

        switch(IDL_NODE_TYPE(data)) {
          case IDLN_OP_DCL:
            write_indent(state->file);
            write_method_signature(data, state->file, AS_DECL, NULL);
            fputs(" { return !_to ? NS_ERROR_NULL_POINTER : _to->", state->file);
            write_method_signature(data, state->file, AS_CALL, NULL);
            break;

          case IDLN_ATTR_DCL:
            write_indent(state->file);
            if (!write_attr_accessor(data, state->file, TRUE, AS_DECL, NULL))
                FAIL;
            fputs(" { return !_to ? NS_ERROR_NULL_POINTER : _to->", state->file);
            if (!write_attr_accessor(data, state->file, TRUE, AS_CALL, NULL))
                FAIL;
            if (!IDL_ATTR_DCL(data).f_readonly) {
                fputs("; } \\\n", state->file); /* Terminate the previous one. */
                write_indent(state->file);
                if (!write_attr_accessor(data, state->file,
                                         FALSE, AS_DECL, NULL))
                    FAIL;
                fputs(" { return !_to ? NS_ERROR_NULL_POINTER : _to->", state->file);
                if (!write_attr_accessor(data, state->file,
                                         FALSE, AS_CALL, NULL))
                    FAIL;
                /* '; } \n' at end will clean up. */
            }
            break;

          case IDLN_CONST_DCL:
          case IDLN_CODEFRAG:
              continue;

          default:
            FAIL;
        }

        if (IDL_LIST(iter).next != NULL) {
            fprintf(state->file, "; } \\\n");
        } else {
            fprintf(state->file, "; } \n");
        }
    }
    fputc('\n', state->file);

    /*
     * Build a sample implementation template.
     */
    if (strlen(className) >= 3 && className[2] == 'I') {
        classNameImpl = xpidl_strdup(className);
        if (!classNameImpl)
            FAIL;
        memmove(&classNameImpl[2], &classNameImpl[3], strlen(classNameImpl) - 2);
    } else {
        classNameImpl = xpidl_strdup("_MYCLASS_");
        if (!classNameImpl)
            FAIL;
    }

    fputs("#if 0\n"
          "/* Use the code below as a template for the "
          "implementation class for this interface. */\n"
          "\n"
          "/* Header file */"
          "\n",
          state->file);
    fprintf(state->file, "class %s : public %s\n", classNameImpl, className);
    fputs("{\n"
          "public:\n", state->file);
    write_indent(state->file);
    fputs("NS_DECL_ISUPPORTS\n", state->file);
    write_indent(state->file);
    fprintf(state->file, "NS_DECL_%s\n", classNameUpper);
    fputs("\n", state->file);
    write_indent(state->file);
    fprintf(state->file, "%s();\n", classNameImpl);
    fputs("\n"
          "private:\n", state->file);
    write_indent(state->file);
    fprintf(state->file, "~%s();\n", classNameImpl);
    fputs("\n"
          "protected:\n", state->file);
    write_indent(state->file);
    fputs("/* additional members */\n", state->file);
    fputs("};\n\n", state->file);

    fputs("/* Implementation file */\n", state->file);

    fprintf(state->file, 
            "NS_IMPL_ISUPPORTS1(%s, %s)\n", classNameImpl, className);
    fputs("\n", state->file);
    
    fprintf(state->file, "%s::%s()\n", classNameImpl, classNameImpl);
    fputs("{\n", state->file);
    write_indent(state->file);
    fputs("/* member initializers and constructor code */\n", state->file);
    fputs("}\n\n", state->file);
    
    fprintf(state->file, "%s::~%s()\n", classNameImpl, classNameImpl);
    fputs("{\n", state->file);
    write_indent(state->file);
    fputs("/* destructor code */\n", state->file);
    fputs("}\n\n", state->file);

    for (iter = IDL_INTERFACE(state->tree).body;
         iter != NULL;
         iter = IDL_LIST(iter).next)
    {
        IDL_tree data = IDL_LIST(iter).data;

        switch(IDL_NODE_TYPE(data)) {
          case IDLN_OP_DCL:
            /* It would be nice to remove this state-twiddling. */
            orig = state->tree; 
            state->tree = data;
            xpidl_write_comment(state, 0);
            state->tree = orig;

            write_method_signature(data, state->file, AS_IMPL, classNameImpl);
            fputs("\n{\n", state->file);
            write_indent(state->file);
            write_indent(state->file);
            fputs("return NS_ERROR_NOT_IMPLEMENTED;\n"
                  "}\n"
                  "\n", state->file);
            break;

          case IDLN_ATTR_DCL:
            /* It would be nice to remove this state-twiddling. */
            orig = state->tree; 
            state->tree = data;
            xpidl_write_comment(state, 0);
            state->tree = orig;
            
            if (!write_attr_accessor(data, state->file, TRUE, 
                                     AS_IMPL, classNameImpl))
                FAIL;
            fputs("\n{\n", state->file);
            write_indent(state->file);
            write_indent(state->file);
            fputs("return NS_ERROR_NOT_IMPLEMENTED;\n"
                  "}\n", state->file);

            if (!IDL_ATTR_DCL(data).f_readonly) {
                if (!write_attr_accessor(data, state->file, FALSE, 
                                         AS_IMPL, classNameImpl))
                    FAIL;
                fputs("\n{\n", state->file);
                write_indent(state->file);
                write_indent(state->file);
                fputs("return NS_ERROR_NOT_IMPLEMENTED;\n"
                      "}\n", state->file);
            }
            fputs("\n", state->file);
            break;

          case IDLN_CONST_DCL:
          case IDLN_CODEFRAG:
              continue;

          default:
            FAIL;
        }
    }

    fputs("/* End of implementation class template. */\n"
          "#endif\n"
          "\n", state->file);

#undef FAIL

out:
    if (classNameUpper)
        free(classNameUpper);
    if (classNameImpl)
        free(classNameImpl);
    return ok;
}
コード例 #26
0
gboolean
verify_attribute_declaration(IDL_tree attr_tree)
{
    IDL_tree iface;
    IDL_tree ident;
    IDL_tree attr_type;
    gboolean scriptable_interface;

    /* We don't support attributes named IID, conflicts with static GetIID 
     * member. The conflict is due to certain compilers (VC++) choosing a
     * different vtable order, placing GetIID at the beginning regardless
     * of it's placement
     */
    if (strcmp(
        IDL_IDENT(
            IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data).str, 
        "IID") == 0) {
        IDL_tree_error(attr_tree,
                       "Attributes named IID not supported, causes vtable "
                       "ordering problems");
        return FALSE;
    }
    /* 
     * Verify that we've been called on an interface, and decide if the
     * interface was marked [scriptable].
     */
    if (IDL_NODE_UP(attr_tree) && IDL_NODE_UP(IDL_NODE_UP(attr_tree)) &&
        IDL_NODE_TYPE(iface = IDL_NODE_UP(IDL_NODE_UP(attr_tree))) 
        == IDLN_INTERFACE)
    {
        scriptable_interface =
            (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable")
             != NULL);
    } else {
        IDL_tree_error(attr_tree,
                    "verify_attribute_declaration called on a non-interface?");
        return FALSE;
    }

    /*
     * Grab the first of the list of idents and hope that it'll
     * say scriptable or no.
     */
    ident = IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).data;

    /*
     * If the interface isn't scriptable, or the attribute is marked noscript,
     * there's no need to check.
     */
    if (!scriptable_interface ||
        IDL_tree_property_get(ident, "noscript") != NULL)
        return TRUE;

    /*
     * If it should be scriptable, check that the type is non-native. nsid,
     * domstring, utf8string, cstring, astring are exempted.
     */
    attr_type = IDL_ATTR_DCL(attr_tree).param_type_spec;

    if (attr_type != NULL)
    {
        if (UP_IS_NATIVE(attr_type) &&
            IDL_tree_property_get(attr_type, "nsid") == NULL &&
            IDL_tree_property_get(attr_type, "domstring") == NULL &&
            IDL_tree_property_get(attr_type, "utf8string") == NULL &&
            IDL_tree_property_get(attr_type, "cstring") == NULL &&
            IDL_tree_property_get(attr_type, "astring") == NULL)
        {
            IDL_tree_error(attr_tree,
                           "attributes in [scriptable] interfaces that are "
                           "non-scriptable because they refer to native "
                           "types must be marked [noscript]\n");
            return FALSE;
        }
        /*
         * We currently don't support properties of type nsid that aren't 
         * pointers or references, unless they are marked [notxpcom} and 
         * must be read-only 
         */
         
        if ((IDL_tree_property_get(ident, "notxpcom") == NULL || !(IDL_ATTR_DCL(attr_tree).f_readonly)) &&
            IDL_tree_property_get(attr_type,"nsid") != NULL &&
            IDL_tree_property_get(attr_type,"ptr") == NULL &&
            IDL_tree_property_get(attr_type,"ref") == NULL)
        {
            IDL_tree_error(attr_tree,
                           "Feature not currently supported: "
                           "attributes with a type of nsid must be marked "
                           "either [ptr] or [ref], or "
                           "else must be marked [notxpcom] "
                           "and must be read-only\n");
            return FALSE;
        }

        /* 
         * Run additional error checks on the attribute type if targetting an 
         * older version of XPConnect.
         */

        if (!verify_type_fits_version(attr_type, attr_tree))
            return FALSE;
    }

    if (IDL_LIST(IDL_ATTR_DCL(attr_tree).simple_declarations).next != NULL)
    {
        IDL_tree_error(attr_tree,
            "multiple attributes in a single declaration is not supported\n");
        return FALSE;
    }
    return TRUE;
}
コード例 #27
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)++;
}
コード例 #28
0
static gboolean
typelib_interface(TreeState *state)
{
    IDL_tree iface = state->tree, iter;
    char *name = IDL_IDENT(IDL_INTERFACE(iface).ident).str;
    XPTInterfaceDirectoryEntry *ide;
    XPTInterfaceDescriptor *id;
    uint16 parent_id = 0;
    PRUint8 interface_flags = 0;

    if (!verify_interface_declaration(iface))
        return FALSE;

    if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable"))
        interface_flags |= XPT_ID_SCRIPTABLE;

    if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "function"))
        interface_flags |= XPT_ID_FUNCTION;

    ide = FindInterfaceByName(HEADER(state)->interface_directory,
                              HEADER(state)->num_interfaces, name);
    if (!ide) {
        IDL_tree_error(iface, "ERROR: didn't find interface %s in "
                       "IDE block. Giving up.\n", name);
        return FALSE;
    }

    if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
        char *parent;
        if (IDL_LIST(iter).next) {
            IDL_tree_error(iface,
                           "ERROR: more than one parent interface for %s\n",
                           name);
            return FALSE;
        }
        parent = IDL_IDENT(IDL_LIST(iter).data).str;
        parent_id = (uint16)(uint32)g_hash_table_lookup(IFACE_MAP(state),
                                                        parent);
        if (!parent_id) {
            IDL_tree_error(iface,
                           "ERROR: no index found for %s. Giving up.\n",
                           parent);
            return FALSE;
        }
    }

    id = XPT_NewInterfaceDescriptor(ARENA(state), parent_id, 0, 0, 
                                    interface_flags);
    if (!id)
        return FALSE;

    CURRENT(state) = ide->interface_descriptor = id;
#ifdef DEBUG_shaver_ifaces
    fprintf(stderr, "DBG: starting interface %s @ %p\n", name, id);
#endif

    NEXT_METH(state) = 0;
    NEXT_CONST(state) = 0;
    NEXT_TYPE(state) = 0;

    state->tree = IDL_INTERFACE(iface).body;
    if (state->tree && !xpidl_process_node(state))
        return FALSE;
#ifdef DEBUG_shaver_ifaces
    fprintf(stderr, "DBG: ending interface %s\n", name);
#endif
    return TRUE;
}
コード例 #29
0
static gboolean
fill_td_from_type(TreeState *state, XPTTypeDescriptor *td, IDL_tree type)
{
    IDL_tree up;
    int16 size_is_argnum;
    int16 length_is_argnum;
    gboolean has_size_is;
    gboolean has_length_is;
    gboolean is_array = FALSE;

    if (type) {

        /* deal with array */

        if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) {
            IDL_tree sd = IDL_PARAM_DCL(state->tree).simple_declarator;
            if (IDL_tree_property_get(sd, "array")) {

                is_array = TRUE;

                /* size_is is required! */
                if (!get_size_and_length(state, type, 
                                         &size_is_argnum, &length_is_argnum,
                                         &has_size_is, &has_length_is)) {
                    /* error was reported by helper function */
                    return FALSE;
                }

                if (!has_size_is) {
                   IDL_tree_error(state->tree, "[array] requires [size_is()]\n");
                    return FALSE;
                }

                td->prefix.flags = TD_ARRAY | XPT_TDP_POINTER;
                td->argnum = size_is_argnum;

                if (has_length_is)
                    td->argnum2 = length_is_argnum;
                else
                    td->argnum2 = size_is_argnum;

                /* 
                * XXX - NOTE - this will be broken for multidimensional 
                * arrays because of the realloc XPT_InterfaceDescriptorAddTypes
                * uses. The underlying 'td' can change as we recurse in to get
                * additional dimensions. Luckily, we don't yet support more
                * than on dimension in the arrays
                */
                /* setup the additional_type */                
                if (!XPT_InterfaceDescriptorAddTypes(ARENA(state), 
                                                     CURRENT(state), 1)) {
                    g_error("out of memory\n");
                    return FALSE;
                }
                td->type.additional_type = NEXT_TYPE(state);
                td = &CURRENT(state)->additional_types[NEXT_TYPE(state)];
                NEXT_TYPE(state)++ ;
            }
        }

handle_typedef:
        switch (IDL_NODE_TYPE(type)) {
          case IDLN_TYPE_INTEGER: {
              gboolean sign = IDL_TYPE_INTEGER(type).f_signed;
              switch(IDL_TYPE_INTEGER(type).f_type) {
                case IDL_INTEGER_TYPE_SHORT:
                  td->prefix.flags = sign ? TD_INT16 : TD_UINT16;
                  break;
                case IDL_INTEGER_TYPE_LONG:
                  td->prefix.flags = sign ? TD_INT32 : TD_UINT32;
                  break;
                case IDL_INTEGER_TYPE_LONGLONG:
                  td->prefix.flags = sign ? TD_INT64 : TD_UINT64;
                  break;
              }
              break;
          }
          case IDLN_TYPE_CHAR:
            td->prefix.flags = TD_CHAR;
            break;
          case IDLN_TYPE_WIDE_CHAR:
            td->prefix.flags = TD_WCHAR;
            break;
          case IDLN_TYPE_STRING:
            if (is_array) {
                td->prefix.flags = TD_PSTRING | XPT_TDP_POINTER;
            } else {
                if (!get_size_and_length(state, type, 
                                         &size_is_argnum, &length_is_argnum,
                                         &has_size_is, &has_length_is)) {
                    /* error was reported by helper function */
                    return FALSE;
                }
                if (has_size_is) {
                    td->prefix.flags = TD_PSTRING_SIZE_IS | XPT_TDP_POINTER;
                    td->argnum = size_is_argnum;
                    if (has_length_is)
                        td->argnum2 = length_is_argnum;
                    else
                        td->argnum2 = size_is_argnum;
                } else {
                    td->prefix.flags = TD_PSTRING | XPT_TDP_POINTER;
                }
            }
            break;
          case IDLN_TYPE_WIDE_STRING:
            if (is_array) {
                td->prefix.flags = TD_PWSTRING | XPT_TDP_POINTER;
            } else {
                if (!get_size_and_length(state, type, 
                                         &size_is_argnum, &length_is_argnum,
                                         &has_size_is, &has_length_is)) {
                    /* error was reported by helper function */
                    return FALSE;
                }
                if (has_size_is) {
                    td->prefix.flags = TD_PWSTRING_SIZE_IS | XPT_TDP_POINTER;
                    td->argnum = size_is_argnum;
                    if (has_length_is)
                        td->argnum2 = length_is_argnum;
                    else
                        td->argnum2 = size_is_argnum;
                } else {
                    td->prefix.flags = TD_PWSTRING | XPT_TDP_POINTER;
                }
            }
            break;
          case IDLN_TYPE_BOOLEAN:
            td->prefix.flags = TD_BOOL;
            break;
          case IDLN_TYPE_OCTET:
            td->prefix.flags = TD_UINT8;
            break;
          case IDLN_TYPE_FLOAT:
            switch (IDL_TYPE_FLOAT (type).f_type) {
              case IDL_FLOAT_TYPE_FLOAT:
                td->prefix.flags = TD_FLOAT;
                break;
              case IDL_FLOAT_TYPE_DOUBLE:
                td->prefix.flags = TD_DOUBLE;
                break;
              /* XXX 'long double' just ignored, or what? */
              default: break;
            }
            break;
          case IDLN_IDENT:
            if (!(up = IDL_NODE_UP(type))) {
                IDL_tree_error(state->tree,
                               "ERROR: orphan ident %s in param list\n",
                               IDL_IDENT(type).str);
                return FALSE;
            }
            switch (IDL_NODE_TYPE(up)) {
                /* This whole section is abominably ugly */
              case IDLN_FORWARD_DCL:
              case IDLN_INTERFACE: {
                XPTInterfaceDirectoryEntry *ide, *ides;
                uint16 num_ifaces;
                char *className;
                const char *iid_is;
handle_iid_is:
                ides = HEADER(state)->interface_directory;
                num_ifaces = HEADER(state)->num_interfaces;
                /* might get here via the goto, so re-check type */
                if (IDL_NODE_TYPE(up) == IDLN_INTERFACE)
                    className = IDL_IDENT(IDL_INTERFACE(up).ident).str;
                else if (IDL_NODE_TYPE(up) == IDLN_FORWARD_DCL)
                    className = IDL_IDENT(IDL_FORWARD_DCL(up).ident).str;
                else
                    className = IDL_IDENT(IDL_NATIVE(up).ident).str;
                iid_is = NULL;

                if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) {
                    iid_is =
                        IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator,
                                              "iid_is");
                }
                if (iid_is) {
                    int16 argnum;
                    if (!find_arg_with_name(state, iid_is, &argnum)) {
                        IDL_tree_error(state->tree,
                                       "can't find matching argument for "
                                       "[iid_is(%s)]\n", iid_is);
                        return FALSE;
                    }
                    td->prefix.flags = TD_INTERFACE_IS_TYPE | XPT_TDP_POINTER;
                    td->argnum = argnum;
                } else {
                    td->prefix.flags = TD_INTERFACE_TYPE | XPT_TDP_POINTER;
                    ide = FindInterfaceByName(ides, num_ifaces, className);
                    if (!ide || ide < ides || ide > ides + num_ifaces) {
                        IDL_tree_error(state->tree,
                                       "unknown iface %s in param\n",
                                       className);
                        return FALSE;
                    }
                    td->type.iface = ide - ides + 1;
#ifdef DEBUG_shaver_index
                    fprintf(stderr, "DBG: index %d for %s\n",
                            td->type.iface, className);
#endif
                }
                break;
              }
              case IDLN_NATIVE: {
                  char *ident;

                  /* jband - adding goto for iid_is when type is native */
                  if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL &&
                      IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator,
                                              "iid_is"))
                      goto handle_iid_is;

                  ident = IDL_IDENT(type).str;
                  if (IDL_tree_property_get(type, "nsid")) {
                      td->prefix.flags = TD_PNSIID;
                      if (IDL_tree_property_get(type, "ref"))
                          td->prefix.flags |= XPT_TDP_POINTER | XPT_TDP_REFERENCE;
                      else if (IDL_tree_property_get(type,"ptr"))
                          td->prefix.flags |= XPT_TDP_POINTER;
                  } else if (IDL_tree_property_get(type, "domstring")) {
                      td->prefix.flags = TD_DOMSTRING | XPT_TDP_POINTER;
                      if (IDL_tree_property_get(type, "ref"))
                          td->prefix.flags |= XPT_TDP_REFERENCE;
                  } else if (IDL_tree_property_get(type, "astring")) {
                      td->prefix.flags = TD_ASTRING | XPT_TDP_POINTER;
                      if (IDL_tree_property_get(type, "ref"))
                          td->prefix.flags |= XPT_TDP_REFERENCE;
                  } else if (IDL_tree_property_get(type, "utf8string")) {
                      td->prefix.flags = TD_UTF8STRING | XPT_TDP_POINTER;
                      if (IDL_tree_property_get(type, "ref"))
                          td->prefix.flags |= XPT_TDP_REFERENCE;
                  } else if (IDL_tree_property_get(type, "cstring")) {
                      td->prefix.flags = TD_CSTRING | XPT_TDP_POINTER;
                      if (IDL_tree_property_get(type, "ref"))
                          td->prefix.flags |= XPT_TDP_REFERENCE;
                  } else if (IDL_tree_property_get(type, "jsval")) {
                      td->prefix.flags = TD_JSVAL;
                      if (IDL_tree_property_get(type, "ptr"))
                          td->prefix.flags |= XPT_TDP_POINTER;
                  } else {
                      td->prefix.flags = TD_VOID | XPT_TDP_POINTER;
                  }
                  break;
                }
              default:
                if (IDL_NODE_TYPE(IDL_NODE_UP(up)) == IDLN_TYPE_DCL) {
                    /* restart with the underlying type */
                    IDL_tree new_type;
                    new_type = IDL_TYPE_DCL(IDL_NODE_UP(up)).type_spec;
#ifdef DEBUG_shaver_misc
                    fprintf(stderr, "following %s typedef to %s\n",
                            IDL_IDENT(type).str, IDL_NODE_TYPE_NAME(new_type));
#endif
                    /* 
                    *  Do a nice messy goto rather than recursion so that
                    *  we can avoid screwing up the *array* information.
                    */
/*                    return fill_td_from_type(state, td, new_type); */
                    if (new_type) {
                        type = new_type;
                        goto handle_typedef;
                    } else {
                        /* do what we would do in recursion if !type */
                        td->prefix.flags = TD_VOID;
                        return TRUE;
                    }
                }
                IDL_tree_error(state->tree,
                               "can't handle %s ident in param list\n",
#ifdef DEBUG_shaver
                               /* XXX is this safe to use on Win now? */
                               IDL_NODE_TYPE_NAME(IDL_NODE_UP(type))
#else
                               "that type of"
#endif
                               );
#ifdef DEBUG_shaver
                XPT_ASSERT(0);
#endif
                return FALSE;
            }
            break;
          default:
            IDL_tree_error(state->tree, "can't handle %s in param list\n",
#ifdef DEBUG_shaver
                           /* XXX is this safe to use on Win now? */
                           IDL_NODE_TYPE_NAME(IDL_NODE_UP(type))
#else
                        "that type"
#endif
            );
            return FALSE;
        }
    } else {
        td->prefix.flags = TD_VOID;
    }

    return TRUE;
}
コード例 #30
0
static gboolean 
xpcom_to_java_type(TreeState *state, IDL_tree type) 
{
    IDL_tree real_type;
    IDL_tree up;

    if (!type) {
        fputs("Object", state->file);
        return TRUE;
    }

    /* Could be a typedef; try to map it to the real type */
    real_type = find_underlying_type(type);
    type = real_type ? real_type : type;

    switch(IDL_NODE_TYPE(type)) {

    case IDLN_TYPE_INTEGER: {

        switch(IDL_TYPE_INTEGER(type).f_type) {

        case IDL_INTEGER_TYPE_SHORT:
            fputs("short", state->file);
            break;

        case IDL_INTEGER_TYPE_LONG:
            fputs("int", state->file);
            break;

        case IDL_INTEGER_TYPE_LONGLONG:
            fputs("long", state->file);
            break;
	    
        default:
            g_error("   Unknown integer type: %d\n",
                    IDL_TYPE_INTEGER(type).f_type);
            return FALSE;

        }

        break;
    }

    case IDLN_TYPE_CHAR:
    case IDLN_TYPE_WIDE_CHAR:
        fputs("char", state->file);
        break;

    case IDLN_TYPE_WIDE_STRING:
    case IDLN_TYPE_STRING:
        fputs("String", state->file);
        break;

    case IDLN_TYPE_BOOLEAN:
        fputs("boolean", state->file);
        break;

    case IDLN_TYPE_OCTET:
        fputs("byte", state->file);
        break;

    case IDLN_TYPE_FLOAT:
        switch(IDL_TYPE_FLOAT(type).f_type) {

        case IDL_FLOAT_TYPE_FLOAT:
            fputs("float", state->file);
            break;

        case IDL_FLOAT_TYPE_DOUBLE:
            fputs("double", state->file);
            break;
	    
        default:
            g_error("    Unknown floating point typ: %d\n",
                    IDL_NODE_TYPE(type));
            break;
        }
        break;


    case IDLN_IDENT:
      if (!(up = IDL_NODE_UP(type))) {
          IDL_tree_error(state->tree,
                         "ERROR: orphan ident %s in param list\n",
                         IDL_IDENT(state->tree).str);
          return FALSE;
      }
      switch (IDL_NODE_TYPE(up)) {
        case IDLN_FORWARD_DCL:
        case IDLN_INTERFACE: {
          char *className;
          const char *iid_is;
handle_iid_is:
          /* might get here via the goto, so re-check type */
          if (IDL_NODE_TYPE(up) == IDLN_INTERFACE)
              className = IDL_IDENT(IDL_INTERFACE(up).ident).str;
          else if (IDL_NODE_TYPE(up) == IDLN_FORWARD_DCL)
              className = IDL_IDENT(IDL_FORWARD_DCL(up).ident).str;
          else
              className = IDL_IDENT(IDL_NATIVE(up).ident).str;
          iid_is = NULL;

          if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL) {
              iid_is =
                  IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator,
                                        "iid_is");
          }
          if (iid_is) {
              fputs("nsISupports", state->file);
          } else {
              /* XXX How do we want to handle this? If it's an IDLN_INTERFACE,
               *  then we can just output the name of the class, since the IDL
               *  files exist for those classes.  However, if it's an
               *  IDLN_FORWARD_DCL, some of those interfaces are not defined in
               *  IDL files, so we get an error when trying to compile the java
               *  files.  So, for now, we just output them as the base iface
               *  (nsISupports). 
               */
              if (IDL_NODE_TYPE(up) == IDLN_FORWARD_DCL)
                  fputs("nsISupports", state->file);
              else
                  fprintf(state->file, "%s", className);
          }
          break;
        }
        case IDLN_NATIVE: {
            char *ident;

            /* jband - adding goto for iid_is when type is native */
            if (IDL_NODE_TYPE(state->tree) == IDLN_PARAM_DCL &&
                IDL_tree_property_get(IDL_PARAM_DCL(state->tree).simple_declarator,
                                        "iid_is"))
            {
                goto handle_iid_is;
/*                fputs("nsISupports", state->file); */
                break;
            }

            ident = IDL_IDENT(type).str;
            if (IDL_tree_property_get(type, "nsid")) {
                fputs("String", state->file);
            } else if (IDL_tree_property_get(type, "domstring")) {
                fputs("String", state->file);
            } else if (IDL_tree_property_get(type, "astring")) {
                fputs("String", state->file);
            } else if (IDL_tree_property_get(type, "utf8string")) {
                fputs("String", state->file);
            } else if (IDL_tree_property_get(type, "cstring")) {
                fputs("String", state->file);
            } else {
                const char* user_type = IDL_NATIVE(IDL_NODE_UP(type)).user_type;
                IDL_tree real_type = 
                    g_hash_table_lookup(TYPEDEFS(state), user_type);

                if (real_type) {
                    return xpcom_to_java_type(state, real_type);
                } else {
                    if (strcmp(user_type, "PRInt8") == 0 ||
                        strcmp(user_type, "PRUint8") == 0) {
                        fputs("byte", state->file);
                    } else if (strcmp(user_type, "PRInt16") == 0 ||
                               strcmp(user_type, "PRUint16") == 0) {
                        fputs("short", state->file);
                    } else if (strcmp(user_type, "PRInt32") == 0 ||
                               strcmp(user_type, "PRUint32") == 0 ||
                               strcmp(user_type, "int") == 0) {
                        fputs("int", state->file);
                    } else if (strcmp(user_type, "PRInt64") == 0 ||
                               strcmp(user_type, "PRUint64") == 0) {
                        fputs("long", state->file);
                    } else if (strcmp(user_type, "PRBool") == 0) {
                        fputs("boolean", state->file);
                    } else if (strncmp(user_type, "char", 4) == 0 ||
                               strncmp(user_type, "const char", 10) == 0 ||
                               strncmp(user_type, "unsigned char", 13) == 0) {
                        if (IDL_tree_property_get(type, "ptr")) {
                            fputs("byte[]", state->file);
                        } else {
                            fputs("char", state->file);
                        }
                    } else if (strcmp(user_type, "nsIID") == 0) {
                        fputs("String", state->file);
                    } else if (strcmp(user_type, "nsString") == 0 ||
                               strcmp(user_type, "nsAString") == 0 ||
                               strcmp(user_type, "nsACString") == 0) {
                        fputs("String", state->file);
                    } else {
                        fputs("int", state->file);
                    }
                }
            }
            break;
          }
        default:
          if (IDL_NODE_TYPE(IDL_NODE_UP(up)) == IDLN_TYPE_DCL) {
              /* restart with the underlying type */
              IDL_tree new_type;
              new_type = IDL_TYPE_DCL(IDL_NODE_UP(up)).type_spec;
              if (new_type) {
                  gboolean rc = xpcom_to_java_type(state, new_type);
                  return rc;
              } else {
                  /* do what we would do in recursion if !type */
                  fputs("Object", state->file);
                  return TRUE;
              }
          }
          IDL_tree_error(state->tree,
                         "can't handle %s ident in param list\n",
                         "that type of"
                         );
          return FALSE;
      }
      break;

    default:
      IDL_tree_error(state->tree, "can't handle %s in param list\n",
#ifdef DEBUG_shaver
                     /* XXX is this safe to use on Win now? */
                     IDL_NODE_TYPE_NAME(IDL_NODE_UP(type))
#else
                  "that type"
#endif
      );
      return FALSE;
    }

    return TRUE;

}