#include <sstream>
#include <cmath>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/un.h>
+
#include "Parser.hpp"
#include "Cycript.tab.hh"
return iconv(cd, const_cast<Type_>(inbuf), inbytesleft, outbuf, outbytesleft);
}
-static CYUTF8String CYPoolUTF8String(apr_pool_t *pool, JSContextRef context, JSStringRef value) {
+CYUTF8String CYPoolUTF8String(apr_pool_t *pool, JSContextRef context, JSStringRef value) {
_assert(pool != NULL);
CYUTF16String utf16(CYCastUTF16String(value));
{NULL, NULL, 0}
};
-static JSObjectRef (*$JSObjectMakeArray)(JSContextRef, size_t, const JSValueRef[], JSValueRef *);
+static JSObjectRef (*JSObjectMakeArray$)(JSContextRef, size_t, const JSValueRef[], JSValueRef *);
void CYSetArgs(int argc, const char *argv[]) {
JSContextRef context(CYGetJSContext());
args[i] = CYCastJSValue(context, argv[i]);
JSObjectRef array;
- if ($JSObjectMakeArray != NULL) {
+ if (JSObjectMakeArray$ != NULL) {
JSValueRef exception(NULL);
- array = (*$JSObjectMakeArray)(context, argc, args, &exception);
+ array = (*JSObjectMakeArray$)(context, argc, args, &exception);
CYThrow(context, exception);
} else {
JSValueRef value(CYCallAsFunction(context, Array_, NULL, argc, args));
_aprcall(apr_pool_create(&Pool_, NULL));
_sqlcall(sqlite3_open("/usr/lib/libcycript.db", &Bridge_));
- $JSObjectMakeArray = reinterpret_cast<JSObjectRef (*)(JSContextRef, size_t, const JSValueRef[], JSValueRef *)>(dlsym(RTLD_DEFAULT, "JSObjectMakeArray"));
+ JSObjectMakeArray$ = reinterpret_cast<JSObjectRef (*)(JSContextRef, size_t, const JSValueRef[], JSValueRef *)>(dlsym(RTLD_DEFAULT, "JSObjectMakeArray"));
}
apr_pool_t *CYGetGlobalPool() {
CYThrow(context, exception);
}
-void CYObjectiveC(JSContextRef context, JSObjectRef global);
-
JSGlobalContextRef CYGetJSContext() {
CYInitialize();
Result_ = JSStringCreateWithUTF8CString("_");
-// XXX: this is very wrong and sad
-#ifdef __APPLE__
- CYObjectiveC(context, global);
-#endif
+ if (hooks_ != NULL && hooks_->SetupContext != NULL)
+ (*hooks_->SetupContext)(context);
}
return Context_;