couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [27/27] couchdb commit: updated refs/heads/1843-feature-bigcouch to 465d1ad
Date Mon, 03 Feb 2014 13:00:06 GMT
Build couchjs

We've dropped all but SpiderMonkey 1.8.5 support for this release.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/465d1ad7
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/465d1ad7
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/465d1ad7

Branch: refs/heads/1843-feature-bigcouch
Commit: 465d1ad737045aabc98f23ca36b501ef84a331ad
Parents: ed4a876
Author: Robert Newson <rnewson@apache.org>
Authored: Thu Jan 30 18:50:18 2014 +0000
Committer: Robert Newson <rnewson@apache.org>
Committed: Mon Feb 3 12:55:28 2014 +0000

----------------------------------------------------------------------
 .gitignore                      |   3 +
 src/couch/priv/couch_js/sm170.c | 398 ----------------------------------
 src/couch/priv/couch_js/sm180.c | 407 -----------------------------------
 src/couch/rebar.config          |  11 -
 src/couch/rebar.config.script   |  69 ++++++
 5 files changed, 72 insertions(+), 816 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/465d1ad7/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index e15b210..09b14d6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,6 @@ rel/logs
 # eclipse
 .project
 /.pydevproject
+
+share/server/main-coffee.js
+share/server/main.js

