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:   21-Jun-2017 19:26:25
  Branch: rpm-5_4                          Handle: 2017062117262400

  Added files:              (Branch: rpm-5_4)
    rpm/rpmio               rpmjs24.cpp rpmjs31.cpp rpmjs38.cpp rpmjs45.cpp
  Modified files:           (Branch: rpm-5_4)
    rpm/rpmio               Makefile.am

  Log:
    - rpmjs: stub-in mozjsXY example embeddings.

  Summary:
    Revision    Changes     Path
    1.293.2.94  +24 -0      rpm/rpmio/Makefile.am
    1.1.2.1     +61 -0      rpm/rpmio/rpmjs24.cpp
    1.1.2.1     +68 -0      rpm/rpmio/rpmjs31.cpp
    1.1.2.1     +70 -0      rpm/rpmio/rpmjs38.cpp
    1.1.2.1     +71 -0      rpm/rpmio/rpmjs45.cpp
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.293.2.93 -r1.293.2.94 Makefile.am
  --- rpm/rpmio/Makefile.am     20 Jun 2017 02:57:33 -0000      1.293.2.93
  +++ rpm/rpmio/Makefile.am     21 Jun 2017 17:26:24 -0000      1.293.2.94
  @@ -18,6 +18,7 @@
        getdate.y html-parse.c html-parse.h libsqlio.c \
        rpmcpio.c rpmcpio.h rpmgenbasedir.c rpmgenpkglist.c rpmgensrclist.c \
        rpmjsio.msg rpmtar.c rpmtar.h \
  +     rpmjs24.cpp rpmjs31.cpp rpmjs38.cpp rpmjs45.cpp \
        tdir.c teio.c tfts.c tget.c tgfs.c tgit.c tglob.c thkp.c thtml.c \
        tinv.c tkey.c tmire.c tmq.c tmqtt.c todbc.c tput.c tpython.c trpmio.c \
        tsexp.c tsvn.c tsw.c lookup3.c duktape.c tjsmn.c tjson.c yajl.c \
  @@ -31,6 +32,7 @@
   EXTRA_PROGRAMS += bsdiff bspatch fanotify pcrsed rpmborg rpmcurl \
        rpmgenbasedir rpmgenpkglist rpmgensrclist rpmgpg \
        rpmpbzip2 rpmpigz rpmzstd \
  +     rpmjs24 rpmjs31 rpmjs38 rpmjs45 \
        tasn tbf tcap tder tdir teio tfts tget tglob thkp tmagic tmire \
        tmount todbc toid tperl tpython tput trpmio tsexp tsvn tsw ttcl \
        dumpasn1 lookup3 trel twitter github tmicrojson
  @@ -548,6 +550,28 @@
   rpmgpg_SOURCES = rpmgpg.c
   rpmgpg_LDADD = $(RPMIO_LDADD_COMMON)
   
  +rpmjs24_SOURCES = rpmjs24.cpp
  +rpmjs24_CPPFLAGS = -include /usr/include/mozjs-24/js/RequiredDefines.h 
-I/usr/include/mozjs-24 -fPIC
  +rpmjs24_LDADD = -L/usr/lib64 -lmozjs-24
  +
  +rpmjs31_SOURCES = rpmjs31.cpp
  +rpmjs31_CPPFLAGS = -include /usr/include/mozjs-31/js/RequiredDefines.h 
-I/usr/include/mozjs-31 -fPIC
  +rpmjs31_LDADD = -L/usr/lib64 -lmozjs-31
  +
  +rpmjs38_SOURCES = rpmjs38.cpp
  +rpmjs38_CPPFLAGS = -include /usr/include/mozjs-38/js/RequiredDefines.h 
-I/usr/include/mozjs-38 -fPIC
  +rpmjs38_LDADD = -L/usr/lib64 -lmozjs-38
  +
  +rpmjs45_SOURCES = rpmjs45.cpp
  +rpmjs45_CPPFLAGS = -include /usr/include/mozjs-45/js/RequiredDefines.h 
