Fixes to 52520 and 13813. Move checks against [retval] usage from xpidl_typelib code to the common xpidl_util code used by all modes, and add a new check asserting that [retva] is only applied to the last parameter. XPConnect has had this restriction for a long time.

no r=, but it's very similar to previous approved changes.  I want to get it in with other xpidl modifications, as everybody's tree needs to be rebuilt anyway.
This commit is contained in:
mccabe%netscape.com 2000-11-30 10:51:39 +00:00
parent 4e0b0efbf3
commit 7ddbcb075b
2 changed files with 24 additions and 15 deletions

View File

@ -1033,7 +1033,6 @@ typelib_op_dcl(TreeState *state)
IDL_tree iter;
uint16 num_args = 0;
uint8 op_flags = 0;
gboolean saw_retval = FALSE;
gboolean op_notxpcom = (IDL_tree_property_get(op->ident, "notxpcom")
!= NULL);
gboolean op_noscript = (IDL_tree_property_get(op->ident, "noscript")
@ -1073,19 +1072,6 @@ typelib_op_dcl(TreeState *state)
XPTParamDescriptor *pd = &meth->params[num_args];
if (!fill_pd_from_param(state, pd, IDL_LIST(iter).data))
return FALSE;
if (pd->flags & XPT_PD_RETVAL) {
if (op->op_type_spec) {
IDL_tree_error(state->tree,
"can't have [retval] with non-void return type");
return FALSE;
}
if (saw_retval) {
IDL_tree_error(state->tree,
"can't have more than one [retval] parameter");
return FALSE;
}
saw_retval = TRUE;
}
}
/* stick retval param where we can see it later */

View File

@ -212,7 +212,6 @@ IDL_tree /* IDL_TYPE_DCL */
find_underlying_type(IDL_tree typedef_ident)
{
IDL_tree up;
IDL_tree type;
if (typedef_ident == NULL || IDL_NODE_TYPE(typedef_ident) != IDLN_IDENT)
return NULL;
@ -347,6 +346,7 @@ verify_method_declaration(IDL_tree method_tree)
IDL_tree iter;
gboolean scriptable_interface;
gboolean scriptable_method;
gboolean seen_retval = FALSE;
const char *method_name = IDL_IDENT(IDL_OP_DCL(method_tree).ident).str;
if (op->f_varargs) {
@ -410,6 +410,29 @@ verify_method_declaration(IDL_tree method_tree)
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) and can't be used with [array].