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

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

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

    return TRUE;
}
CORBA_TypeCode
MateCORBA_imodule_create_alias_typecode (GHashTable    *typecodes,
				     IDL_tree       tree,
				     CORBA_TypeCode original_type)
{
	CORBA_Environment env;
	CORBA_TypeCode    retval;

	CORBA_exception_init (&env);

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

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

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

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

	CORBA_exception_free (&env);

	return retval;
}
static gboolean
do_const_dcl(TreeState *state)
{
    struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree);
    const char *name = IDL_IDENT(dcl->ident).str;
    gboolean is_signed;
    GSList *doc_comments = IDL_IDENT(dcl->ident).comments;
    IDL_tree real_type;
    const char *const_format;

    if (!verify_const_declaration(state->tree))
        return FALSE;

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

    /* Could be a typedef; try to map it to the real type. */
    real_type = find_underlying_type(dcl->const_type);
    real_type = real_type ? real_type : dcl->const_type;
    is_signed = IDL_TYPE_INTEGER(real_type).f_signed;

    const_format = is_signed ? "%" IDL_LL "d" : "%" IDL_LL "uU";
    write_indent(state->file);
    fprintf(state->file, "enum { %s = ", name);
    fprintf(state->file, const_format, IDL_INTEGER(dcl->const_exp).value);
    fprintf(state->file, " };\n\n");

    return TRUE;
}
예제 #4
0
/*
 * make exception typecode
 */
static CORBA_TypeCode orbit_idl_tree_type_to_typecode_exception(IDL_tree type)
{
	CORBA_TypeCode type_code = NULL;
	CORBA_StructMemberSeq * p_members = NULL;

#if 0
	if (IDL_EXCEPT_DCL(type).members == NULL)
	{
		printf("no members\n");
		goto error;
	}
#endif

	p_members = orbit_create_member_sequence(IDL_EXCEPT_DCL(type).members);
	if (p_members == NULL)
		goto error;
	
	type_code = CORBA_ORB_create_exception_tc(
			orbit_get_orb(),
			IDL_IDENT(IDL_EXCEPT_DCL(type).ident).repo_id,
			IDL_IDENT(IDL_EXCEPT_DCL(type).ident).str,
			p_members,
			orbit_get_environment());

	goto exit;

error:
	satellite_release_typecode(type_code);

exit:
	CORBA_free(p_members);
	return type_code;

}
예제 #5
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;
    }
  }
}
예제 #6
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;
    }
  }
}
예제 #7
0
/*
 * If p is an ident for an interface, and we don't have an entry in the
 * interface map yet, add one.
 */
