Closed
Bug 48564
Opened 25 years ago
Closed 25 years ago
[xml-rpc] createType not working as before
Categories
(Core :: XML, defect, P3)
Tracking
()
VERIFIED
FIXED
People
(Reporter: janv, Assigned: mj)
Details
Attachments
(5 files)
4.05 KB,
patch
|
Details | Diff | Splinter Review | |
9.61 KB,
patch
|
Details | Diff | Splinter Review | |
9.62 KB,
patch
|
Details | Diff | Splinter Review | |
12.31 KB,
patch
|
Details | Diff | Splinter Review | |
12.51 KB,
patch
|
Details | Diff | Splinter Review |
before:
var x=xmlrpc.createType(xmlrpc.STRING)
x.data="text";
now:
var x=xmlrpc.createType(xmlrpc.STRING)
x=x.QueryInterface(Components.interfaces.nsISupportsString);
x.data="text";
Why I have to QueryInterface ?
In M17 it's working without quering.
Assignee | ||
Comment 1•25 years ago
|
||
Hmm, strange. Nothing changed in that area, it seems that
.createInstance(interface) ignores the interface argument.
If it is, than that would be a bug in XPConnect, but just now I have no time to
investigate.
In the meantime, you could try and see what the following code gives you:
var id = 'component://netscape/supports-string'
var inf = 'nsISupportsString'
var x = Components.classes[id].createInstance(Components.interfaces[intf])
This is exactly what happens when you call .createType(xmlrpc.STRING)
Summary: [xml-rpc] createType not working as before → [xml-rpc] createType not working as before
Reporter | ||
Comment 2•25 years ago
|
||
This code works, I also tried something similar.
I think too that this is bug in XPConnect.
Same function createType works standalone (copied to my script)
problem probably rise when instance is returned as nsISupports
adding jband to CC list
Comment 3•25 years ago
|
||
No, this is not really a bug in XPConnect. I tightened the rules for JS
Components and closed loopholes that were open only when the caller and the
component were both implemented in JavaScript.
see my posting:
news://news.mozilla.org/3987B45D.FB8301D2%40netscape.com
and the referenced urls:
http://www.mozilla.org/scriptable/js-components-status.html
http://bugzilla.mozilla.org/show_bug.cgi?id=25180
I'm sorry this change broke your code.
Before this change a JS caller to the JS component was not restricted to the
semantics of the interface as declared. This was bad. Some things that should
not have worked for xpcom interfaces did work. You have a case of that here...
The interface says:
nsISupports createType(in unsigned long type);
If you implement or call this in C++ you would have to QI to the type you want.
This only worked before because the JS caller was getting direct access to the
JSObject returned by the JS component implementing the interface.
XPConnect now enforces the semantics of the interface. This may seem annoying,
but imagine that at some later time it is decided to implement this same
interface in C++ or python. Then all the callers relying on this special
behavior that is *not* suggested by the semantics of the interface would be
broken. we decided it as better to do this fix now then later when more JS
Componets are likely to be in use.
So how should you work around it?
I appreciate the idea of having this convenience function that allows the caller
to not worry about the actual iid, but instead just use the limited set of
types. But, one way or another the actual iid needs to be communicated in the
interface in order for the mapping layer (xpconnect or some future layer) to
know what the interface type actually is. I would suggest:
void createType(in unsigned long type,
out nsIIDRef uuid,
[iid_is(uuid),retval] out nsQIResult result);
In the implementation you'd have to set uuid.value = theIID for each of the
cases to let xpconnect know what type of wrapper to build.
And, since xpconnect does not allow you to not pass required params (even if the
caller is going to ignore them), the callers would have to pass an additional
object to hold the 'out' param. This can be as simple as:
var x = xmlrpc.createType(xmlrpc.STRING,{});
or
var ignored = {};
var x = xmlrpc.createType(xmlrpc.STRING, ignored);
var y = xmlrpc.createType(xmlrpc.ARRAY, ignored);
// etc...
Sorry, that's the best solution I have.
Assignee | ||
Comment 4•25 years ago
|
||
Thanks John,
I'll use your new method, it is not that big a change for JS users. I'll attach
a patch for this.
Assignee | ||
Updated•25 years ago
|
Status: NEW → ASSIGNED
Assignee | ||
Comment 5•25 years ago
|
||
Comment 6•25 years ago
|
||
Martijn, Looks right to me. Does it work as expected?
Reporter | ||
Comment 7•25 years ago
|
||
this broke linux filepicker also
Reporter | ||
Comment 8•25 years ago
|
||
please ignore my last comment
Reporter | ||
Comment 9•25 years ago
|
||
I tried proposed patch but it doesn't work for me.
here is error message:
Call Async
JavaScript error:
line 0: uncaught exception: [Exception... "[JavaScript Error: "uuid has no
properties" {file:
"/home/varga/mozilla/obj-optimized/dist/bin/components/nsXmlRpcClient.js" line:
416}] [nsIXmlRpcClient::createType]" nsresult: "0x80570021
(NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)" location: "JS frame ::
chrome://lis/content/xml-rpc.xul :: callAsync :: line 23" data:
yes]
Reporter | ||
Comment 10•25 years ago
|
||
forgot remove bryner from CC list
because this is not also filepicker issue as I thought
Comment 11•25 years ago
|
||
Did you force the typelib to get updated by doing a make in this directory?
Reporter | ||
Comment 12•25 years ago
|
||
Thanks, createType works now.
But I think this require more work
Comment 13•25 years ago
|
||
>But I think this require more work
meaning?
Reporter | ||
Comment 14•25 years ago
|
||
Reporter | ||
Comment 15•25 years ago
|
||
New patch includes additional small fixes to get XML-RPC working
For example, variable "internalContext" was passed to channel.asyncRead as
nsISupports and then accessed as ctxt.listener, ctxt.context, ctxt.seenStart
but this is impossible now.
Insteed I created 2 new member variables _listener and _seenStart
Hope it will work
Reporter | ||
Comment 16•25 years ago
|
||
Assignee | ||
Comment 17•25 years ago
|
||
Almost there :)
The Interface definition for call needs to be updated too.
I am sorry that I my reaction speed is so low, I have little time to spare just
now. I'll try to and test this later this week.
Assignee | ||
Comment 18•25 years ago
|
||
Sorry, I won't be able to look into this until after my holiday (the next two
weeks).
Assignee | ||
Comment 19•25 years ago
|
||
Assignee | ||
Comment 20•25 years ago
|
||
Attached patch fixes the problems, and unscrews RayW carpool "fix" for the
prog-ids. He didn't see I do dynamic "Contract ID" stuff with createType.
I am waiting for a r= before checkin.
Assignee | ||
Comment 21•25 years ago
|
||
Assignee | ||
Comment 22•25 years ago
|
||
Latest patch has the right test/xml-rpc.xul file.
Reporter | ||
Comment 23•25 years ago
|
||
works for me
Assignee | ||
Comment 24•25 years ago
|
||
Fix checked in. Thanks Jan.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•