-I/usr/include/mozjs-45 -fPIC
  +rpmjs45_LDADD = -L/usr/lib64 -lmozjs-45
  +
  +mozjs:       rpmjs24 rpmjs31 rpmjs38 rpmjs45
  +     -./rpmjs24
  +     -./rpmjs31
  +     -./rpmjs38
  +     -./rpmjs45
  +
   rpmpbzip2_SOURCES = rpmpbzip2.c
   rpmpbzip2_LDADD = $(RPMIO_LDADD_COMMON)
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs24.cpp
  ============================================================================
  $ cvs diff -u -r0 -r1.1.2.1 rpmjs24.cpp
  --- /dev/null 2017-06-21 19:22:00.000000000 +0200
  +++ rpmjs24.cpp       2017-06-21 19:26:24.894224457 +0200
  @@ -0,0 +1,61 @@
  +// following code might be needed in some case
  +// #define __STDC_LIMIT_MACROS
  +// #include <stdint.h>
  +#include "jsapi.h"
  +
  +/* The class of the global object. */
  +static JSClass global_class = {
  +    "global",
  +    JSCLASS_GLOBAL_FLAGS,
  +    JS_PropertyStub,
  +    JS_DeletePropertyStub,
  +    JS_PropertyStub,
  +    JS_StrictPropertyStub,
  +    JS_EnumerateStub,
  +    JS_ResolveStub,
  +    JS_ConvertStub,
  +};
  +
  +int main(int argc, const char *argv[])
  +{
  +    JSRuntime *rt = JS_NewRuntime(8L * 1024 * 1024, JS_USE_HELPER_THREADS);
  +    if (!rt)
  +        return 1;
  +
  +    JSContext *cx = JS_NewContext(rt, 8192);
  +    if (!cx)
  +        return 1;
  +
  +    { // Scope for our various stack objects (JSAutoRequest, RootedObject), 
so they all go
  +      // out of scope before we JS_DestroyContext.
  +
  +      JSAutoRequest ar(cx); // In practice, you would want to exit this any
  +                            // time you're spinning the event loop
  +
  +      JS::RootedObject global(cx, JS_NewGlobalObject(cx, &global_class, 
nullptr));
  +      if (!global)
  +          return 1;
  +
  +      JS::RootedValue rval(cx);
  +
  +      { // Scope for JSAutoCompartment
  +        JSAutoCompartment ac(cx, global);
  +        JS_InitStandardClasses(cx, global);
  +
  +        const char *script = "'hello'+'world, it is '+new Date()";
  +        const char *filename = "noname";
  +        int lineno = 1;
  +        bool ok = JS_EvaluateScript(cx, global, script, strlen(script), 
filename, lineno, rval.address());
  +        if (!ok)
  +          return 1;
  +      }
  +
  +      JSString *str = rval.toString();
  +      printf("%s\n", JS_EncodeString(cx, str));
  +    }
  +
  +    JS_DestroyContext(cx);
  +    JS_DestroyRuntime(rt);
  +    JS_ShutDown();
  +    return 0;
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs31.cpp
  ============================================================================
  $ cvs diff -u -r0 -r1.1.2.1 rpmjs31.cpp
  --- /dev/null 2017-06-21 19:22:00.000000000 +0200
  +++ rpmjs31.cpp       2017-06-21 19:26:24.903224388 +0200
  @@ -0,0 +1,68 @@
  +// following code might be needed in some case
  +// #define __STDC_LIMIT_MACROS
  +// #include <stdint.h>
  +#include "jsapi.h"
  +
  +/* The class of the global object. */
  +static JSClass global_class = {
  +    "global",
  +    JSCLASS_GLOBAL_FLAGS,
  +    JS_PropertyStub,
  +    JS_DeletePropertyStub,
  +    JS_PropertyStub,
  +    JS_StrictPropertyStub,
  +    JS_EnumerateStub,
  +    JS_ResolveStub,
  +    JS_ConvertStub,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    JS_GlobalObjectTraceHook
  +};
  +
  +int main(int argc, const char *argv[])
  +{
  +    JS_Init();
  +
  +    JSRuntime *rt = JS_NewRuntime(8L * 1024 * 1024, JS_USE_HELPER_THREADS);
  +    if (!rt)
  +        return 1;
  +
  +    JSContext *cx = JS_NewContext(rt, 8192);
  +    if (!cx)
  +        return 1;
  +
  +    { // Scope for our various stack objects (JSAutoRequest, RootedObject), 
so they all go
  +      // out of scope before we JS_DestroyContext.
  +
  +      JSAutoRequest ar(cx); // In practice, you would want to exit this any
  +                            // time you're spinning the event loop
  +
  +      JS::RootedObject global(cx, JS_NewGlobalObject(cx, &global_class, 
nullptr, JS::FireOnNewGlobalHook));
  +      if (!global)
  +          return 1;
  +
  +      JS::RootedValue rval(cx);
  +
  +      { // Scope for JSAutoCompartment
  +        JSAutoCompartment ac(cx, global);
  +        JS_InitStandardClasses(cx, global);
  +
  +        const char *script = "'hello'+'world, it is '+new Date()";
  +        const char *filename = "noname";
  +        int lineno = 1;
  +        bool ok = JS_EvaluateScript(cx, global, script, strlen(script), 
filename, lineno, &rval);
  +        if (!ok)
  +          return 1;
  +      }
  +
  +      JSString *str = rval.toString();
  +      printf("%s\n", JS_EncodeString(cx, str));
  +    }
  +
  +    JS_DestroyContext(cx);
  +    JS_DestroyRuntime(rt);
  +    JS_ShutDown();
  +    return 0;
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs38.cpp
  ============================================================================
  $ cvs diff -u -r0 -r1.1.2.1 rpmjs38.cpp
  --- /dev/null 2017-06-21 19:22:00.000000000 +0200
  +++ rpmjs38.cpp       2017-06-21 19:26:24.913224341 +0200
  @@ -0,0 +1,70 @@
  +// following code might be needed in some case
  +// #define __STDC_LIMIT_MACROS
  +// #include <stdint.h>
  +#include "jsapi.h"
  +
  +/* The class of the global object. */
  +static JSClass global_class = {
  +    "global",
  +    JSCLASS_GLOBAL_FLAGS,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    JS_GlobalObjectTraceHook
  +};
  +
  +int main(int argc, const char *argv[])
  +{
  +    JS_Init();
  +
  +    JSRuntime *rt = JS_NewRuntime(8L * 1024 * 1024);
  +    if (!rt)
  +        return 1;
  +
  +    JSContext *cx = JS_NewContext(rt, 8192);
  +    if (!cx)
  +        return 1;
  +
  +    { // Scope for our various stack objects (JSAutoRequest, RootedObject), 
so they all go
  +      // out of scope before we JS_DestroyContext.
  +
  +      JSAutoRequest ar(cx); // In practice, you would want to exit this any
  +                            // time you're spinning the event loop
  +
  +      JS::RootedObject global(cx, JS_NewGlobalObject(cx, &global_class, 
nullptr, JS::FireOnNewGlobalHook));
  +      if (!global)
  +          return 1;
  +
  +      JS::RootedValue rval(cx);
  +
  +      { // Scope for JSAutoCompartment
  +        JSAutoCompartment ac(cx, global);
  +        JS_InitStandardClasses(cx, global);
  +
  +        const char *script = "'hello'+'world, it is '+new Date()";
  +        const char *filename = "noname";
  +        int lineno = 1;
  +        JS::CompileOptions opts(cx);
  +        opts.setFileAndLine(filename, lineno);
  +        bool ok = JS::Evaluate(cx, global, opts, script, strlen(script), 
&rval);
  +        if (!ok)
  +          return 1;
  +      }
  +
  +      JSString *str = rval.toString();
  +      printf("%s\n", JS_EncodeString(cx, str));
  +    }
  +
  +    JS_DestroyContext(cx);
  +    JS_DestroyRuntime(rt);
  +    JS_ShutDown();
  +    return 0;
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs45.cpp
  ============================================================================
  $ cvs diff -u -r0 -r1.1.2.1 rpmjs45.cpp
  --- /dev/null 2017-06-21 19:22:00.000000000 +0200
  +++ rpmjs45.cpp       2017-06-21 19:26:24.922224505 +0200
  @@ -0,0 +1,71 @@
  +// following code might be needed in some case
  +// #define __STDC_LIMIT_MACROS
  +// #include <stdint.h>
  +#include "jsapi.h"
  +#include "js/Initialization.h"
  +
  +/* The class of the global object. */
  +static JSClass global_class = {
  +    "global",
  +    JSCLASS_GLOBAL_FLAGS,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    nullptr,
  +    JS_GlobalObjectTraceHook
  +};
  +
  +int main(int argc, const char *argv[])
  +{
  +    JS_Init();
  +
  +    JSRuntime *rt = JS_NewRuntime(8L * 1024 * 1024);
  +    if (!rt)
  +        return 1;
  +
  +    JSContext *cx = JS_NewContext(rt, 8192);
  +    if (!cx)
  +        return 1;
  +
  +    { // Scope for our various stack objects (JSAutoRequest, RootedObject), 
so they all go
  +      // out of scope before we JS_DestroyContext.
  +
  +      JSAutoRequest ar(cx); // In practice, you would want to exit this any
  +                            // time you're spinning the event loop
  +
  +      JS::RootedObject global(cx, JS_NewGlobalObject(cx, &global_class, 
nullptr, JS::FireOnNewGlobalHook));
  +      if (!global)
  +          return 1;
  +
  +      JS::RootedValue rval(cx);
  +
  +      { // Scope for JSAutoCompartment
  +        JSAutoCompartment ac(cx, global);
  +        JS_InitStandardClasses(cx, global);
  +
  +        const char *script = "'hello'+'world, it is '+new Date()";
  +        const char *filename = "noname";
  +        int lineno = 1;
  +        JS::CompileOptions opts(cx);
  +        opts.setFileAndLine(filename, lineno);
  +        bool ok = JS::Evaluate(cx, opts, script, strlen(script), &rval);
  +        if (!ok)
  +          return 1;
  +      }
  +
  +      JSString *str = rval.toString();
  +      printf("%s\n", JS_EncodeString(cx, str));
  +    }
  +
  +    JS_DestroyContext(cx);
  +    JS_DestroyRuntime(rt);
  +    JS_ShutDown();
  +    return 0;
  +}
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to