зеркало из https://github.com/mozilla/gecko-dev.git
add xpidl support for DOMString to fix bug 65762. r=jst sr=brendan
This commit is contained in:
Родитель
abc6bd8a0b
Коммит
ea496b8199
|
@ -66,7 +66,10 @@
|
|||
((uint8)((np_no) | ((p_no) << 1) | ((np_o) << 2) | ((p_o) << 3)))
|
||||
|
||||
/***********************************************************/
|
||||
#define XPC_FLAG_COUNT nsXPTType::T_PWSTRING_SIZE_IS+1
|
||||
// xpt uses 5 bits for this info. We deal with the possibility that
|
||||
// some new types might exist that we don't know about.
|
||||
|
||||
#define XPC_FLAG_COUNT (1 << 5)
|
||||
|
||||
/* '1' means 'reflectable'. '0' means 'not reflectable'. */
|
||||
static uint8 xpc_reflectable_flags[XPC_FLAG_COUNT] = {
|
||||
|
@ -87,15 +90,25 @@ static uint8 xpc_reflectable_flags[XPC_FLAG_COUNT] = {
|
|||
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_WCHAR */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* T_VOID */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_IID */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* T_BSTR */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* T_DOMSTRING */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_CHAR_STR */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_WCHAR_STR */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_INTERFACE */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_INTERFACE_IS */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_ARRAY */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_PSTRING_SIZE_IS */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ) /* T_PWSTRING_SIZE_IS */
|
||||
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_PWSTRING_SIZE_IS */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 23 - reserved */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 24 - reserved */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 25 - reserved */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 26 - reserved */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 27 - reserved */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 28 - reserved */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 29 - reserved */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* 30 - reserved */
|
||||
XPC_MK_FLAG( 0 , 0 , 0 , 0 ) /* 31 - reserved */
|
||||
};
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
// static
|
||||
|
@ -333,9 +346,9 @@ XPCConvert::NativeData2JS(JSContext* cx, jsval* d, const void* s,
|
|||
break;
|
||||
}
|
||||
|
||||
case nsXPTType::T_BSTR:
|
||||
// XXX implement BSTR ?
|
||||
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : BSTR params not supported"));
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
// XXX implement DOMSTRING
|
||||
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : DOMSTRING params not supported"));
|
||||
return JS_FALSE;
|
||||
|
||||
case nsXPTType::T_CHAR_STR:
|
||||
|
@ -572,9 +585,9 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, jsval s,
|
|||
return JS_TRUE;
|
||||
}
|
||||
|
||||
case nsXPTType::T_BSTR:
|
||||
// XXX implement BSTR
|
||||
XPC_LOG_ERROR(("XPCConvert::JSData2Native : BSTR params not supported"));
|
||||
case nsXPTType::T_DOMSTRING:
|
||||
// XXX implement DOMSTRING
|
||||
XPC_LOG_ERROR(("XPCConvert::JSData2Native : DOMSTRING params not supported"));
|
||||
return JS_FALSE;
|
||||
|
||||
case nsXPTType::T_CHAR_STR:
|
||||
|
@ -1263,7 +1276,7 @@ XPCConvert::NativeArray2JS(JSContext* cx,
|
|||
case nsXPTType::T_WCHAR : POPULATE(jschar); break;
|
||||
case nsXPTType::T_VOID : NS_ASSERTION(0,"bad type"); goto failure;
|
||||
case nsXPTType::T_IID : POPULATE(nsID*); break;
|
||||
case nsXPTType::T_BSTR : NS_ASSERTION(0,"bad type"); goto failure;
|
||||
case nsXPTType::T_DOMSTRING : NS_ASSERTION(0,"bad type"); goto failure;
|
||||
case nsXPTType::T_CHAR_STR : POPULATE(char*); break;
|
||||
case nsXPTType::T_WCHAR_STR : POPULATE(jschar*); break;
|
||||
case nsXPTType::T_INTERFACE : POPULATE(nsISupports*); break;
|
||||
|
@ -1389,7 +1402,7 @@ fill_array:
|
|||
case nsXPTType::T_WCHAR : POPULATE(na, jschar); break;
|
||||
case nsXPTType::T_VOID : NS_ASSERTION(0,"bad type"); goto failure;
|
||||
case nsXPTType::T_IID : POPULATE(fr, nsID*); break;
|
||||
case nsXPTType::T_BSTR : NS_ASSERTION(0,"bad type"); goto failure;
|
||||
case nsXPTType::T_DOMSTRING : NS_ASSERTION(0,"bad type"); goto failure;
|
||||
case nsXPTType::T_CHAR_STR : POPULATE(fr, char*); break;
|
||||
case nsXPTType::T_WCHAR_STR : POPULATE(fr, jschar*); break;
|
||||
case nsXPTType::T_INTERFACE : POPULATE(re, nsISupports*); break;
|
||||
|
|
|
@ -64,6 +64,10 @@ typedef unsigned long size_t;
|
|||
|
||||
[ptr] native nsQIResult(void);
|
||||
|
||||
[ref, domstring] native DOMString(ignored);
|
||||
[ref, domstring] native DOMStringRef(ignored);
|
||||
[ptr, domstring] native DOMStringPtr(ignored);
|
||||
|
||||
%{C++
|
||||
/*
|
||||
* End commenting out the C++ versions of the above in the output header
|
||||
|
|
|
@ -138,7 +138,7 @@ struct nsXPTCVariant : public nsXPTCMiniVariant
|
|||
case nsXPTType::T_WCHAR: val.wc = mv.val.wc; break;
|
||||
case nsXPTType::T_VOID: /* fall through */
|
||||
case nsXPTType::T_IID: /* fall through */
|
||||
case nsXPTType::T_BSTR: /* fall through */
|
||||
case nsXPTType::T_DOMSTRING: /* fall through */
|
||||
case nsXPTType::T_CHAR_STR: /* fall through */
|
||||
case nsXPTType::T_WCHAR_STR: /* fall through */
|
||||
case nsXPTType::T_INTERFACE: /* fall through */
|
||||
|
|
|
@ -154,7 +154,7 @@ public:
|
|||
T_WCHAR = TD_WCHAR ,
|
||||
T_VOID = TD_VOID ,
|
||||
T_IID = TD_PNSIID ,
|
||||
T_BSTR = TD_PBSTR ,
|
||||
T_DOMSTRING = TD_DOMSTRING ,
|
||||
T_CHAR_STR = TD_PSTRING ,
|
||||
T_WCHAR_STR = TD_PWSTRING ,
|
||||
T_INTERFACE = TD_INTERFACE_TYPE ,
|
||||
|
@ -178,6 +178,7 @@ public:
|
|||
PRBool IsOut() const {return (PRBool) (XPT_PD_IS_OUT(flags));}
|
||||
PRBool IsRetval() const {return (PRBool) (XPT_PD_IS_RETVAL(flags));}
|
||||
PRBool IsShared() const {return (PRBool) (XPT_PD_IS_SHARED(flags));}
|
||||
PRBool IsDipper() const {return (PRBool) (XPT_PD_IS_DIPPER(flags));}
|
||||
const nsXPTType GetType() const {return type.prefix;}
|
||||
|
||||
// NOTE: other activities on types are done via methods on nsIInterfaceInfo
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
/*
|
||||
* IDL_tree_warning bombs on libIDL version 6.5, and I don't want to not write
|
||||
* warnings... so I define a versioned one here. Thanks to Mike Shaver for the
|
||||
* ## idiom, which allows us to pass through varargs calls.
|
||||
* ## idiom, that allows us to pass through varargs calls.
|
||||
*/
|
||||
#if !(LIBIDL_MAJOR_VERSION == 0 && LIBIDL_MINOR_VERSION == 6 && \
|
||||
LIBIDL_MICRO_VERSION == 5) && !defined(DEBUG_shaver)
|
||||
|
@ -197,6 +197,9 @@ xpidl_parse_iid(nsID *id, const char *str);
|
|||
(IDL_NODE_TYPE(node) == IDLN_IDENT && \
|
||||
UP_IS_AGGREGATE(node)))
|
||||
|
||||
#define DIPPER_TYPE(node) \
|
||||
(NULL != IDL_tree_property_get(node, "domstring"))
|
||||
|
||||
/*
|
||||
* Find the underlying type of an identifier typedef. Returns NULL
|
||||
* (and doesn't complain) on failure.
|
||||
|
|
|
@ -535,7 +535,7 @@ list(TreeState *state)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
write_type(IDL_tree type_tree, FILE *outfile)
|
||||
write_type(IDL_tree type_tree, gboolean is_out, FILE *outfile)
|
||||
{
|
||||
if (!type_tree) {
|
||||
fputs("void", outfile);
|
||||
|
@ -596,7 +596,15 @@ write_type(IDL_tree type_tree, FILE *outfile)
|
|||
break;
|
||||
case IDLN_IDENT:
|
||||
if (UP_IS_NATIVE(type_tree)) {
|
||||
fputs(IDL_NATIVE(IDL_NODE_UP(type_tree)).user_type, outfile);
|
||||
if (IDL_tree_property_get(type_tree, "domstring")) {
|
||||
if (is_out) {
|
||||
fputs("nsAWritableString", outfile);
|
||||
} else {
|
||||
fputs("nsAReadableString", outfile);
|
||||
}
|
||||
} else {
|
||||
fputs(IDL_NATIVE(IDL_NODE_UP(type_tree)).user_type, outfile);
|
||||
}
|
||||
if (IDL_tree_property_get(type_tree, "ptr")) {
|
||||
fputs(" *", outfile);
|
||||
} else if (IDL_tree_property_get(type_tree, "ref")) {
|
||||
|
@ -650,20 +658,22 @@ write_attr_accessor(IDL_tree attr_tree, FILE * outfile,
|
|||
getter ? 'G' : 'S',
|
||||
toupper(*attrname), attrname + 1);
|
||||
if (mode == AS_DECL || mode == AS_IMPL) {
|
||||
/* Setters for string, wstring and nsid get const. */
|
||||
/* Setters for string, wstring, nsid, and domstring get const.
|
||||
*/
|
||||
if (!getter &&
|
||||
(IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_STRING ||
|
||||
IDL_NODE_TYPE(ATTR_TYPE_DECL(attr_tree)) == IDLN_TYPE_WIDE_STRING ||
|
||||
IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "nsid")))
|
||||
IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "nsid") ||
|
||||
IDL_tree_property_get(ATTR_TYPE_DECL(attr_tree), "domstring")))
|
||||
{
|
||||
fputs("const ", outfile);
|
||||
}
|
||||
|
||||
if (!write_type(ATTR_TYPE_DECL(attr_tree), outfile))
|
||||
if (!write_type(ATTR_TYPE_DECL(attr_tree), getter, outfile))
|
||||
return FALSE;
|
||||
fprintf(outfile, "%s%s",
|
||||
(STARRED_TYPE(attr_tree) ? "" : " "),
|
||||
getter ? "*" : "");
|
||||
(getter && !DIPPER_TYPE(ATTR_TYPE_DECL(attr_tree)))? "*" : "");
|
||||
}
|
||||
fprintf(outfile, "a%c%s)", toupper(attrname[0]), attrname + 1);
|
||||
return TRUE;
|
||||
|
@ -775,7 +785,7 @@ do_typedef(TreeState *state)
|
|||
printlist(state->file, doc_comments);
|
||||
|
||||
fputs("typedef ", state->file);
|
||||
if (!write_type(type, state->file))
|
||||
if (!write_type(type, FALSE, state->file))
|
||||
return FALSE;
|
||||
fputs(" ", state->file);
|
||||
|
||||
|
@ -796,7 +806,7 @@ do_typedef(TreeState *state)
|
|||
printlist(state->file, doc_comments);
|
||||
|
||||
fputs("typedef ", state->file);
|
||||
if (!write_type(type, state->file))
|
||||
if (!write_type(type, FALSE, state->file))
|
||||
return FALSE;
|
||||
fputs(" ", state->file);
|
||||
fputs(IDL_IDENT(IDL_LIST(dcls).data).str, state->file);
|
||||
|
@ -818,14 +828,18 @@ 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, and any
|
||||
* explicitly marked [const] are const
|
||||
*/
|
||||
|
||||
/* in string, wstring, nsid, and any explicitly marked [const] are const */
|
||||
if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_IN &&
|
||||
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, "nsid") ||
|
||||
IDL_tree_property_get(param_type_spec, "domstring"))) {
|
||||
fputs("const ", outfile);
|
||||
}
|
||||
else if (IDL_PARAM_DCL(param_tree).attr == IDL_PARAM_OUT &&
|
||||
|
@ -834,17 +848,20 @@ write_param(IDL_tree param_tree, FILE *outfile)
|
|||
fputs("const ", outfile);
|
||||
}
|
||||
|
||||
if (!write_type(param_type_spec, 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 *! */
|
||||
if (IDL_PARAM_DCL(param_tree).attr != IDL_PARAM_IN)
|
||||
/* 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,
|
||||
|
@ -898,7 +915,7 @@ write_method_signature(IDL_tree method_tree, FILE *outfile, int mode,
|
|||
if (mode == AS_DECL) {
|
||||
if (op_notxpcom) {
|
||||
fputs("NS_IMETHOD_(", outfile);
|
||||
if (!write_type(op->op_type_spec, outfile))
|
||||
if (!write_type(op->op_type_spec, FALSE, outfile))
|
||||
return FALSE;
|
||||
fputc(')', outfile);
|
||||
} else {
|
||||
|
@ -909,7 +926,7 @@ write_method_signature(IDL_tree method_tree, FILE *outfile, int mode,
|
|||
else if (mode == AS_IMPL) {
|
||||
if (op_notxpcom) {
|
||||
fputs("NS_IMETHODIMP_(", outfile);
|
||||
if (!write_type(op->op_type_spec, outfile))
|
||||
if (!write_type(op->op_type_spec, FALSE, outfile))
|
||||
return FALSE;
|
||||
fputc(')', outfile);
|
||||
} else {
|
||||
|
|
|
@ -67,24 +67,24 @@ CreateNewInterfaceHolder(char *name, char *name_space, char *iid,
|
|||
gboolean is_forward_dcl)
|
||||
{
|
||||
NewInterfaceHolder *holder = calloc(1, sizeof(NewInterfaceHolder));
|
||||
if(holder) {
|
||||
if (holder) {
|
||||
holder->is_forward_dcl = is_forward_dcl;
|
||||
if(name)
|
||||
if (name)
|
||||
holder->name = xpidl_strdup(name);
|
||||
if(name_space)
|
||||
if (name_space)
|
||||
holder->name_space = xpidl_strdup(name_space);
|
||||
if(holder->name && holder->name_space) {
|
||||
if (holder->name && holder->name_space) {
|
||||
holder->full_name = calloc(1, strlen(holder->name) +
|
||||
strlen(holder->name_space) + 2);
|
||||
}
|
||||
if(holder->full_name) {
|
||||
if (holder->full_name) {
|
||||
strcpy(holder->full_name, holder->name_space);
|
||||
strcat(holder->full_name, ".");
|
||||
strcat(holder->full_name, holder->name);
|
||||
}
|
||||
else
|
||||
holder->full_name = holder->name;
|
||||
if(iid)
|
||||
if (iid)
|
||||
holder->iid = xpidl_strdup(iid);
|
||||
}
|
||||
return holder;
|
||||
|
@ -93,14 +93,14 @@ CreateNewInterfaceHolder(char *name, char *name_space, char *iid,
|
|||
static void
|
||||
DeleteNewInterfaceHolder(NewInterfaceHolder *holder)
|
||||
{
|
||||
if(holder) {
|
||||
if(holder->full_name && holder->full_name != holder->name)
|
||||
if (holder) {
|
||||
if (holder->full_name && holder->full_name != holder->name)
|
||||
free(holder->full_name);
|
||||
if(holder->name)
|
||||
if (holder->name)
|
||||
free(holder->name);
|
||||
if(holder->name_space)
|
||||
if (holder->name_space)
|
||||
free(holder->name_space);
|
||||
if(holder->iid)
|
||||
if (holder->iid)
|
||||
free(holder->iid);
|
||||
free(holder);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ add_interface_maybe(IDL_tree_func_data *tfd, gpointer user_data)
|
|||
NewInterfaceHolder *holder =
|
||||
CreateNewInterfaceHolder(iface, name_space, iid,
|
||||
(gboolean) node_type == IDLN_FORWARD_DCL);
|
||||
if(!holder)
|
||||
if (!holder)
|
||||
return FALSE;
|
||||
g_hash_table_insert(IFACE_MAP(state),
|
||||
holder->full_name, holder);
|
||||
|
@ -485,7 +485,7 @@ typelib_interface(TreeState *state)
|
|||
uint16 parent_id = 0;
|
||||
PRUint8 interface_flags = 0;
|
||||
|
||||
if(IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable"))
|
||||
if (IDL_tree_property_get(IDL_INTERFACE(iface).ident, "scriptable"))
|
||||
interface_flags |= XPT_ID_SCRIPTABLE;
|
||||
|
||||
ide = FindInterfaceByName(HEADER(state)->interface_directory,
|
||||
|
@ -622,7 +622,7 @@ fill_td_from_type(TreeState *state, XPTTypeDescriptor *td, IDL_tree type)
|
|||
|
||||
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")) {
|
||||
if (IDL_tree_property_get(sd, "array")) {
|
||||
|
||||
is_array = TRUE;
|
||||
|
||||
|
@ -820,9 +820,13 @@ handle_iid_is:
|
|||
goto handle_iid_is;
|
||||
|
||||
ident = IDL_IDENT(type).str;
|
||||
if(IDL_tree_property_get(type, "nsid")) {
|
||||
if (IDL_tree_property_get(type, "nsid")) {
|
||||
td->prefix.flags = TD_PNSIID | XPT_TDP_POINTER;
|
||||
if(IDL_tree_property_get(type, "ref"))
|
||||
if (IDL_tree_property_get(type, "ref"))
|
||||
td->prefix.flags |= XPT_TDP_REFERENCE;
|
||||
} 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 {
|
||||
td->prefix.flags = TD_VOID | XPT_TDP_POINTER;
|
||||
|
@ -897,6 +901,7 @@ static gboolean
|
|||
fill_pd_from_param(TreeState *state, XPTParamDescriptor *pd, IDL_tree tree)
|
||||
{
|
||||
uint8 flags = 0;
|
||||
gboolean is_dipper_type = DIPPER_TYPE(IDL_PARAM_DCL(tree).param_type_spec);
|
||||
|
||||
switch (IDL_PARAM_DCL(tree).attr) {
|
||||
case IDL_PARAM_IN:
|
||||
|
@ -921,6 +926,11 @@ fill_pd_from_param(TreeState *state, XPTParamDescriptor *pd, IDL_tree tree)
|
|||
flags |= XPT_PD_RETVAL;
|
||||
}
|
||||
|
||||
if (is_dipper_type && (flags & XPT_PD_OUT)) {
|
||||
flags &= ~XPT_PD_OUT;
|
||||
flags |= XPT_PD_IN | XPT_PD_DIPPER;
|
||||
}
|
||||
|
||||
if (IDL_tree_property_get(IDL_PARAM_DCL(tree).simple_declarator,
|
||||
"shared")) {
|
||||
if (flags & XPT_PD_IN) {
|
||||
|
@ -963,7 +973,16 @@ typelib_attr_accessor(TreeState *state, XPTMethodDescriptor *meth,
|
|||
ATTR_IDENT(state->tree).str, 1))
|
||||
return FALSE;
|
||||
|
||||
pdflags |= getter ? (XPT_PD_RETVAL | XPT_PD_OUT) : XPT_PD_IN;
|
||||
if (getter) {
|
||||
if (DIPPER_TYPE(ATTR_TYPE_DECL(state->tree))) {
|
||||
pdflags |= (XPT_PD_RETVAL | XPT_PD_IN | XPT_PD_DIPPER);
|
||||
} else {
|
||||
pdflags |= (XPT_PD_RETVAL | XPT_PD_OUT);
|
||||
}
|
||||
} else {
|
||||
pdflags |= XPT_PD_IN;
|
||||
}
|
||||
|
||||
if (!fill_pd_from_type(state, meth->params, pdflags,
|
||||
ATTR_TYPE_DECL(state->tree)))
|
||||
return FALSE;
|
||||
|
@ -1056,9 +1075,12 @@ typelib_op_dcl(TreeState *state)
|
|||
/* XXX unless [notxpcom] */
|
||||
if (!op_notxpcom) {
|
||||
if (op->op_type_spec) {
|
||||
uint8 pdflags = DIPPER_TYPE(op->op_type_spec) ?
|
||||
(XPT_PD_RETVAL | XPT_PD_IN | XPT_PD_DIPPER) :
|
||||
(XPT_PD_RETVAL | XPT_PD_OUT);
|
||||
|
||||
if (!fill_pd_from_type(state, &meth->params[num_args],
|
||||
XPT_PD_RETVAL | XPT_PD_OUT,
|
||||
op->op_type_spec))
|
||||
pdflags, op->op_type_spec))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1111,12 +1133,12 @@ typelib_const_dcl(TreeState *state)
|
|||
value = IDL_INTEGER(dcl->const_exp).value;
|
||||
sign = IDL_TYPE_INTEGER(dcl->const_type).f_signed;
|
||||
if (is_long) {
|
||||
if(sign)
|
||||
if (sign)
|
||||
cd->value.i32 = value;
|
||||
else
|
||||
cd->value.ui32 = value;
|
||||
} else {
|
||||
if(sign)
|
||||
if (sign)
|
||||
cd->value.i16 = value;
|
||||
else
|
||||
cd->value.ui16 = value;
|
||||
|
|
|
@ -227,16 +227,17 @@ verify_attribute_declaration(IDL_tree attr_tree)
|
|||
return TRUE;
|
||||
|
||||
/*
|
||||
* If it should be scriptable, check that the type is non-native. nsid
|
||||
* is exempted.
|
||||
* If it should be scriptable, check that the type is non-native. nsid and
|
||||
* domstring are exempted.
|
||||
*/
|
||||
attr_type = IDL_ATTR_DCL(attr_tree).param_type_spec;
|
||||
|
||||
if (attr_type != NULL && UP_IS_NATIVE(attr_type) &&
|
||||
IDL_tree_property_get(attr_type, "nsid") == NULL)
|
||||
IDL_tree_property_get(attr_type, "nsid") == NULL &&
|
||||
IDL_tree_property_get(attr_type, "domstring") == NULL)
|
||||
{
|
||||
IDL_tree_error(attr_tree,
|
||||
"attributes in [scriptable] interfaces which are "
|
||||
"attributes in [scriptable] interfaces that are "
|
||||
"non-scriptable because they refer to native "
|
||||
"types must be marked [noscript]\n");
|
||||
return FALSE;
|
||||
|
@ -437,15 +438,16 @@ verify_method_declaration(IDL_tree method_tree)
|
|||
|
||||
/*
|
||||
* Reject this method if it should be scriptable and some parameter is
|
||||
* native that isn't marked with either nsid or iid_is.
|
||||
* native that isn't marked with either nsid, domstring, 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(simple_decl, "iid_is") == NULL &&
|
||||
IDL_tree_property_get(param_type, "domstring") == NULL)
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"methods in [scriptable] interfaces which are "
|
||||
"methods in [scriptable] interfaces that are "
|
||||
"non-scriptable because they refer to native "
|
||||
"types (parameter \"%s\") must be marked "
|
||||
"[noscript]", param_name);
|
||||
|
@ -477,7 +479,8 @@ verify_method_declaration(IDL_tree method_tree)
|
|||
|
||||
/*
|
||||
* Confirm that [shared] attributes are only used with string, wstring,
|
||||
* or native (but not nsid) and can't be used with [array].
|
||||
* or native (but not nsid or domstring)
|
||||
* and can't be used with [array].
|
||||
*/
|
||||
if (IDL_tree_property_get(simple_decl, "shared") != NULL) {
|
||||
IDL_tree real_type;
|
||||
|
@ -494,7 +497,8 @@ verify_method_declaration(IDL_tree method_tree)
|
|||
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, "nsid") &&
|
||||
!IDL_tree_property_get(real_type, "domstring"))))
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"[shared] parameter \"%s\" must be of type "
|
||||
|
@ -513,10 +517,11 @@ verify_method_declaration(IDL_tree method_tree)
|
|||
/* 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, "nsid") == NULL &&
|
||||
IDL_tree_property_get(op->op_type_spec, "domstring") == NULL)
|
||||
{
|
||||
IDL_tree_error(method_tree,
|
||||
"methods in [scriptable] interfaces which are "
|
||||
"methods in [scriptable] interfaces that are "
|
||||
"non-scriptable because they return native "
|
||||
"types must be marked [noscript]");
|
||||
return FALSE;
|
||||
|
|
|
@ -101,7 +101,7 @@ struct XPTHeader {
|
|||
/* For error messages. */
|
||||
#define XPT_MAGIC_STRING "XPCOM\\nTypeLib\\r\\n\\032"
|
||||
#define XPT_MAJOR_VERSION 0x01
|
||||
#define XPT_MINOR_VERSION 0x00
|
||||
#define XPT_MINOR_VERSION 0x01
|
||||
|
||||
/* Any file with a major version number of XPT_MAJOR_INCOMPATIBLE_VERSION
|
||||
* or higher is to be considered incompatible by this version of xpt and
|
||||
|
@ -291,7 +291,7 @@ enum XPTTypeDescriptorTags {
|
|||
TD_WCHAR = 12,
|
||||
TD_VOID = 13,
|
||||
TD_PNSIID = 14,
|
||||
TD_PBSTR = 15,
|
||||
TD_DOMSTRING = 15,
|
||||
TD_PSTRING = 16,
|
||||
TD_PWSTRING = 17,
|
||||
TD_INTERFACE_TYPE = 18,
|
||||
|
@ -374,12 +374,14 @@ struct XPTParamDescriptor {
|
|||
#define XPT_PD_OUT 0x40
|
||||
#define XPT_PD_RETVAL 0x20
|
||||
#define XPT_PD_SHARED 0x10
|
||||
#define XPT_PD_FLAGMASK 0xf0
|
||||
#define XPT_PD_DIPPER 0x08
|
||||
#define XPT_PD_FLAGMASK 0xf8
|
||||
|
||||
#define XPT_PD_IS_IN(flags) (flags & XPT_PD_IN)
|
||||
#define XPT_PD_IS_OUT(flags) (flags & XPT_PD_OUT)
|
||||
#define XPT_PD_IS_RETVAL(flags) (flags & XPT_PD_RETVAL)
|
||||
#define XPT_PD_IS_SHARED(flags) (flags & XPT_PD_SHARED)
|
||||
#define XPT_PD_IS_DIPPER(flags) (flags & XPT_PD_DIPPER)
|
||||
|
||||
/* this is bogus
|
||||
#define XPT_PARAMDESCRIPTOR_SIZE (XPT_TYPEDESCRIPTOR_SIZE + 1)
|
||||
|
|
|
@ -528,7 +528,6 @@ SizeOfConstDescriptor(XPTConstDescriptor *cd, XPTInterfaceDescriptor *id)
|
|||
break;
|
||||
case TD_INT32:
|
||||
case TD_UINT32:
|
||||
case TD_PBSTR: /* XXX check for pointer! */
|
||||
case TD_PSTRING:
|
||||
size += 4;
|
||||
break;
|
||||
|
@ -675,11 +674,6 @@ DoConstDescriptor(XPTArena *arena, XPTCursor *cursor, XPTConstDescriptor *cd,
|
|||
case TD_WCHAR:
|
||||
ok = XPT_Do16(cursor, &cd->value.wch);
|
||||
break;
|
||||
case TD_PBSTR:
|
||||
if (cd->type.prefix.flags & XPT_TDP_POINTER) {
|
||||
ok = XPT_DoString(arena, cursor, &cd->value.string);
|
||||
break;
|
||||
}
|
||||
/* fall-through */
|
||||
default:
|
||||
fprintf(stderr, "illegal type!\n");
|
||||
|
|
|
@ -122,12 +122,13 @@ main(int argc, char **argv)
|
|||
TRY("FillMethodDescriptor", ok);
|
||||
|
||||
meth->result->flags = 0;
|
||||
meth->result->type.prefix.flags = TD_PBSTR | XPT_TDP_POINTER;
|
||||
meth->result->type.prefix.flags = TD_PSTRING | XPT_TDP_POINTER;
|
||||
meth->params[0].type.prefix.flags = TD_UINT32;
|
||||
meth->params[0].flags = XPT_PD_IN;
|
||||
meth->params[1].type.prefix.flags = TD_BOOL;
|
||||
meth->params[1].flags = XPT_PD_IN;
|
||||
|
||||
#if 0
|
||||
/* const one = 1; */
|
||||
id->const_descriptors[0].name = "one";
|
||||
id->const_descriptors[0].type.prefix.flags = TD_UINT16;
|
||||
|
@ -137,6 +138,7 @@ main(int argc, char **argv)
|
|||
id->const_descriptors[1].name = "squeamish";
|
||||
id->const_descriptors[1].type.prefix.flags = TD_PBSTR | XPT_TDP_POINTER;
|
||||
id->const_descriptors[1].value.string = XPT_NewStringZ(arena, "ossifrage");
|
||||
#endif
|
||||
|
||||
/* serialize it */
|
||||
state = XPT_NewXDRState(XPT_ENCODE, NULL, 0);
|
||||
|
|
|
@ -42,29 +42,35 @@
|
|||
|
||||
#define BASE_INDENT 3
|
||||
|
||||
static char *type_array[23] =
|
||||
{"int8", "int16", "int32", "int64",
|
||||
"uint8", "uint16", "uint32", "uint64",
|
||||
"float", "double", "boolean", "char",
|
||||
"wchar_t", "void", "reserved", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved",
|
||||
"reserved", "reserved", "reserved"};
|
||||
static char *type_array[32] =
|
||||
{"int8", "int16", "int32", "int64",
|
||||
"uint8", "uint16", "uint32", "uint64",
|
||||
"float", "double", "boolean", "char",
|
||||
"wchar_t", "void", "reserved", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved"};
|
||||
|
||||
static char *ptype_array[23] =
|
||||
{"int8 *", "int16 *", "int32 *", "int64 *",
|
||||
"uint8 *", "uint16 *", "uint32 *", "uint64 *",
|
||||
"float *", "double *", "boolean *", "char *",
|
||||
"wchar_t *", "void *", "nsIID *", "bstr",
|
||||
"string", "wstring", "Interface *", "InterfaceIs *",
|
||||
"array", "string_s", "wstring_s"};
|
||||
static char *ptype_array[32] =
|
||||
{"int8 *", "int16 *", "int32 *", "int64 *",
|
||||
"uint8 *", "uint16 *", "uint32 *", "uint64 *",
|
||||
"float *", "double *", "boolean *", "char *",
|
||||
"wchar_t *", "void *", "nsIID *", "DOMString *",
|
||||
"string", "wstring", "Interface *", "InterfaceIs *",
|
||||
"array", "string_s", "wstring_s", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved"};
|
||||
|
||||
static char *rtype_array[23] =
|
||||
{"int8 &", "int16 &", "int32 &", "int64 &",
|
||||
"uint8 &", "uint16 &", "uint32 &", "uint64 &",
|
||||
"float &", "double &", "boolean &", "char &",
|
||||
"wchar_t &", "void &", "nsIID &", "bstr",
|
||||
"string &", "wstring &", "Interface &", "InterfaceIs &",
|
||||
"array &", "string_s &", "wstring_s &"};
|
||||
static char *rtype_array[32] =
|
||||
{"int8 &", "int16 &", "int32 &", "int64 &",
|
||||
"uint8 &", "uint16 &", "uint32 &", "uint64 &",
|
||||
"float &", "double &", "boolean &", "char &",
|
||||
"wchar_t &", "void &", "nsIID &", "DOMString &",
|
||||
"string &", "wstring &", "Interface &", "InterfaceIs &",
|
||||
"array &", "string_s &", "wstring_s &", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved",
|
||||
"reserved", "reserved", "reserved", "reserved"};
|
||||
|
||||
PRBool param_problems = PR_FALSE;
|
||||
|
||||
|
@ -592,6 +598,12 @@ XPT_DumpMethodDescriptor(XPTHeader *header, XPTMethodDescriptor *md,
|
|||
}
|
||||
} else {
|
||||
fprintf(stdout, " ");
|
||||
if (XPT_PD_IS_DIPPER(pd->flags)) {
|
||||
fprintf(stdout, "dipper ");
|
||||
}
|
||||
if (XPT_PD_IS_RETVAL(pd->flags)) {
|
||||
fprintf(stdout, "retval ");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (XPT_PD_IS_OUT(pd->flags)) {
|
||||
|
@ -719,6 +731,13 @@ XPT_DumpParamDescriptor(XPTHeader *header, XPTParamDescriptor *pd,
|
|||
else
|
||||
fprintf(stdout, "FALSE\n");
|
||||
|
||||
fprintf(stdout, "%*sDipper? ", indent, " ");
|
||||
if (XPT_PD_IS_DIPPER(pd->flags))
|
||||
fprintf(stdout, "TRUE\n");
|
||||
else
|
||||
fprintf(stdout, "FALSE\n");
|
||||
|
||||
|
||||
fprintf(stdout, "%*sType Descriptor:\n", indent, " ");
|
||||
if (!XPT_DumpTypeDescriptor(&pd->type, id, new_indent, verbose_mode))
|
||||
return PR_FALSE;
|
||||
|
@ -872,13 +891,6 @@ XPT_DumpConstDescriptor(XPTHeader *header, XPTConstDescriptor *cd,
|
|||
} else
|
||||
return PR_FALSE;
|
||||
break;
|
||||
case TD_PBSTR:
|
||||
if (XPT_TDP_IS_POINTER(cd->type.prefix.flags)) {
|
||||
if (!XPT_DumpXPTString(cd->value.string))
|
||||
return PR_FALSE;
|
||||
} else
|
||||
return PR_FALSE;
|
||||
break;
|
||||
case TD_PSTRING:
|
||||
if (XPT_TDP_IS_POINTER(cd->type.prefix.flags)) {
|
||||
fprintf(stdout, "%s", cd->value.str);
|
||||
|
|
Загрузка…
Ссылка в новой задаче