http://git-wip-us.apache.org/repos/asf/couchdb/blob/465d1ad7/src/couch/priv/couch_js/sm170.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/sm170.c b/src/couch/priv/couch_js/sm170.c
deleted file mode 100644
index 4a18d8f..0000000
--- a/src/couch/priv/couch_js/sm170.c
+++ /dev/null
@@ -1,398 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <jsapi.h>
-#include "http.h"
-#include "utf8.h"
-#include "util.h"
-
-
-#ifdef JS_THREADSAFE
-#define SETUP_REQUEST(cx) \
-    JS_SetContextThread(cx); \
-    JS_BeginRequest(cx);
-#define FINISH_REQUEST(cx) \
-    JS_EndRequest(cx); \
-    JS_ClearContextThread(cx);
-#else
-#define SETUP_REQUEST(cx)
-#define FINISH_REQUEST(cx)
-#endif
-
-
-static JSBool
-req_ctor(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    return http_ctor(cx, obj);
-}
-
-
-static void 
-req_dtor(JSContext* cx, JSObject* obj)
-{
-    http_dtor(cx, obj);
-}
-
-
-static JSBool
-req_open(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    JSBool ret = JS_FALSE;
-
-    if(argc == 2) {
-        ret = http_open(cx, obj, argv[0], argv[1], JSVAL_FALSE);
-    } else if(argc == 3) {
-        ret = http_open(cx, obj, argv[0], argv[1], argv[2]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.open");
-    }
-
-    *rval = JSVAL_VOID;
-    return ret;
-}
-
-
-static JSBool
-req_set_hdr(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    JSBool ret = JS_FALSE;
-    if(argc == 2) {
-        ret = http_set_hdr(cx, obj, argv[0], argv[1]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.set_header");
-    }
-
-    *rval = JSVAL_VOID;
-    return ret;
-}
-
-
-static JSBool
-req_send(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    JSBool ret = JS_FALSE;
-    if(argc == 1) {
-        ret = http_send(cx, obj, argv[0]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.send");
-    }
-
-    *rval = JSVAL_VOID;
-    return ret;
-}
-
-
-static JSBool
-req_status(JSContext* cx, JSObject* obj, jsval idval, jsval* rval)
-{
-    int status = http_status(cx, obj);
-    if(status < 0)
-        return JS_FALSE;
-
-    if(INT_FITS_IN_JSVAL(status)) {
-        *rval = INT_TO_JSVAL(status);
-        return JS_TRUE;
-    } else {
-        JS_ReportError(cx, "Invalid HTTP status.");
-        return JS_FALSE;
-    }
-}
-
-
-static JSBool
-base_url(JSContext *cx, JSObject* obj, jsval idval, jsval* rval)
-{
-    couch_args *args = (couch_args*)JS_GetContextPrivate(cx);
-    return http_uri(cx, obj, args, rval);
-}
-
-
-static JSBool
-evalcx(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
-{
-    JSString *str;
-    JSObject *sandbox;
-    JSContext *subcx;
-    const jschar *src;
-    size_t srclen;
-    JSBool ret = JS_FALSE;
-    char *name = NULL;
-
-    sandbox = NULL;
-    if(!JS_ConvertArguments(cx, argc, argv, "S / o", &str, &sandbox)) {
-        return JS_FALSE;
-    }
-
-    subcx = JS_NewContext(JS_GetRuntime(cx), 8L * 1024L);
-    if(!subcx) {
-        JS_ReportOutOfMemory(cx);
-        return JS_FALSE;
-    }
-
-    SETUP_REQUEST(subcx);
-
-    src = JS_GetStringChars(str);
-    srclen = JS_GetStringLength(str);
-
-    if(!sandbox) {
-        sandbox = JS_NewObject(subcx, NULL, NULL, NULL);
-        if(!sandbox || !JS_InitStandardClasses(subcx, sandbox)) {
-            goto done;
-        }
-    }
-
-    if(argc > 2) {
-      name = enc_string(cx, argv[2], NULL);
-    }
-
-    if(srclen == 0) {
-        *rval = OBJECT_TO_JSVAL(sandbox);
-    } else {
-        JS_EvaluateUCScript(subcx, sandbox, src, srclen, name, 1, rval);
-    }
-    
-    ret = JS_TRUE;
-
-done:
-    if(name) JS_free(cx, name);
-    FINISH_REQUEST(subcx);
-    JS_DestroyContext(subcx);
-    return ret;
-}
-
-
-static JSBool
-gc(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    JS_GC(cx);
-    *rval = JSVAL_VOID;
-    return JS_TRUE;
-}
-
-
-static JSBool
-print(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    couch_print(cx, argc, argv);
-    *rval = JSVAL_VOID;
-    return JS_TRUE;
-}
-
-
-static JSBool
-quit(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    int exit_code = 0;
-    JS_ConvertArguments(cx, argc, argv, "/i", &exit_code);
-    exit(exit_code);
-}
-
-
-static JSBool
-readline(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    JSString* line;
-
-    /* GC Occasionally */
-    JS_MaybeGC(cx);
-
-    line = couch_readline(cx, stdin);
-    if(line == NULL) return JS_FALSE;
-
-    *rval = STRING_TO_JSVAL(line);
-    return JS_TRUE;
-}
-
-
-static JSBool
-seal(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    JSObject *target;
-    JSBool deep = JS_FALSE;
-
-    if(!JS_ConvertArguments(cx, argc, argv, "o/b", &target, &deep))
-        return JS_FALSE;
-
-    if(!target) {
-        *rval = JSVAL_VOID;
-        return JS_TRUE;
-    }
-
-    if(JS_SealObject(cx, target, deep) != JS_TRUE)
-        return JS_FALSE;
-
-    *rval = JSVAL_VOID;
-    return JS_TRUE;
-}
-
-
-JSClass CouchHTTPClass = {
-    "CouchHTTP",
-    JSCLASS_HAS_PRIVATE
-        | JSCLASS_CONSTRUCT_PROTOTYPE
-        | JSCLASS_HAS_RESERVED_SLOTS(2),
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub,
-    req_dtor,
-    JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-JSPropertySpec CouchHTTPProperties[] = {
-    {"status", 0, JSPROP_READONLY, req_status, NULL},
-    {"base_url", 0, JSPROP_READONLY | JSPROP_SHARED, base_url, NULL},
-    {0, 0, 0, 0, 0}
-};
-
-
-JSFunctionSpec CouchHTTPFunctions[] = {
-    {"_open", req_open, 3, 0, 0},
-    {"_setRequestHeader", req_set_hdr, 2, 0, 0},
-    {"_send", req_send, 1, 0, 0},
-    {0, 0, 0, 0, 0}
-};
-
-
-static JSClass global_class = {
-    "GlobalClass",
-    JSCLASS_GLOBAL_FLAGS,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub,
-    JS_FinalizeStub,
-    JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-static JSFunctionSpec global_functions[] = {
-    {"evalcx", evalcx, 0, 0, 0},
-    {"gc", gc, 0, 0, 0},
-    {"print", print, 0, 0, 0},
-    {"quit", quit, 0, 0, 0},
-    {"readline", readline, 0, 0, 0},
-    {"seal", seal, 0, 0, 0},
-    {0, 0, 0, 0, 0}
-};
-
-
-int
-main(int argc, const char* argv[])
-{
-    JSRuntime* rt = NULL;
-    JSContext* cx = NULL;
-    JSObject* global = NULL;
-    JSObject* klass = NULL;
-    JSScript* script;
-    JSString* scriptsrc;
-    jschar* schars;
-    size_t slen;
-    jsval sroot;
-    jsval result;
-    int i;
-
-    couch_args* args = couch_parse_args(argc, argv);
-    
-    rt = JS_NewRuntime(64L * 1024L * 1024L);
-    if(rt == NULL)
-        return 1;
-
-    cx = JS_NewContext(rt, args->stack_size);
-    if(cx == NULL)
-        return 1;
-
-    JS_SetErrorReporter(cx, couch_error);
-    JS_ToggleOptions(cx, JSOPTION_XML);
-    JS_SetContextPrivate(cx, args);
-    
-    SETUP_REQUEST(cx);
-
-    global = JS_NewObject(cx, &global_class, NULL, NULL);
-    if(global == NULL)
-        return 1;
-
-    JS_SetGlobalObject(cx, global);
-    
-    if(!JS_InitStandardClasses(cx, global))
-        return 1;
-
-    if(couch_load_funcs(cx, global, global_functions) != JS_TRUE)
-        return 1;
- 
-    if(args->use_http) {
-        http_check_enabled();
-
-        klass = JS_InitClass(
-            cx, global,
-            NULL,
-            &CouchHTTPClass, req_ctor,
-            0,
-            CouchHTTPProperties, CouchHTTPFunctions,
-            NULL, NULL
-        );
-
-        if(!klass)
-        {
-            fprintf(stderr, "Failed to initialize CouchHTTP class.\n");
-            exit(2);
-        }
-    } 
-
-    for (i = 0 ; args->scripts[i] ; i++) {
-        // Convert script source to jschars.
-        scriptsrc = couch_readfile(cx, args->scripts[i]);
-        if(!scriptsrc)
-            return 1;
-
-        schars = JS_GetStringChars(scriptsrc);
-        slen = JS_GetStringLength(scriptsrc);
-
-        // Root it so GC doesn't collect it.
-        sroot = STRING_TO_JSVAL(scriptsrc);
-        if(JS_AddRoot(cx, &sroot) != JS_TRUE) {
-            fprintf(stderr, "Internal root error.\n");
-            return 1;
-        }
-
-        // Compile and run
-        script = JS_CompileUCScript(cx, global, schars, slen,
-                                    args->scripts[i], 1);
-        if(!script) {
-            fprintf(stderr, "Failed to compile script.\n");
-            return 1;
-        }
-
-        JS_ExecuteScript(cx, global, script, &result);
-
-        // Warning message if we don't remove it.
-        JS_RemoveRoot(cx, &sroot);
-    }
-
-    FINISH_REQUEST(cx);
-    JS_DestroyContext(cx);
-    JS_DestroyRuntime(rt);
-    JS_ShutDown();
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/465d1ad7/src/couch/priv/couch_js/sm180.c
----------------------------------------------------------------------
diff --git a/src/couch/priv/couch_js/sm180.c b/src/couch/priv/couch_js/sm180.c
deleted file mode 100644
index 9ffd1df..0000000
--- a/src/couch/priv/couch_js/sm180.c
+++ /dev/null
@@ -1,407 +0,0 @@
-// Licensed under the Apache License, Version 2.0 (the "License"); you may not
-// use this file except in compliance with the License. You may obtain a copy of
-// the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations under
-// the License.
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <jsapi.h>
-#include "http.h"
-#include "utf8.h"
-#include "util.h"
-
-
-#define SETUP_REQUEST(cx) \
-    JS_SetContextThread(cx); \
-    JS_BeginRequest(cx);
-#define FINISH_REQUEST(cx) \
-    JS_EndRequest(cx); \
-    JS_ClearContextThread(cx);
-
-
-static JSBool
-req_ctor(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval)
-{
-    return http_ctor(cx, obj);
-}
-
-
-static void 
-req_dtor(JSContext* cx, JSObject* obj)
-{
-    http_dtor(cx, obj);
-}
-
-
-static JSBool
-req_open(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSObject* obj = JS_THIS_OBJECT(cx, vp);
-    jsval* argv = JS_ARGV(cx, vp);
-    JSBool ret = JS_FALSE;
-
-    if(argc == 2) {
-        ret = http_open(cx, obj, argv[0], argv[1], JSVAL_FALSE);
-    } else if(argc == 3) {
-        ret = http_open(cx, obj, argv[0], argv[1], argv[2]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.open");
-    }
-
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return ret;
-}
-
-
-static JSBool
-req_set_hdr(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSObject* obj = JS_THIS_OBJECT(cx, vp);
-    jsval* argv = JS_ARGV(cx, vp);
-    JSBool ret = JS_FALSE;
-
-    if(argc == 2) {
-        ret = http_set_hdr(cx, obj, argv[0], argv[1]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.set_header");
-    }
-
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return ret;
-}
-
-
-static JSBool
-req_send(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSObject* obj = JS_THIS_OBJECT(cx, vp);
-    jsval* argv = JS_ARGV(cx, vp);
-    JSBool ret = JS_FALSE;
-
-    if(argc == 1) {
-        ret = http_send(cx, obj, argv[0]);
-    } else {
-        JS_ReportError(cx, "Invalid call to CouchHTTP.send");
-    }
-
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return ret;
-}
-
-
-static JSBool
-req_status(JSContext* cx, JSObject* obj, jsval idval, jsval* vp)
-{
-    int status = http_status(cx, obj);
-    if(status < 0)
-        return JS_FALSE;
-
-    if(INT_FITS_IN_JSVAL(status)) {
-        JS_SET_RVAL(cx, vp, INT_TO_JSVAL(status));
-        return JS_TRUE;
-    } else {
-        JS_ReportError(cx, "Invalid HTTP status.");
-        return JS_FALSE;
-    }
-}
-
-
-static JSBool
-base_url(JSContext *cx, JSObject* obj, jsid pid, jsval* vp)
-{
-    couch_args *args = (couch_args*)JS_GetContextPrivate(cx);
-    return http_uri(cx, obj, args, &JS_RVAL(cx, vp));
-}
-
-
-static JSBool
-evalcx(JSContext *cx, uintN argc, jsval* vp)
-{
-    jsval* argv = JS_ARGV(cx, vp);
-    JSString *str;
-    JSObject *sandbox;
-    JSContext *subcx;
-    const jschar *src;
-    size_t srclen;
-    jsval rval;
-    JSBool ret = JS_FALSE;
-    char *name = NULL;
-
-    sandbox = NULL;
-    if(!JS_ConvertArguments(cx, argc, argv, "S / o", &str, &sandbox)) {
-        return JS_FALSE;
-    }
-
-    subcx = JS_NewContext(JS_GetRuntime(cx), 8L * 1024L);
-    if(!subcx) {
-        JS_ReportOutOfMemory(cx);
-        return JS_FALSE;
-    }
-
-    SETUP_REQUEST(subcx);
-
-    src = JS_GetStringChars(str);
-    srclen = JS_GetStringLength(str);
-
-    if(!sandbox) {
-        sandbox = JS_NewObject(subcx, NULL, NULL, NULL);
-        if(!sandbox || !JS_InitStandardClasses(subcx, sandbox)) {
-            goto done;
-        }
-    }
-
-    if(argc > 2) {
-      name = enc_string(cx, argv[2], NULL);
-    }
-
-    if(srclen == 0) {
-        JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(sandbox));
-    } else {
-        JS_EvaluateUCScript(subcx, sandbox, src, srclen, name, 1, &rval);
-        JS_SET_RVAL(cx, vp, rval);
-    }
-    
-    ret = JS_TRUE;
-
-done:
-    if(name) JS_free(cx, name);
-    FINISH_REQUEST(subcx);
-    JS_DestroyContext(subcx);
-    return ret;
-}
-
-
-static JSBool
-gc(JSContext* cx, uintN argc, jsval* vp)
-{
-    JS_GC(cx);
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return JS_TRUE;
-}
-
-
-static JSBool
-print(JSContext* cx, uintN argc, jsval* vp)
-{
-    jsval* argv = JS_ARGV(cx, vp);
-    couch_print(cx, argc, argv);
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return JS_TRUE;
-}
-
-
-static JSBool
-quit(JSContext* cx, uintN argc, jsval* vp)
-{
-    jsval* argv = JS_ARGV(cx, vp);
-    int exit_code = 0;
-    JS_ConvertArguments(cx, argc, argv, "/i", &exit_code);
-    exit(exit_code);
-}
-
-
-static JSBool
-readline(JSContext* cx, uintN argc, jsval* vp)
-{
-    JSString* line;
-
-    /* GC Occasionally */
-    JS_MaybeGC(cx);
-
-    line = couch_readline(cx, stdin);
-    if(line == NULL) return JS_FALSE;
-
-    JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(line));
-    return JS_TRUE;
-}
-
-
-static JSBool
-seal(JSContext* cx, uintN argc, jsval* vp)
-{
-    jsval* argv = JS_ARGV(cx, vp);
-    JSObject *target;
-    JSBool deep = JS_FALSE;
-
-    if(!JS_ConvertArguments(cx, argc, argv, "o/b", &target, &deep))
-        return JS_FALSE;
-
-    if(!target) {
-        JS_SET_RVAL(cx, vp, JSVAL_VOID);
-        return JS_TRUE;
-    }
-
-    if(JS_SealObject(cx, target, deep) != JS_TRUE)
-        return JS_FALSE;
-
-    JS_SET_RVAL(cx, vp, JSVAL_VOID);
-    return JS_TRUE;
-}
-
-
-JSClass CouchHTTPClass = {
-    "CouchHTTP",
-    JSCLASS_HAS_PRIVATE
-        | JSCLASS_CONSTRUCT_PROTOTYPE
-        | JSCLASS_HAS_RESERVED_SLOTS(2),
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub,
-    req_dtor,
-    JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-JSPropertySpec CouchHTTPProperties[] = {
-    {"status", 0, JSPROP_READONLY, req_status, NULL},
-    {"base_url", 0, JSPROP_READONLY | JSPROP_SHARED, base_url, NULL},
-    {0, 0, 0, 0, 0}
-};
-
-
-JSFunctionSpec CouchHTTPFunctions[] = {
-    JS_FS("_open", (JSNative) req_open, 3, JSFUN_FAST_NATIVE, 0),
-    JS_FS("_setRequestHeader", (JSNative) req_set_hdr, 2, JSFUN_FAST_NATIVE, 0),
-    JS_FS("_send", (JSNative) req_send, 1, JSFUN_FAST_NATIVE, 0),
-    JS_FS_END
-};
-
-
-static JSClass global_class = {
-    "GlobalClass",
-    JSCLASS_GLOBAL_FLAGS,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_PropertyStub,
-    JS_EnumerateStub,
-    JS_ResolveStub,
-    JS_ConvertStub,
-    JS_FinalizeStub,
-    JSCLASS_NO_OPTIONAL_MEMBERS
-};
-
-
-static JSFunctionSpec global_functions[] = {
-    JS_FS("evalcx", (JSNative) evalcx, 0, JSFUN_FAST_NATIVE, 0),
-    JS_FS("gc", (JSNative) gc, 0, JSFUN_FAST_NATIVE, 0),
-    JS_FS("print", (JSNative) print, 0, JSFUN_FAST_NATIVE, 0),
-    JS_FS("quit", (JSNative) quit, 0, JSFUN_FAST_NATIVE, 0),
-    JS_FS("readline", (JSNative) readline, 0, JSFUN_FAST_NATIVE, 0),
-    JS_FS("seal", (JSNative) seal, 0, JSFUN_FAST_NATIVE, 0),
-    JS_FS_END
-};
-
-
-int
-main(int argc, const char* argv[])
-{
-    JSRuntime* rt = NULL;
-    JSContext* cx = NULL;
-    JSObject* global = NULL;
-    JSObject* klass = NULL;
-    JSScript* script;
-    JSString* scriptsrc;
-    jschar* schars;
-    size_t slen;
-    jsval sroot;
-    jsval result;
-    int i;
-
-    couch_args* args = couch_parse_args(argc, argv);
-    
-    rt = JS_NewRuntime(64L * 1024L * 1024L);
-    if(rt == NULL)
-        return 1;
-
-    cx = JS_NewContext(rt, args->stack_size);
-    if(cx == NULL)
-        return 1;
-
-    JS_SetErrorReporter(cx, couch_error);
-    JS_ToggleOptions(cx, JSOPTION_XML);
-    JS_SetContextPrivate(cx, args);
-    
-    SETUP_REQUEST(cx);
-
-    global = JS_NewObject(cx, &global_class, NULL, NULL);
-    if(global == NULL)
-        return 1;
-
-    JS_SetGlobalObject(cx, global);
-    
-    if(!JS_InitStandardClasses(cx, global))
-        return 1;
-
-    if(couch_load_funcs(cx, global, global_functions) != JS_TRUE)
-        return 1;
- 
-    if(args->use_http) {
-        http_check_enabled();
-
-        klass = JS_InitClass(
-            cx, global,
-            NULL,
-            &CouchHTTPClass, req_ctor,
-            0,
-            CouchHTTPProperties, CouchHTTPFunctions,
-            NULL, NULL
-        );
-
-        if(!klass)
-        {
-            fprintf(stderr, "Failed to initialize CouchHTTP class.\n");
-            exit(2);
-        }
-    } 
-
-    for (i = 0 ; args->scripts[i] ; i++) {
-        // Convert script source to jschars.
-        scriptsrc = couch_readfile(cx, args->scripts[i]);
-        if(!scriptsrc)
-            return 1;
-
-        schars = JS_GetStringChars(scriptsrc);
-        slen = JS_GetStringLength(scriptsrc);
-
-        // Root it so GC doesn't collect it.
-        sroot = STRING_TO_JSVAL(scriptsrc);
-        if(JS_AddRoot(cx, &sroot) != JS_TRUE) {
-            fprintf(stderr, "Internal root error.\n");
-            return 1;
-        }
-
-        // Compile and run
-        script = JS_CompileUCScript(cx, global, schars, slen,
-                                    args->scripts[i], 1);
-        if(!script) {
-            fprintf(stderr, "Failed to compile script.\n");
-            return 1;
-        }
-
-        JS_ExecuteScript(cx, global, script, &result);
-
-        // Warning message if we don't remove it.
-        JS_RemoveRoot(cx, &sroot);
-    }
-
-    FINISH_REQUEST(cx);
-    JS_DestroyContext(cx);
-    JS_DestroyRuntime(rt);
-    JS_ShutDown();
-
-    return 0;
-}

http://git-wip-us.apache.org/repos/asf/couchdb/blob/465d1ad7/src/couch/rebar.config
----------------------------------------------------------------------
diff --git a/src/couch/rebar.config b/src/couch/rebar.config
deleted file mode 100644
index def6879..0000000
--- a/src/couch/rebar.config
+++ /dev/null
@@ -1,11 +0,0 @@
-{port_specs, [{"priv/couch_icu_driver.so", ["priv/icu_driver/couch_icu_driver.c"]}]}.
-
-{port_env, [
-  {"DRV_CFLAGS",  "$DRV_CFLAGS -DPIC -O2 -fno-common"},
-  {"DRV_LDFLAGS", "$DRV_LDFLAGS -lm -licuuc -licudata -licui18n -lpthread"},
-  {"linux", "DRV_LDFLAGS", "$DRV_LDFLAGS -lcrypt"},
-  {"freebsd", "DRV_CFLAGS", "$DRV_CFLAGS -I/usr/local/include"},
-  {"freebsd", "DRV_LDFLAGS", "$DRV_LDFLAGS -L/usr/local/lib"},
-  {"solaris", "DRV_CFLAGS", "$DRV_CFLAGS -I/opt/local/include"},
-  {"solaris", "DRV_LDFLAGS", "$DRV_LDFLAGS -L/opt/local/lib"}
-]}.

http://git-wip-us.apache.org/repos/asf/couchdb/blob/465d1ad7/src/couch/rebar.config.script
----------------------------------------------------------------------
diff --git a/src/couch/rebar.config.script b/src/couch/rebar.config.script
new file mode 100644
index 0000000..a0e1345
--- /dev/null
+++ b/src/couch/rebar.config.script
@@ -0,0 +1,69 @@
+%% Licensed under the Apache License, Version 2.0 (the "License"); you may not
+%% use this file except in compliance with the License. You may obtain a copy of
+%% the License at
+%%
+%%   http://www.apache.org/licenses/LICENSE-2.0
+%%
+%% Unless required by applicable law or agreed to in writing, software
+%% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+%% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+%% License for the specific language governing permissions and limitations under
+%% the License.
+
+%% declare values
+CouchJSName = case os:type() of
+    {win32, _} ->
+        "couchjs.exe";
+    _ ->
+        "couchjs"
+end,
+Version = string:strip(os:cmd("git describe"), right, $\n),
+
+%% build config.h
+ConfigH = [
+ {"SM185", ""},
+ {"HAVE_JS_GET_STRING_CHARS_AND_LENGTH", "1"},
+ {"JSSCRIPT_TYPE", "JSObject*"},
+ {"COUCHJS_NAME", "\"" ++ CouchJSName++ "\""},
+ {"PACKAGE", "\"apache-couchdb\""},
+ {"PACKAGE_BUGREPORT", "\"https://issues.apache.org/jira/browse/COUCHDB\""},
+ {"PACKAGE_NAME", "\"Apache CouchDB\""},
+ {"PACKAGE_STRING", "\"Apache CouchDB " ++ Version ++ "\""},
+ {"PACKAGE_VERSION", "\"" ++ Version ++ "\""}],
+ConfigSrc = [["#define ", K, " ", V, $\n] || {K, V} <- ConfigH],
+ok = file:write_file("priv/couch_js/config.h", ConfigSrc),
+
+%% compile-time parameters
+JSLIBS = "-lmozjs185",
+{CFLAGS0, LDFLAGS} = case os:type() of
+    {unix, darwin} ->
+        {"-DXP_UNIX -I/usr/local/include/js", JSLIBS};
+    {unix, linux} ->
+        {"-DXP_UNIX -I/usr/include/js", JSLIBS ++ " -lm"};
+    {unix, _} ->
+        {"-DXP_UNIX -I/usr/local/include/js", JSLIBS ++ " -lm"};
+    _ ->
+        {"-DXP_WIN -I/usr/include/js", JSLIBS}
+end,
+CFLAGS1 = CFLAGS0 ++ " -DWITHOUT_CURL",
+
+PortEnv = [
+    {"CFLAGS", "$CFLAGS -Wall -c -g -O2 " ++ CFLAGS1},
+    {"LDFLAGS", LDFLAGS}],
+
+CouchJSSpec = [{filename:join(["priv", CouchJSName]),
+                ["priv/couch_js/{help,http,main,utf8,util}.c"]}],
+SpawnSpec = [{"priv/couchspawnkillable", ["priv/spawnkillable/*.c"]}],
+
+PortSpecs = case os:type() of
+    {win32, _} ->
+        CouchJSSpec ++ SpawnSpec;
+    _ ->
+        {ok, _} = file:copy("priv/spawnkillable/couchspawnkillable.sh",
+                            "priv/couchspawnkillable"),
+        os:cmd("chmod +x priv/couchspawnkillable"),
+        CouchJSSpec
+end,
+
+[{port_env, PortEnv},
+ {port_specs, PortSpecs}].


Mime
View raw message