Sha256: b61b3db0f2f84e5da27f40111eaf12b96434f4a0b5742588e467240c57325852

Contents?: true

Size: 1.34 KB

Versions: 23

Compression:

Stored size: 1.34 KB

Contents

#include "extensions.h"

static JSBool /* Object.defineProperty(target, name, value, flags) */
define_property(JSContext *js_context, JSObject* UNUSED(obj), uintN argc, jsval *argv, jsval *retval) {
  assert(argc > 1);
  char *name = JS_GetStringBytes(JSVAL_TO_STRING(argv[1]));

  // READ_ONLY | ITERABLE | NON_DELETABLE
  jsuint flags = argc > 3 ? (unsigned) JSVAL_TO_INT(argv[3]) : 0;

  *retval = JSVAL_VOID;
  return JS_DefineProperty(js_context, JSVAL_TO_OBJECT(argv[0]), name, argc > 2 ? argv[2] : JSVAL_VOID, NULL, NULL, flags);
}

VALUE init_spidermonkey_extensions(JohnsonContext* context, VALUE self)
{
  PREPARE_RUBY_JROOTS(context->js, 1);
  
  jsval Object;
  JSObject * global = JS_GetGlobalObject(context->js);
  JCHECK(JS_GetProperty(context->js, global, "Object", &Object));
  JROOT(Object);

  JCHECK(JS_DefineFunction(context->js, JSVAL_TO_OBJECT(Object),
    "defineProperty", define_property, 4, 0));
        
  JCHECK(JS_DefineProperty(context->js, JSVAL_TO_OBJECT(Object), "READ_ONLY",
    INT_TO_JSVAL(0x02), NULL, NULL, JSPROP_READONLY));
        
  JCHECK(JS_DefineProperty(context->js, JSVAL_TO_OBJECT(Object), "ITERABLE",
    INT_TO_JSVAL(0x01), NULL, NULL, JSPROP_READONLY));
        
  JCHECK(JS_DefineProperty(context->js, JSVAL_TO_OBJECT(Object), "NON_DELETABLE",
    INT_TO_JSVAL(0x04), NULL, NULL, JSPROP_READONLY));

  JRETURN_RUBY(self);
}

Version data entries

23 entries across 23 versions & 3 rubygems

Version Path
jbarnette-johnson-1.0.0.200806240111 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.200807291507 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.200808062051 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.200808062111 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.200811251942 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.20081126120511 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.20090127202936 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.20090225110820 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.20090326122910 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.20090326154650 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.20090326161333 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.20090402144841 ext/spidermonkey/extensions.c
jbarnette-johnson-1.0.0.20090402155420 ext/spidermonkey/extensions.c
johnson-2.0.0.pre1 ext/spidermonkey/extensions.c
johnson-2.0.0.pre0 ext/spidermonkey/extensions.c
johnson-1.2.0 ext/spidermonkey/extensions.c
smparkes-johnson-1.1.2.6 ext/spidermonkey/extensions.c
smparkes-johnson-1.1.2.5 ext/spidermonkey/extensions.c
smparkes-johnson-1.1.2.4 ext/spidermonkey/extensions.c
smparkes-johnson-1.1.2.3 ext/spidermonkey/extensions.c