static gboolean
add_interface_maybe(IDL_tree_func_data *tfd, gpointer user_data)
{
    TreeState *state = user_data;
    IDL_tree up;
    if (IDL_NODE_TYPE(tfd->tree) == IDLN_IDENT) {
        IDL_tree_type node_type = IDL_NODE_TYPE((up = IDL_NODE_UP(tfd->tree)));
        if (node_type == IDLN_INTERFACE || node_type == IDLN_FORWARD_DCL) {

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

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

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

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

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

	members = CORBA_StructMemberSeq__alloc ();

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

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

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

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

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

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

		CORBA_Object_release ((CORBA_Object) subtc, ev);
	}

	g_assert (i == num_members);

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

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

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

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

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

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

            fputs("typedef ", state->file);
            if (!write_type(type, FALSE, state->file))
                return FALSE;
            fputs(" ", state->file);
            fputs(IDL_IDENT(IDL_LIST(dcls).data).str, state->file);
        }
        fputs(";\n\n", state->file);
    }
    return TRUE;
}
예제 #10
0
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);
}
예제 #11
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);

}
예제 #12
0
static gboolean
typelib_const_dcl(TreeState *state)
{
    struct _IDL_CONST_DCL *dcl = &IDL_CONST_DCL(state->tree);
    const char *name = IDL_IDENT(dcl->ident).str;
    gboolean is_long;
    gboolean sign;
    IDL_tree real_type;
    XPTInterfaceDescriptor *id;
    XPTConstDescriptor *cd;
    IDL_longlong_t value;

    if (!verify_const_declaration(state->tree))
        return FALSE;

    /* Could be a typedef; try to map it to the real type. */
    real_type = find_underlying_type(dcl->const_type);
    real_type = real_type ? real_type : dcl->const_type;
    is_long = (IDL_TYPE_INTEGER(real_type).f_type == IDL_INTEGER_TYPE_LONG);

    id = CURRENT(state);
    if (!XPT_InterfaceDescriptorAddConsts(ARENA(state), id, 1))
        return FALSE;
    cd = &id->const_descriptors[NEXT_CONST(state)];
    
    cd->name = IDL_IDENT(dcl->ident).str;
#ifdef DEBUG_shaver_const
    fprintf(stderr, "DBG: adding const %s\n", cd->name);
#endif
    if (!fill_td_from_type(state, &cd->type, dcl->const_type))
        return FALSE;
    
    value = IDL_INTEGER(dcl->const_exp).value;
    sign = IDL_TYPE_INTEGER(dcl->const_type).f_signed;
    if (is_long) {
        if (sign)
            cd->value.i32 = value;
        else
            cd->value.ui32 = value;
    } else {
        if (sign)
            cd->value.i16 = value;
        else
            cd->value.ui16 = value;
    }
    NEXT_CONST(state)++;
    return TRUE;
}
예제 #13
0
static gboolean coder_get_type_info(IDL_tree tree, int attr, TypeInfo* type)
{
	const char* name = "";
	type->attr = attr;
	if(attr == IDL_PARAM_INOUT)
	{
		assert(!"Not supported.");
	}

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

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

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

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

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

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

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

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

		g_assert (label->_type->kind == CORBA_tk_enum);
		for (val = 0; val < label->_type->sub_parts; val++)
			if (!strcmp (IDL_IDENT (node).str, label->_type->subnames [val]))
				break;
		g_assert (val < label->_type->sub_parts);
		*(CORBA_long *) label->_value = val;
		break;
	}
	default:
		g_assert_not_reached ();
		break;
	}
}
예제 #15
0
static gboolean
find_arg_with_name(TreeState *state, const char *name, int16 *argnum)
{
    int16 count;
    IDL_tree params;

    XPT_ASSERT(state);
    XPT_ASSERT(name);
    XPT_ASSERT(argnum);

    params = IDL_OP_DCL(IDL_NODE_UP(IDL_NODE_UP(state->tree))).parameter_dcls;
    for (count = 0;
         params != NULL && IDL_LIST(params).data != NULL;
         params = IDL_LIST(params).next, count++)
    {
        const char *cur_name = IDL_IDENT(
                IDL_PARAM_DCL(IDL_LIST(params).data).simple_declarator).str;
        if (!strcmp(cur_name, name)) {
            /* XXX ought to verify that this is the right type here */
            /* XXX for iid_is this must be an iid */
            /* XXX for size_is and length_is this must be a uint32 */
            *argnum = count;
            return TRUE;
        }
    }
    return FALSE;
}
/*
 * A method is an `operation', therefore a method decl is an `op dcl'.
 * I blame Elliot.
 */
