Evaluating Javascript Expressions In C Functions - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
The moduleName .unload function is called. The unload function destroys its module's global data.
The next time a function in the library is called, GoLive reloads the module and creates new global data
for it.
The SDK makes currently running modules available by name in the JavaScript global namespace. Thus,
the JavaScript name of a module that has not been loaded is undefined. You can test this condition as
follows:
If (typeof
Window.alert ("Cannot find external library.");

Evaluating JavaScript expressions in C functions

External library functions use the JSAEval function to evaluate a text string as a JavaScript expression.
The SDK evaluates the expression in the execution scope of the JavaScript module that calls the external
library. For a discussion of scope, see
JavaScript
C functions in external libraries can use the JSAEval function to:
Retrieve the values of JavaScript properties from within the scope of the calling module.
Execute a JavaScript function call within the scope of the calling module.
You can't pass arguments of any kind, but the scriptlet is evaluated in the context of the JavaScript
variables and properties available to the Extend Script extension module that called the external binary
library.
Retrieve or discard the results of the script evaluation.
For example, the following function uses the JSAEval function to call the getOuterHTML method of the
Markup object that represents the <mytag> custom element in the current document's markup tree.
static void myExtFn(int argc, JSValue *argv, JSValue returnValue)
{
char* pTheSource;
JSAEval(
pTheSource = JSAValueToString(returnValue);
// sets the myExtFn function's return value to undefined
JSAUndefinedToValue(returnValue);
}
When an extension calls the external myExtFn function, the SDK supplies the JSValue pointer passed as
the argument to the returnValue parameter. To retrieve the results of script evaluation, the body of the
myExtFn function passes this pointer as the returnValue argument to the JSAEval function. To
discard the results of script execution, pass null as the returnValue argument to the JSAEval
function.
JSAEval("document.documentElement.getOuterHTML()", returnValue, -1);
When the JSAEval function completes, the returnValue pointer holds the result of the script
evaluation (unless you passed null as this argument.) To return the script evaluation result as the result of
the myExtFn function call, the myExtFn method need not do anything further — the SDK uses the
returnValue pointer as it is.
moduleName
== "undefined")
in the GoLive CS2 SDK Programmer's Reference.
"document.documentElement.getSubElement("mytag").getOuterHTML()",
returnValue, -1);
Adobe GoLive CS2 SDK
Scope of Variables and
Using External Libraries
Functions, and
Appendix E, "Scoping in
185

Advertisement

Table of Contents
loading

Table of Contents