[xml-rpc] createType not working as before




18 years ago
17 years ago


(Reporter: janv, Assigned: Martijn Pieters)



Firefox Tracking Flags

(Not tracked)



(5 attachments)



18 years ago

var x=xmlrpc.createType(xmlrpc.STRING)

var x=xmlrpc.createType(xmlrpc.STRING)

Why I have to QueryInterface ?
In M17 it's working without quering.

Comment 1

18 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

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

Comment 2

18 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

18 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:

and the referenced urls:

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,{});


  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.

Comment 4

18 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.


18 years ago

Comment 5

18 years ago
Created attachment 12776 [details] [diff] [review]
Proposed path relative to extensions/xml-rpc/

Comment 6

18 years ago
Martijn, Looks right to me. Does it work as expected?

Comment 7

18 years ago
this broke linux filepicker also

Comment 8

18 years ago
please ignore my last comment

Comment 9

18 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
chrome://lis/content/xml-rpc.xul :: callAsync :: line 23"  data:

Comment 10

18 years ago
forgot remove bryner from CC list
because this is not also filepicker issue as I thought

Comment 11

18 years ago
Did you force the typelib to get updated by doing a make in this directory?

Comment 12

18 years ago
Thanks, createType works now.

But I think this require more work

Comment 13

18 years ago
>But I think this require more work


Comment 14

18 years ago
Created attachment 12980 [details] [diff] [review]
new patch

Comment 15

18 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

Comment 16

18 years ago
Created attachment 12982 [details] [diff] [review]
I'm sorry previous patch is bad, use this

Comment 17

18 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.

Comment 18

18 years ago
Sorry, I won't be able to look into this until after my holiday (the next two

Comment 19

18 years ago
Created attachment 14706 [details] [diff] [review]
Proposed patch

Comment 20

18 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.

Comment 21

18 years ago
Created attachment 14712 [details] [diff] [review]
*Correct* proposed fix

Comment 22

18 years ago
Latest patch has the right test/xml-rpc.xul file.

Comment 23

18 years ago
works for me

Comment 24

18 years ago
Fix checked in. Thanks Jan.
Last Resolved: 18 years ago
Resolution: --- → FIXED

Comment 25

17 years ago
Marking verified per last comments.
You need to log in before you can comment on or make changes to this bug.