static gboolean
op_dcl(TreeState *state)
{
    GSList *doc_comments = IDL_IDENT(IDL_OP_DCL(state->tree).ident).comments;

    /*
     * Verify that e.g. non-scriptable methods in [scriptable] interfaces
     * are declared so.  Do this in a separate verification pass?
     */
    if (!verify_method_declaration(state->tree))
        return FALSE;

    if (doc_comments != NULL) {
        write_indent(state->file);
        printlist(state->file, doc_comments);
    }
    xpidl_write_comment(state, 2);

    write_indent(state->file);
    if (!write_method_signature(state->tree, state->file, AS_DECL, NULL))
        return FALSE;
    fputs(" = 0;\n\n", state->file);

    return TRUE;
}
예제 #17
0
void
orbit_cbe_flatten_args (IDL_tree tree, FILE *of, const char *name)
{
	int i = 0;
	IDL_tree l;

	for (l = IDL_OP_DCL(tree).parameter_dcls; l;
	     l = IDL_LIST(l).next)
		i++;

	fprintf (of, "gpointer %s[%d];\n", name, i);
	
	i = 0;
	for (l = IDL_OP_DCL(tree).parameter_dcls; l;
	     l = IDL_LIST(l).next) {
		IDL_tree decl = IDL_LIST (l).data;
		IDL_tree tspec = orbit_cbe_get_typespec (decl);
		IDL_ParamRole r = 0;

		switch(IDL_PARAM_DCL(decl).attr) {
		case IDL_PARAM_IN:    r = DATA_IN;    break;
		case IDL_PARAM_INOUT: r = DATA_INOUT; break;
		case IDL_PARAM_OUT:   r = DATA_OUT;   break;
		default:
			g_error("Unknown IDL_PARAM type");
		}
		
		fprintf (of, "%s[%d] = %s%s;\n",
			 name, i,
			 orbit_cbe_flatten_ref (r, tspec),
			 IDL_IDENT (IDL_PARAM_DCL (decl).simple_declarator).str);
		i++;
	}
}
static CORBA_EnumMemberSeq *
MateCORBA_imodule_get_enum_members (IDL_tree           tree,
				CORBA_Environment *ev)
{
	CORBA_EnumMemberSeq *members;
	IDL_tree             l;
	int                  num_members = 0;
	int                  i;

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

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

	members = CORBA_EnumMemberSeq__alloc ();

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

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

	g_assert (i == num_members);

	return members;
}
예제 #19
0
static gboolean
typelib_enum(TreeState *state)
{
    XPIDL_WARNING((state->tree, IDL_WARNING1,
                   "enums not supported, enum \'%s\' ignored",
                   IDL_IDENT(IDL_TYPE_ENUM(state->tree).ident).str));
    return TRUE;
}
예제 #20
0
static void
orbit_output_tcstruct_repo_id (FILE *fh, IDL_tree node, int array_gen_ctr)
{
	switch (IDL_NODE_TYPE (node)) {
	case IDLN_TYPE_STRUCT:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_TYPE_STRUCT (node).ident).repo_id);
		break;
	case IDLN_TYPE_UNION:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_TYPE_UNION (node).ident).repo_id);
		break;
	case IDLN_TYPE_ENUM:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_TYPE_ENUM (node).ident).repo_id);
		break;
	case IDLN_INTERFACE:
	case IDLN_FORWARD_DCL:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_INTERFACE (node).ident).repo_id);
		break;
	case IDLN_EXCEPT_DCL:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_EXCEPT_DCL (node).ident).repo_id);
		break;
	case IDLN_IDENT:
		fprintf (fh, "(char *)\"%s\"", IDL_IDENT (node).repo_id);
		break;
	case IDLN_TYPE_ARRAY:
		if (!array_gen_ctr)
			fprintf (fh, "(char *)\"%s\"", IDL_IDENT (IDL_TYPE_ARRAY (node).ident).repo_id);
		else
			fprintf (fh, "NULL");
		break;
	default:
		fprintf (fh, "NULL");
		break;
	}
}
예제 #21
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;
}
예제 #22
0
/* If notype is true, just write the param name. */
static gboolean
write_param(IDL_tree param_tree, FILE *outfile)
{
    IDL_tree param_type_spec = IDL_PARAM_DCL(param_tree).param_type_spec;
    gboolean is_in = IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_IN;
    /* in string, wstring, nsid, domstring, utf8string, cstring and 
     * astring any explicitly marked [const] are const 
     */

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

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

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

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

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

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

    return TRUE;
}
예제 #23
0
static CORBA_TypeCode orbit_idl_tree_type_to_typecode_enum(IDL_tree type)
{
	CORBA_TypeCode type_code;
	CORBA_EnumMemberSeq * p_members = NULL;

	p_members = CORBA_EnumMemberSeq__alloc();
	p_members->_maximum = p_members->_length = 1;
	p_members->_buffer = CORBA_sequence_CORBA_Identifier_allocbuf(p_members->_length);

	p_members->_buffer[0] = "dummy";

	/* 
	 * TODO: initialize p_members with members...
	 *       look at orbit_idl_tree_type_to_typecode_struct
	 */

	type_code = CORBA_ORB_create_enum_tc(
			orbit_get_orb(),
			IDL_IDENT(IDL_TYPE_ENUM(type).ident).repo_id,
			IDL_IDENT(IDL_TYPE_ENUM(type).ident).str,
			p_members,
			orbit_get_environment());

	if (orbit_error_test("CORBA_ORB_create_enum_tc"))
	{
		goto error;
	}

	if (type_code == NULL)
	{
/*		printf("unable to create enum typecode for type %s\n", 
				IDL_IDENT(IDL_TYPE_ENUM(type).ident).str);*/
	}

	goto exit;

error:
	type_code = NULL;

exit:
	CORBA_free(p_members);
	return type_code;
}
static CORBA_UnionMemberSeq *
MateCORBA_imodule_get_union_members (GHashTable        *typecodes,
				 IDL_tree           tree,
				 CORBA_TypeCode     switchtc,
				 CORBA_Environment *ev)
{
	CORBA_UnionMemberSeq *members;
	IDL_tree              l;
	int                   num_members = 0;
	int                   i;

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

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

	members = CORBA_UnionMemberSeq__alloc ();

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

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

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

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

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

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

			umember->label._release = CORBA_TRUE;

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

		CORBA_Object_release ((CORBA_Object) subtc, ev);
	}

	g_assert (i == num_members);

	return members;
}
예제 #25
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++;
}
예제 #26
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)++;
}
/*
 * A forward declaration, usually an interface.
 */
