Rony G. Flatscher wrote:
Mathias Bauer wrote:
E.g., in the ooRexx support for UNO/OOo the connection-routine looks like:
------------- cut here -------------
::routine UNO.connect public
parse arg unoURL -- retrieve the argument, if any
xContext=.UNO~Bootstrap~bootstrap -- get an initialized local UNO
runtime environment
if unoURL="" then -- no unoURL given, use default (local installation)
return xContext -- return the context object (which can be used to get the
service manager)
-- use the received unoURL to establish a connection to the remote object
uur=
xContext~getServiceManager~createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver",
xContext)
remoteObject = uur~XUnoUrlResolver ~resolve(unoURL) -- get the connection
return remoteObject
------------- cut here -------------
Looking at the code (the tilde is the message operator, i.e. left of it
is the receiving object, right of it the name of the message), there is
no queryInterface() at all. However, wherever the name of an interface
is used as a message name (like at the end of the code snippet, the
message "XUnoUrlResolver"), the "under the covers" support will carry
out the queryInterface().
Exactly that's what more or less what OOo Basic does. I agree that this
is a very good compromise: it allows a qualified access without the
hassle of separate "queryInterface" calls.
Hmm, well, no, not really. OOo Basic gets the name of a method and then
it starts to look for it, if not found, it'll look in the interfaces,
first match wins, if I understand the behaviour correctly.
The above is a little bit (but significantly!) different: it would not
go out and look for methods in interfaces on its own at all. The
programmer needs to denominate the interface, if its methods are to be
used, otherwise a runtime error would occur, indicating that the
intended method was not found. The point just is, that denominating the
interface is unobstrusive in this case, as the programmer does not need
to explicitly carry out the queryInterface(), rather the
"under-the-covers" support for UNO (realized in the form of an ooRexx
module for UNO) does this, alleviating the programmer.
Probably it would be possible to do the same with OOo Basic, ie. add
that behaviour there as well (and it should be possible without breaking
existing code), e.g.
uur.XUnoUrlResolver.resolve(unoURL)
... as an option to
uur.resolve(unoURL)
...which could break existing code: Given the UNOIDL
interface x { void y(); };
interface y: x {};
interface z { y x(); };
the Basic expression
o.x.y;
could either be
o.x.y();
REM call x.y() on o
or
o.x().y();
REM first call z.x() on o, then call y.y() (aka x.y()) on the result
-Stephan
This at first may look like "syntax sugar", as the present behaviour
would still be available. But if desired (as an additional suggestion to
OOo Basic), one could add an OPTION to indicate that interfaces need to
be explicitly denominated.
Regards,
---rony
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]