RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: rpm                              Date:   25-Jun-2017 01:46:21
  Branch: rpm-5_4                          Handle: 2017062423462100

  Modified files:           (Branch: rpm-5_4)
    rpm/rpmio               rpmjs17.cpp rpmjs185.cpp rpmjs24.cpp rpmjs31.cpp
                            rpmjs38.cpp

  Log:
    - rpmjss: make as similar as possible.

  Summary:
    Revision    Changes     Path
    1.1.2.8     +17 -22     rpm/rpmio/rpmjs17.cpp
    1.1.2.8     +1  -8      rpm/rpmio/rpmjs185.cpp
    1.1.2.9     +46 -36     rpm/rpmio/rpmjs24.cpp
    1.1.2.9     +43 -32     rpm/rpmio/rpmjs31.cpp
    1.1.2.9     +37 -25     rpm/rpmio/rpmjs38.cpp
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs17.cpp
  ============================================================================
  $ cvs diff -u -r1.1.2.7 -r1.1.2.8 rpmjs17.cpp
  --- rpm/rpmio/rpmjs17.cpp     24 Jun 2017 20:32:04 -0000      1.1.2.7
  +++ rpm/rpmio/rpmjs17.cpp     24 Jun 2017 23:46:21 -0000      1.1.2.8
  @@ -28,9 +28,9 @@
   
   static int rpmjss_nopens;
   
  -static int _rpmjss17_debug;
  +int _rpmjss_debug;
   #define SPEW(_fmt, ...) \
  -    if (_rpmjss17_debug) \
  +    if (_rpmjss_debug) \
        fprintf(stderr, _fmt, __VA_ARGS__)
   
   /*==============================================================*/
  @@ -465,13 +465,13 @@
       JS_SetVersion(I->cx, JSVERSION_LATEST);
       JS_SetErrorReporter(I->cx, rpmjssReportError);
   
  -    JS::RootedObject global(I->cx,
  +    JS::RootedObject glob(I->cx,
                JS_NewGlobalObject(I->cx, _clasp, _principals));
  -    I->global = global;
  +    I->global = glob;
   assert(I->global);
       JS_SetGlobalObject(I->cx, I->global);
   
  -    ok = JS_InitStandardClasses(I->cx, global);
  +    ok = JS_InitStandardClasses(I->cx, I->global);
   assert(ok);
   #ifdef  JS_HAS_CTYPES
       ok = JS_InitCTypesClass(I->cx, I->global);
  @@ -489,17 +489,12 @@
   {
       JSI_t I = (JSI_t) jss->I;
   
  -    JSBool ok;
  -
  -    // In practice, you would want to exit this any
  -    // time you're spinning the event loop
  -    JSAutoRequest ar(I->cx);
  -
  +    JS::RootedObject glob(I->cx, I->global);
       JS::RootedValue rval(I->cx);
       {        // Scope for JSAutoCompartment
  -     JSAutoCompartment ac(I->cx, I->global);
  +     JSAutoCompartment ac(I->cx, glob);
   
  -     ok = JS_EvaluateScript(I->cx, I->global,
  +     JSBool ok = JS_EvaluateScript(I->cx, glob,
                        script, strlen(script), fn, ln,
                        rval.address());
        if (!ok)
  @@ -510,29 +505,29 @@
       size_t nb = sizeof(b);
       char * t = NULL;
   
  -    if (JSVAL_IS_NULL(rval)) {
  +    if (rval.isNull()) {
        t = xstrdup("");
       } else
  -    if (JSVAL_IS_VOID(rval)) {
  +    if (rval.isUndefined()) {
        t = xstrdup("");
       } else
  -    if (JSVAL_IS_BOOLEAN(rval)) {
  +    if (rval.isBoolean()) {
        snprintf(b, nb, "%c", (rval.toBoolean() ? 'T' : 'F'));
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_INT(rval)) {        /* int32_t */
  +    if (rval.isInt32()) {
        snprintf(b, nb, "%d", rval.toInt32());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_DOUBLE(rval)) {
  +    if (rval.isDouble()) {
        snprintf(b, nb, "%.16g", rval.toDouble());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_NUMBER(rval)) {
  +    if (rval.isNumber()) {
        snprintf(b, nb, "%.16g", rval.toNumber());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_STRING(rval)) {
  +    if (rval.isString()) {
        t = JS_EncodeString(I->cx, rval.toString());
       } else
        t = xstrdup("");
  @@ -545,8 +540,8 @@
       return 0;
   }
   
  -static struct JSIO_s _mozjs17 = { mozFini, mozInit, mozRun };
  -JSIO_t mozjs17 = &_mozjs17;
  +static struct JSIO_s _mozjs = { mozFini, mozInit, mozRun };
  +JSIO_t mozjs17 = &_mozjs;
   
   #if defined(RPMJSS_SELF_TEST)
   #include <rpmio.h>
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs185.cpp
  ============================================================================
  $ cvs diff -u -r1.1.2.7 -r1.1.2.8 rpmjs185.cpp
  --- rpm/rpmio/rpmjs185.cpp    24 Jun 2017 20:47:34 -0000      1.1.2.7
  +++ rpm/rpmio/rpmjs185.cpp    24 Jun 2017 23:46:21 -0000      1.1.2.8
  @@ -471,13 +471,6 @@
   {
       JSI_t I = (JSI_t) jss->I;
   
  -    JSClass * _clasp = (JSClass *)&global_class;
  -#ifdef       NOTYET
  -    JSFunctionSpec * _functions = global_functions;
  -#endif
  -    JSPrincipals * _principals = NULL;
  -    JSBool ok;
  -
       jsval rval;
       {        // Scope for JSAutoCompartment
   
  @@ -487,7 +480,7 @@
            return 1;
   #endif
   
  -     ok = JS_EvaluateScript(I->cx, I->global,
  +     JSBool ok = JS_EvaluateScript(I->cx, I->global,
                        script, strlen(script), fn, ln,
                        &rval);
        if (!ok)
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs24.cpp
  ============================================================================
  $ cvs diff -u -r1.1.2.8 -r1.1.2.9 rpmjs24.cpp
  --- rpm/rpmio/rpmjs24.cpp     24 Jun 2017 20:32:04 -0000      1.1.2.8
  +++ rpm/rpmio/rpmjs24.cpp     24 Jun 2017 23:46:21 -0000      1.1.2.9
  @@ -26,13 +26,11 @@
       JS_ConvertStub,
   };
   
  -#define      JS_Init()
  -
   static int rpmjss_nopens;
   
  -static int _rpmjss24_debug;
  +int _rpmjss_debug;
   #define SPEW(_fmt, ...) \
  -    if (_rpmjss24_debug) \
  +    if (_rpmjss_debug) \
        fprintf(stderr, _fmt, __VA_ARGS__)
   
   /*==============================================================*/
  @@ -78,9 +76,18 @@
   
       static uint32_t _maxbytes = 8L * 1024L * 1024L;
       static size_t _stackChunkSize = 8192;
  +    JSClass * _clasp = (JSClass *)&global_class;
  +#ifdef       NOTYET
  +    const JSFunctionSpec * _functions = global_functions;
  +#endif
  +    JSPrincipals * _principals = NULL;
  +    JSBool ok;
   
  -    if (rpmjss_nopens++ == 0)
  +    if (rpmjss_nopens++ == 0) {
  +#ifdef       NOTYET          /* XXX collides with ancient JS_NewRuntime */
        JS_Init();
  +#endif
  +    }
   
       I = (JSI_t) calloc(1, sizeof(*I));
   assert(I);
  @@ -100,6 +107,28 @@
   #endif
       JS_SetErrorReporter(I->cx, rpmjssReportError);
   
  +    { 
  +     JS::RootedObject glob(I->cx,
  +             JS_NewGlobalObject(I->cx, _clasp, _principals));
  +     I->global = glob;
  +assert(I->global);
  +     JS_SetGlobalObject(I->cx, I->global);
  +
  +     {
  +         JSAutoCompartment ac(I->cx, I->global);
  +         ok = JS_InitStandardClasses(I->cx, glob);
  +assert(ok);
  +#ifdef JS_HAS_CTYPES
  +         ok = JS_InitCTypesClass(cx, glob);
  +assert(ok);
  +#endif
  +#ifdef       NOTYET
  +         ok = JS_DefineFunctions(I->cx, glob, _functions);
  +assert(ok);
  +#endif
  +     }
  +    }
  +
       return I;
   }
   
  @@ -108,31 +137,12 @@
   {
       JSI_t I = (JSI_t) jss->I;
   
  -    JSClass * _clasp = (JSClass *)&global_class;
  -#ifdef       NOTYET
  -    JSFunctionSpec * _functions = global_functions;
  -#endif
  -    JSPrincipals * _principals = NULL;
  -    JSBool ok;
  -
  -    // In practice, you would want to exit this any
  -    // time you're spinning the event loop
  -    JSAutoRequest ar(I->cx);
  -
  -    JS::RootedObject global(I->cx,
  -             JS_NewGlobalObject(I->cx, _clasp, _principals));
  -    if (!global)
  -     return 1;
  -    I->global = global;
  -assert(I->global);
  -    JS_SetGlobalObject(I->cx, I->global);
  -
  +    JS::RootedObject glob(I->cx, I->global);
       JS::RootedValue rval(I->cx);
       {        // Scope for JSAutoCompartment
  -     JSAutoCompartment ac(I->cx, global);
  -     JS_InitStandardClasses(I->cx, global);
  +     JSAutoCompartment ac(I->cx, glob);
   
  -     ok = JS_EvaluateScript(I->cx, global,
  +     JSBool ok = JS_EvaluateScript(I->cx, glob,
                        script, strlen(script), fn, ln,
                        rval.address());
        if (!ok)
  @@ -143,29 +153,29 @@
       size_t nb = sizeof(b);
       char * t = NULL;
   
  -    if (JSVAL_IS_NULL(rval)) {
  +    if (rval.isNull()) {
        t = xstrdup("");
       } else
  -    if (JSVAL_IS_VOID(rval)) {
  +    if (rval.isUndefined()) {
        t = xstrdup("");
       } else
  -    if (JSVAL_IS_BOOLEAN(rval)) {
  +    if (rval.isBoolean()) {
        snprintf(b, nb, "%c", (rval.toBoolean() ? 'T' : 'F'));
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_INT(rval)) {        /* int32_t */
  +    if (rval.isInt32()) {
        snprintf(b, nb, "%d", rval.toInt32());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_DOUBLE(rval)) {
  +    if (rval.isDouble()) {
        snprintf(b, nb, "%.16g", rval.toDouble());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_NUMBER(rval)) {
  +    if (rval.isNumber()) {
        snprintf(b, nb, "%.16g", rval.toNumber());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_STRING(rval)) {
  +    if (rval.isString()) {
        t = JS_EncodeString(I->cx, rval.toString());
       } else
        t = xstrdup("");
  @@ -178,8 +188,8 @@
       return 0;
   }
   
  -static struct JSIO_s _mozjs24 = { mozFini, mozInit, mozRun };
  -JSIO_t mozjs24 = &_mozjs24;
  +static struct JSIO_s _mozjs = { mozFini, mozInit, mozRun };
  +JSIO_t mozjs24 = &_mozjs;
   
   #if defined(RPMJSS_SELF_TEST)
   #include <rpmio.h>
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs31.cpp
  ============================================================================
  $ cvs diff -u -r1.1.2.8 -r1.1.2.9 rpmjs31.cpp
  --- rpm/rpmio/rpmjs31.cpp     24 Jun 2017 20:32:04 -0000      1.1.2.8
  +++ rpm/rpmio/rpmjs31.cpp     24 Jun 2017 23:46:21 -0000      1.1.2.9
  @@ -33,9 +33,9 @@
   
   static int rpmjss_nopens;
   
  -static int _rpmjs31_debug;
  +int rpmjss_debug;
   #define SPEW(_fmt, ...) \
  -    if (_rpmjss31_debug) \
  +    if (_rpmjss_debug) \
        fprintf(stderr, _fmt, __VA_ARGS__)
   
   /*==============================================================*/
  @@ -81,6 +81,12 @@
   
       static uint32_t _maxbytes = 8L * 1024L * 1024L;
       static size_t _stackChunkSize = 8192;
  +    JSClass * _clasp = (JSClass *)&global_class;
  +#ifdef       NOTYET
  +    const JSFunctionSpec * _functions = global_functions;
  +#endif
  +    JSPrincipals * _principals = NULL;
  +    bool ok;
   
       if (rpmjss_nopens++ == 0)
        JS_Init();
  @@ -98,6 +104,29 @@
   
       JS_SetErrorReporter(I->cx, rpmjssReportError);
   
  +    { 
  +     JS::CompartmentOptions options;
  +     options.setVersion(JSVERSION_DEFAULT);
  +     JS::RootedObject glob(I->cx,
  +             JS_NewGlobalObject(I->cx, _clasp, _principals, 
JS::DontFireOnNewGlobalHook, options));
  +     I->global = glob;
  +assert(I->global);
  +     {
  +         JSAutoCompartment ac(I->cx, I->global);
  +         ok = JS_InitStandardClasses(I->cx, glob);
  +assert(ok);
  +#ifdef JS_HAS_CTYPES
  +         ok = JS_InitCTypesClass(cx, glob);
  +assert(ok);
  +#endif
  +#ifdef       NOTYET
  +         ok = JS_DefineFunctions(I->cx, glob, _functions);
  +assert(ok);
  +#endif
  +     }
  +     JS_FireOnNewGlobalObject(I->cx, glob);
  +    }
  +
       return I;
   }
   
  @@ -106,30 +135,12 @@
   {
       JSI_t I = (JSI_t) jss->I;
   
  -    JSClass * _clasp = (JSClass *)&global_class;
  -#ifdef       NOTYET
  -    JSFunctionSpec * _functions = global_functions;
  -#endif
  -    JSPrincipals * _principals = NULL;
  -    bool ok;
  -
  -    // In practice, you would want to exit this any
  -    // time you're spinning the event loop
  -    JSAutoRequest ar(I->cx);
  -
  -    JS::RootedObject global(I->cx,
  -             JS_NewGlobalObject(I->cx, _clasp, _principals, 
JS::FireOnNewGlobalHook));
  -    if (!global)
  -     return 1;
  -    I->global = global;
  -assert(I->global);
  -
  +    JS::RootedObject glob(I->cx, I->global);
       JS::RootedValue rval(I->cx);
       {        // Scope for JSAutoCompartment
  -     JSAutoCompartment ac(I->cx, global);
  -     JS_InitStandardClasses(I->cx, global);
  +     JSAutoCompartment ac(I->cx, glob);
   
  -     ok = JS_EvaluateScript(I->cx, global,
  +     bool ok = JS_EvaluateScript(I->cx, glob,
                        script, strlen(script), fn, ln,
                        &rval);
        if (!ok)
  @@ -140,29 +151,29 @@
       size_t nb = sizeof(b);
       char * t = NULL;
   
  -    if (JSVAL_IS_NULL(rval)) {
  +    if (rval.isNull()) {
        t = xstrdup("");
       } else
  -    if (JSVAL_IS_VOID(rval)) {
  +    if (rval.isUndefined()) {
        t = xstrdup("");
       } else
  -    if (JSVAL_IS_BOOLEAN(rval)) {
  +    if (rval.isBoolean()) {
        snprintf(b, nb, "%c", (rval.toBoolean() ? 'T' : 'F'));
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_INT(rval)) {        /* int32_t */
  +    if (rval.isInt32()) {
        snprintf(b, nb, "%d", rval.toInt32());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_DOUBLE(rval)) {
  +    if (rval.isDouble()) {
        snprintf(b, nb, "%.16g", rval.toDouble());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_NUMBER(rval)) {
  +    if (rval.isNumber()) {
        snprintf(b, nb, "%.16g", rval.toNumber());
        t = xstrdup(b);
       } else
  -    if (JSVAL_IS_STRING(rval)) {
  +    if (rval.isString()) {
        t = JS_EncodeString(I->cx, rval.toString());
       } else
        t = xstrdup("");
  @@ -175,8 +186,8 @@
       return 0;
   }
   
  -static struct JSIO_s _mozjs31 = { mozFini, mozInit, mozRun };
  -JSIO_t mozjs31 = &_mozjs31;
  +static struct JSIO_s _mozjs = { mozFini, mozInit, mozRun };
  +JSIO_t mozjs31 = &_mozjs;
   
   #if defined(RPMJSS_SELF_TEST)
   #include <rpmio.h>
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs38.cpp
  ============================================================================
  $ cvs diff -u -r1.1.2.8 -r1.1.2.9 rpmjs38.cpp
  --- rpm/rpmio/rpmjs38.cpp     24 Jun 2017 20:32:04 -0000      1.1.2.8
  +++ rpm/rpmio/rpmjs38.cpp     24 Jun 2017 23:46:21 -0000      1.1.2.9
  @@ -33,9 +33,9 @@
   
   static int rpmjss_nopens;
   
  -static int _rpmjss38_debug;
  +int _rpmjss_debug;
   #define SPEW(_fmt, ...) \
  -    if (_rpmjss38_debug) \
  +    if (_rpmjss_debug) \
        fprintf(stderr, _fmt, __VA_ARGS__)
   
   /*==============================================================*/
  @@ -81,6 +81,12 @@
   
       static uint32_t _maxbytes = 8L * 1024L * 1024L;
       static size_t _stackChunkSize = 8192;
  +    JSClass * _clasp = (JSClass *)&global_class;
  +#ifdef       NOTYET
  +    const JSFunctionSpec * _functions = global_functions;
  +#endif
  +    JSPrincipals * _principals = NULL;
  +    bool ok;
   
       if (rpmjss_nopens++ == 0)
        JS_Init();
  @@ -98,6 +104,29 @@
   
       JS_SetErrorReporter(I->rt, rpmjssReportError);
   
  +    { 
  +        JS::CompartmentOptions options;
  +     options.setVersion(JSVERSION_DEFAULT);
  +     JS::RootedObject glob(I->cx,
  +             JS_NewGlobalObject(I->cx, _clasp, _principals, 
JS::DontFireOnNewGlobalHook, options));
  +     I->global = glob;
  +assert(I->global);
  +     {
  +         JSAutoCompartment ac(I->cx, I->global);
  +         ok = JS_InitStandardClasses(I->cx, glob);
  +assert(ok);
  +#ifdef JS_HAS_CTYPES
  +         ok = JS_InitCTypesClass(cx, glob);
  +assert(ok);
  +#endif
  +#ifdef       NOTYET
  +         ok = JS_DefineFunctions(I->cx, glob, _functions);
  +assert(ok);
  +#endif
  +     }
  +     JS_FireOnNewGlobalObject(I->cx, glob);
  +    }
  +
       return I;
   }
   
  @@ -106,32 +135,15 @@
   {
       JSI_t I = (JSI_t) jss->I;
   
  -    JSClass * _clasp = (JSClass *)&global_class;
  -#ifdef       NOTYET
  -    JSFunctionSpec * _functions = global_functions;
  -#endif
  -    JSPrincipals * _principals = NULL;
  -    bool ok;
  -
  -    // In practice, you would want to exit this any
  -    // time you're spinning the event loop
  -    JSAutoRequest ar(I->cx);
  -
  -    JS::RootedObject global(I->cx,
  -             JS_NewGlobalObject(I->cx, _clasp, _principals, 
JS::FireOnNewGlobalHook));
  -    if (!global)
  -     return 1;
  -    I->global = global;
  -assert(I->global);
  -
  +    JS::RootedObject glob(I->cx, I->global);
       JS::RootedValue rval(I->cx);
       {        // Scope for JSAutoCompartment
  -     JSAutoCompartment ac(I->cx, global);
  -     JS_InitStandardClasses(I->cx, global);
  +     JSAutoCompartment ac(I->cx, glob);
   
        JS::CompileOptions opts(I->cx);
        opts.setFileAndLine(fn, ln);
  -     ok = JS::Evaluate(I->cx, global, opts, script, strlen(script), &rval);
  +
  +     bool ok = JS::Evaluate(I->cx, glob, opts, script, strlen(script), 
&rval);
        if (!ok)
            return 1;
       }
  @@ -175,8 +187,8 @@
       return 0;
   }
   
  -static struct JSIO_s _mozjs38 = { mozFini, mozInit, mozRun };
  -JSIO_t mozjs38 = &_mozjs38;
  +static struct JSIO_s _mozjs = { mozFini, mozInit, mozRun };
  +JSIO_t mozjs38 = &_mozjs;
   
   #if defined(RPMJSS_SELF_TEST)
   #include <rpmio.h>
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to