static gboolean
forward_dcl(TreeState *state)
{
    IDL_tree iface = state->tree;
    const char *className = IDL_IDENT(IDL_FORWARD_DCL(iface).ident).str;

    if (!className)
        return FALSE;

    fprintf(state->file, "class %s; /* forward declaration */\n\n", className);
    return TRUE;
}
예제 #28
0
/*
 * Verify that a native declaration has an associated C++ expression, i.e. that
 * it's of the form native <idl-name>(<c++-name>)
 */
gboolean
check_native(TreeState *state)
{
    char *native_name;
    /* require that native declarations give a native type */
    if (IDL_NATIVE(state->tree).user_type) 
        return TRUE;
    native_name = IDL_IDENT(IDL_NATIVE(state->tree).ident).str;
    IDL_tree_error(state->tree,
                   "``native %s;'' needs C++ type: ``native %s(<C++ type>);''",
                   native_name, native_name);
    return FALSE;
}
예제 #29
0
void
orte_idl_check_oneway_op (IDL_tree op)
{
	g_assert (IDL_NODE_TYPE(op) == IDLN_OP_DCL);

	if (IDL_OP_DCL (op).f_oneway) {
		IDL_tree sub;

		for (sub = IDL_OP_DCL (op).parameter_dcls; sub; sub = IDL_LIST (sub).next) {
			IDL_tree param = IDL_LIST (sub).data;

			if (IDL_PARAM_DCL (param).attr == IDL_PARAM_OUT ||
			    IDL_PARAM_DCL (param).attr == IDL_PARAM_INOUT) {
				g_warning ("Out or Inout parameter in declaration of oneway '%s'",
					   IDL_IDENT(IDL_OP_DCL(op).ident).str);
				break;
			}
		}

		if (IDL_OP_DCL (op).op_type_spec)
			g_warning ("Return value in declaration of oneway '%s'",
				   IDL_IDENT(IDL_OP_DCL(op).ident).str);
	}
}
예제 #30
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;
}