I have created generic ActiveScript support for my application to allow
it
to be scripted. It runs Jscript, VBScript, PerlScript, and PythonScript
very well. Jscript is the primary script language, but the application
must
be compatible with VBScript, PerlScript and PythonScript in the event we
wish to license these as scripting engines in the future (i.e., I have
internally advertised support for these as available scripting language,
should we choose to use them).
As part of the design, I must provide host-application (C++) access to
functions, variables and objects created by each of these script
engines, in
addition to host-defined objects. The normal means of doing this is via
IActiveScript::GetScriptDispatch.
This works quite well for Jscript and VBScript. I can access functions,
variables, classes, objects, and object properties.
However, there *are* issues accessing these things when created in
PerlScript and PythonScript. From limited experimentation, the
following
things appear to be supported and unsupported in PerlScript and
PythonScript:
PERLSCRIPT
- Supports retrieving and calling global procedures
- No support for accessing global variables
- No support for accessing structures and structure members
- No support for accessing class (module) instance data
PYTHONSCRIPT
- Supports retrieving and calling global procedures
- Supports accessing global variables (see notes)
- No support for accessing class objects or members (see notes)
Would someone be kind enough to either verify that these are real
limitations
of these two engines, or indicate that I am just doing something wrong
in my
code and it works fine in yours? Perhaps I am not asking for the
variables
using the proper name? I am particularly interested in accessing
script-created objects and object properties - this is important to the
application design
Thank you very much for your help!
NOTES
PythonScript returns E_NOTIMPL for both variables and class instances
when
called with pDispatch->Invoke( ..., DISPATCH_PROPERTYGET, ...).
However, calling pDispatch->Invoke( ...,
DISPATCH_PROPERTYGET|DISPATCH_METHOD, ...) seems to work fine for
variables,
but still returns E_NOTIMPL when attempting to access an object (class
instance).
Neither works for PerlScript: in fact, PerlScript does not get past
pDispatch->GetIDsOfNames(), which returns DISP_E_UNKNOWNNAME. This
leads me
to think that perhaps PerlScript requires some additional syntactic
sugar to
access variables and object member. None of the following work:
"varName",
"main::varName", "main::$varName", or "$varName". However, I can access
procedures just fine with the same code. Am I doing else something
wrong
here? Do I need to specify the variable name differently?
James
_____________________________________________________________
"Perfection is reached, not when there is no longer anything more to
add,
but when there is no longer anything to take away."
-- Antoine de Saint Exupery
_____________________________________________________________
James Hugard, Software Consultant
[EMAIL PROTECTED]
_____________________________________________________________
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Other options: http://listserv.ActiveState.com/mailman/listinfo/ActivePython