I've been using IdScriptableObject to implement a few classes.
Normally I've been using exportAsJSClass to define these classes.
However I'm now in a situation where that isn't working.
exportAsJSClass defines a top-level scope property, however I'm now in
the case where rather than wanting it in the top level scope I need to
define it on a object I have.
(ie: Rather than defining class Foo as global.Foo I want to define it as
x.Foo where x is a ScriptableObject I have)
The issue is this:
- exportAsJSClass does not accept an object to define it on
-- exportAsJSClass calls ctor.exportAsScopeProperty(); (addAsProperty
can define it on an object rather than as top-level)
- prototypeValues.createPrecachedConstructor(); is necessary to get ctor
-- prototypeValues is private and cannot be used in subclasses to get a ctor
Could we get another method to handle this case. Possible solutions:
A) An exportAsJSClass that accepts a object and calls addAsProperty(obj)
instead of exportAsScopeProperty
B) An alternate method that does everything in exportAsJSClass EXCEPT
call ctor.exportAsScopeProperty(); and returns ctor
-- exportAsJSClass can call it to get the ctor and run
ctor.exportAsScopeProperty();
-- We can also call it to run addAsProperty
-- It'll also let us define classes in other properties by running that
method, then calling ScriptableObject.defineProperty ourselves (which is
what addAsProperty calls, and exportAsScopeProperty just calls
addAsProperty) and gives us the ability to define things that are
enumerable.
I think the latter option is better.
--
~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://daniel.friesen.name]
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino