Skip to content

Instantly share code, notes, and snippets.

@hns
Created April 7, 2010 08:43
Show Gist options
  • Save hns/358670 to your computer and use it in GitHub Desktop.
Save hns/358670 to your computer and use it in GitHub Desktop.
diff --git a/src/org/ringojs/wrappers/Storable.java b/src/org/ringojs/wrappers/Storable.java
index 2ee3055..302fa40 100644
--- a/src/org/ringojs/wrappers/Storable.java
+++ b/src/org/ringojs/wrappers/Storable.java
@@ -70,7 +70,7 @@ public class Storable extends ScriptableObject {
}
@JSStaticFunction
- public static Scriptable defineClass(Scriptable store, String type)
+ public static Scriptable defineClass(Scriptable store, String type, Object mapping)
throws NoSuchMethodException {
int attr = DONTENUM | PERMANENT | READONLY;
Scriptable scope = ScriptRuntime.getTopCallScope(Context.getCurrentContext());
@@ -80,6 +80,9 @@ public class Storable extends ScriptableObject {
// create the constructor, visible to the application
BaseFunction ctor = new FactoryFunction(prototype, scope, FactoryType.CONSTRUCTOR);
ctor.setImmunePrototypeProperty(prototype);
+ if (mapping != Undefined.instance) {
+ ctor.defineProperty("mapping", mapping, attr);
+ }
prototype.setParentScope(ctor);
defineProperty(prototype, "constructor", ctor, attr);
// create the factory function, visible to the store implementation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment