On Sep 13, 2004, at 4:12 AM, Josef JAHN wrote:
> Hello list,
>
> Since I can't acces the list archives (which appear to be completely
> non-functional by the way), I'm posting this directly to this list.
>
> I have a script file that extends a java class and overloads a java
> function in that class, "generateAtis(MetarData metarData)"
>
> Suppose you have this java snippet:
>
> MetarData myMetarData = MetarInput.readMetarXML(inputXML);
> Scope outputScope = new
> BasicScope(OscriptInterpreter.getGlobalScope());
> OscriptInterpreter.eval(
> readScriptFile("scripts/AtisOutput.os"), outputScope );
> OscriptInterpreter.eval("metarData;",
> outputScope).opAssign(JavaBridge.convertToScriptObject(myMetarData));
> Value oScript = OscriptInterpreter.eval("(new
> ScriptedAtisOutput()).generateAtis(metarData)", outputScope);
>
> Also suppose that "var metarData;" is set in the script file that is
> evaluated. The eval of "metarData" that I use to convert (or wrap) the
> java object myMetarData to the script object metarData fails.
>
> The error message:
> oscript.exceptions.PackagedScriptObjectException:
> NoSuchMemberException: no such member: (undefined): =
Hmm, try using lookupInScope instead:
outputScope.lookupInScope("metarData").opAssign(...);
or, if you want to also create metarData from java:
outputScope.createMember( "metarData", 0 ).opAssign(...);
The problem, I think, is that the eval() is returning the value of
metarData, rather than a reference to metarData
> Any ideas? I have a very hard time digging through the documentation
> as there are near zero actual java integration examples. Most of the
> examples deal with script code, and writing whole applications in
> script.
yeah, I apologize... I will try to find some time to update and enhance
the java integration docs
----------------------
Rob Clark
Texas Instruments, Inc.
(858)552-2946
ro...@ti...
----------------------
|