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:   22-Jun-2017 19:03:52
  Branch: rpm-5_4                          Handle: 2017062217035200

  Added files:              (Branch: rpm-5_4)
    rpm/rpmio               rpmjs17.cpp rpmjs185.cpp

  Log:
    - create.

  Summary:
    Revision    Changes     Path
    1.1.2.1     +94 -0      rpm/rpmio/rpmjs17.cpp
    1.1.2.1     +95 -0      rpm/rpmio/rpmjs185.cpp
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs17.cpp
  ============================================================================
  $ cvs diff -u -r0 -r1.1.2.1 rpmjs17.cpp
  --- /dev/null 2017-06-22 19:02:36.000000000 +0200
  +++ rpmjs17.cpp       2017-06-22 19:03:52.944363065 +0200
  @@ -0,0 +1,94 @@
  +/* 
  + * This define is for Windows only, it is a work-around for bug 661663. 
  + */  
  +#ifdef _MSC_VER  
  +# define XP_WIN  
  +#endif  
  +  
  +/* Include the JSAPI header file to get access to SpiderMonkey. */  
  +#include "jsapi.h"  
  +  
  +/* The class of the global object. */  
  +static JSClass global_class = {  
  +    "global", JSCLASS_GLOBAL_FLAGS,  
  +    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, 
JS_StrictPropertyStub,  
  +    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub,
  +};  
  +  
  +/* The error reporter callback. */  
  +void reportError(JSContext *cx, const char *message, JSErrorReport *report)  
  +{  
  +    fprintf(stderr, "%s:%u:%s\n",  
  +            report->filename ? report->filename : "<no 
filename=\"filename\">",  
  +            (unsigned int) report->lineno,  
  +            message);  
  +}  
  +  
  +int main(int argc, const char *argv[])  
  +{  
  +    /* JSAPI variables. */  
  +    JSRuntime *rt;  
  +    JSContext *cx;  
  +  
  +    static uint32_t _maxbytes = 8L * 1024L * 1024L;
  +    static size_t _stackChunkSize = 8192;
  +
  +    /* Create a JS runtime. You always need at least one runtime per 
process. */  
  +    rt = JS_NewRuntime(_maxbytes);  
  +    if (rt == NULL)  
  +        return 1;  
  +  
  +    /*  
  +     * Create a context. You always need a context per thread. 
  +     * Note that this program is not multi-threaded. 
  +     */  
  +    cx = JS_NewContext(rt, _stackChunkSize);  
  +    if (cx == NULL)  
  +        return 1;  
  +
  +    /* 
  +     * Create the global object in a new compartment. 
  +     * You always need a global object per context. 
  +     */  
  +    JS::RootedObject global(cx,
  +             JS_NewGlobalObject(cx, &global_class, NULL));
  +    if (global == NULL)  
  +        return 1;  
  +  
  +    /* 
  +     * Populate the global object with the standard JavaScript 
  +     * function and object classes, such as Object, Array, Date. 
  +     */  
  +    if (!JS_InitStandardClasses(cx, global))  
  +        return 1;  
  +  
  +    /* Your application code here. This may include JSAPI calls 
  +     * to create your own custom JavaScript objects and to run scripts. 
  +     * 
  +     * The following example code creates a literal JavaScript script, 
  +     * evaluates it, and prints the result to stdout. 
  +     * 
  +     * Errors are conventionally saved in a JSBool variable named ok. 
  +     */  
  +    const char *script = "'hello'+'world, it is '+new Date()";
  +    jsval rval;  
  +    JSBool ok;  
  +    const char *filename = "noname";  
  +    unsigned lineno = 0;  
  +  
  +    ok = JS_EvaluateScript(cx, global, script, strlen(script),  
  +                           filename, lineno, &rval);  
  +    if (!ok)
  +        return 1;  
  +  
  +    JSString * str = JS_ValueToString(cx, rval);  
  +    printf("%s\n", JS_EncodeString(cx, str));  
  +  
  +    /* End of your application code */  
  +  
  +    /* Clean things up and shut down SpiderMonkey. */  
  +    JS_DestroyContext(cx);  
  +    JS_DestroyRuntime(rt);  
  +    JS_ShutDown();  
  +    return 0;  
  +}
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/rpmjs185.cpp
  ============================================================================
  $ cvs diff -u -r0 -r1.1.2.1 rpmjs185.cpp
  --- /dev/null 2017-06-22 19:02:36.000000000 +0200
  +++ rpmjs185.cpp      2017-06-22 19:03:52.934363235 +0200
  @@ -0,0 +1,95 @@
  +/* 
  + * This define is for Windows only, it is a work-around for bug 661663. 
  + */  
  +#ifdef _MSC_VER  
  +# define XP_WIN  
  +#endif  
  +  
  +/* Include the JSAPI header file to get access to SpiderMonkey. */  
  +#include "jsapi.h"  
  +  
  +/* The class of the global object. */  
  +static JSClass global_class = {  
  +    "global", JSCLASS_GLOBAL_FLAGS,  
  +    JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, 
JS_StrictPropertyStub,  
  +    JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,  
  +    JSCLASS_NO_OPTIONAL_MEMBERS  
  +};  
  +  
  +/* The error reporter callback. */  
  +void reportError(JSContext *cx, const char *message, JSErrorReport *report)  
  +{  
  +    fprintf(stderr, "%s:%u:%s\n",  
  +            report->filename ? report->filename : "<no 
filename=\"filename\">",  
  +            (unsigned int) report->lineno,  
  +            message);  
  +}  
  +  
  +int main(int argc, const char *argv[])  
  +{  
  +    /* JSAPI variables. */  
  +    JSRuntime *rt;  
  +    JSContext *cx;  
  +    JSObject  *global;  
  +  
  +    /* Create a JS runtime. You always need at least one runtime per 
process. */  
  +    rt = JS_NewRuntime(8 * 1024 * 1024);  
  +    if (rt == NULL)  
  +        return 1;  
  +  
  +    /*  
  +     * Create a context. You always need a context per thread. 
  +     * Note that this program is not multi-threaded. 
  +     */  
  +    cx = JS_NewContext(rt, 8192);  
  +    if (cx == NULL)  
  +        return 1;  
  +    JS_SetOptions(cx, JSOPTION_VAROBJFIX | JSOPTION_JIT | 
JSOPTION_METHODJIT);  
  +    JS_SetVersion(cx, JSVERSION_LATEST);  
  +    JS_SetErrorReporter(cx, reportError);  
  +  
  +    /* 
  +     * Create the global object in a new compartment. 
  +     * You always need a global object per context. 
  +     */  
  +    global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL);  
  +    if (global == NULL)  
  +        return 1;  
  +  
  +    /* 
  +     * Populate the global object with the standard JavaScript 
  +     * function and object classes, such as Object, Array, Date. 
  +     */  
  +    if (!JS_InitStandardClasses(cx, global))  
  +        return 1;  
  +  
  +    /* Your application code here. This may include JSAPI calls 
  +     * to create your own custom JavaScript objects and to run scripts. 
  +     * 
  +     * The following example code creates a literal JavaScript script, 
  +     * evaluates it, and prints the result to stdout. 
  +     * 
  +     * Errors are conventionally saved in a JSBool variable named ok. 
  +     */  
  +    const char *script = "'hello'+'world, it is '+new Date()";
  +    jsval rval;  
  +    JSBool ok;  
  +    const char *filename = "noname";  
  +    uintN lineno = 0;  
  +  
  +    ok = JS_EvaluateScript(cx, global, script, strlen(script),  
  +                           filename, lineno, &rval);  
  +    if (!ok)
  +        return 1;  
  +  
  +    JSString * str = JS_ValueToString(cx, rval);  
  +    printf("%s\n", JS_EncodeString(cx, str));  
  +  
  +    /* End of your application code */  
  +  
  +    /* Clean things up and shut down SpiderMonkey. */  
  +    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