On Jul 4, 10:37 pm, Boris Zbarsky <bzbar
...@mit.edu> wrote:
> > the latest one - DrawImage - is a complete blocker. in the IDL file,
> > there are zero arguments. in the implementation, it is assumed that
> > there will be a Javascript Context (which in python-xpcom there won't
> > be) and thus the optional arguments will be picked up from there
> > (which in python-xpcom they can't be).
> Yes. This was done more or less by design; part of the problem is that
> the desired behavior of the function can't be expressed in xpidl. Or at
> least couldn't be when the function was created. Maybe things have changed?
> > thus i've created a patch which makes the first three arguments non-
> > optional, by adding them into the IDL file and thus python-xpcom and
> > all other XPCOM bindings can get at them.
> I commented about that patch in the bug.
> > the typical simplest solution here is one which microsoft deploys when
> > using IDL files - simply create drawImage1 which takes 3 args,
> > drawImage2 which takes 5, and drawImage3 which takes 9.
> The problem is a limitation of xpidl and pyxcpom that would cause all
> those methods to be exposed to web script if they're not marked
> [noscript] (not acceptable) and not be exposed to pyxpcom if not marked
> [noscript] (a stupid bug in pyxpcom, in my opinion).
> > this policy is something that microsoft has successfully deployed time and time
> > again for the past... what... 18 years since the introduction of DCE/
> > RPC into the very first version of the NT operating system (NT 3.1).
> Microsoft does not expose its IDL interfaces directly to web script.
ya - i figured (surmise) that the implementation of the web script
goes something like:
JSFunction()
{
JSContext ctx = getJScontext()
argc = ctx->argc
argv = ctx->argv
if argc == 5
return IDLisedInterfaceJSFunction1(argv[0], argv[1], ....
argv[4])
elif argc == 9
return IDLisedInterfaceJSFunction2(argv[0], argv[1], ....
argv[8])
}
pretty much for every single function, perhaps with some auto-
generator
or perhaps a base class which can deal with the "general" case where
the
web (JS) function matches exactly with the published IDL definition.
and then, COM (or, better DCOM in the MS case) can bind to the IDL
definitions, and JS is the "special strict" jobbie.
so, the lovely Visual Basic gets the function1, function2 etc. etc.
convention, and the lovely IE5-8 JS gets whatever MS decides that it
wants to call the W3C published spec function name, today.
i can see that you've taken this approach with e.g. OpenRequest in
XMLHttpRequest but then added [noscript] to make it unavailable, which
makes absolutely no sense!
the numbering approach is i believe a lot simpler than the meandering
that i can see going on, with noscript, optional, suggestions for
optional_argc and noxpcom.
i think that microsoft's approach, to treat JS as the first class
citizen and have that as the strict compliance naming-wise, and for
everything else to be "fair game", is just really really sensible.
step back and think about it for a second: not all languages (COM
bindings) have the concept of default values or even optional
arguments (c unless you want to get into a terrible mess with
varargs). not all languages can do function overloading (c, python).
therefore, sticking to the simplest approach - the one that's
originally c-based (DCOM is COM and is based on DCE/RPC, so the IDL
files revolve around c not c++) is just .... sensible.
and doing anything else - deviating from that original design - is
just going to get you into no end of trouble.
but, hey, i'm just a random free software developer - you're big
enough and ugly enough to work these things out for yourselves, or to
enjoy the pain of incompatible COM implementations across languages,
if that's what you're in to :)
i'm just glad it's hanging together enough for pyjamas-desktop to be
able to work at all. it took only 2 days to port pyjamas to python-
xpcom, and, staggeringly, the only thing i've found that won't work
(at all) is that SVG 2D Canvas context "DrawImage" function.
you should be absolutely dead proud of yourselves for that because
pyjamas is a pretty much unknown but very comprehensive DOM-using
project that squeezes absolutely every corner of its underlying DOM
api (in this case, xulrunner) until the pips squeak.
l.