From 2892653821db515977146a160552209d7cd3cb6c Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 28 Oct 2009 03:39:54 +0000 Subject: [PATCH] Finally got this damned thing actually executing JavaScript on Linux. --- Darwin.mk | 2 +- Library.cpp | 12 ++++++++++++ Linux.mk | 2 ++ makefile | 4 ++-- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Darwin.mk b/Darwin.mk index c37e770..bbb6691 100644 --- a/Darwin.mk +++ b/Darwin.mk @@ -7,6 +7,6 @@ console += -framework Foundation library += -install_name /usr/lib/libcycript.$(dll) library += -framework Foundation -framework CFNetwork library += -framework JavaScriptCore -framework WebCore -library += -lsubstrate +library += -lsubstrate -liconv include ObjectiveC.mk diff --git a/Library.cpp b/Library.cpp index eba549a..80a17f7 100644 --- a/Library.cpp +++ b/Library.cpp @@ -146,7 +146,11 @@ static CYUTF8String CYPoolUTF8String(apr_pool_t *pool, JSContextRef context, JSS CYUTF16String utf16(CYCastUTF16String(value)); const char *in(reinterpret_cast(utf16.data)); +#ifdef __APPLE__ iconv_t conversion(_syscall(iconv_open("UTF-8", "UCS-2-INTERNAL"))); +#else + iconv_t conversion(_syscall(iconv_open("UTF-8", "UCS-2"))); +#endif size_t size(JSStringGetMaximumUTF8CStringSize(value)); char *out(new(pool) char[size]); @@ -1297,9 +1301,14 @@ void CYSetArgs(int argc, const char *argv[]) { JSValueRef args[argc]; for (int i(0); i != argc; ++i) args[i] = CYCastJSValue(context, argv[i]); +#ifdef __APPLE__ JSValueRef exception(NULL); JSObjectRef array(JSObjectMakeArray(context, argc, args, &exception)); CYThrow(context, exception); +#else + JSValueRef value(CYCallAsFunction(context, Array_, NULL, argc, args)); + JSObjectRef array(CYCastJSObject(context, value)); +#endif CYSetProperty(context, System_, CYJSString("args"), array); } @@ -1547,7 +1556,10 @@ JSGlobalContextRef CYGetJSContext() { Result_ = JSStringCreateWithUTF8CString("_"); +// XXX: this is very wrong and sad +#ifdef __APPLE__ CYObjectiveC(context, global); +#endif } return Context_; diff --git a/Linux.mk b/Linux.mk index 26b27ed..93e2e94 100644 --- a/Linux.mk +++ b/Linux.mk @@ -1,3 +1,5 @@ export PATH := /usr/local/bin:$(PATH) flags += -I/usr/include/webkit-1.0 +flags += -DCY_EXECUTE depends += libffi4 libreadline5 +library += -lwebkit-1.0 diff --git a/makefile b/makefile index 1ca4693..18cea08 100644 --- a/makefile +++ b/makefile @@ -30,7 +30,7 @@ filters := C #E4X ldid := true dll := so apr := $(shell apr-1-config --link-ld) -library := $(apr) -lffi -liconv -lsqlite3 +library := $(apr) -lffi -lsqlite3 console := $(apr) -lreadline depends := @@ -41,7 +41,7 @@ uname_p := $(shell uname -p) ifeq ($(filter ObjectiveC,$(filters)),) ifneq ($(shell which gnustep-config 2>/dev/null),) -include GNUstep.mk +#include GNUstep.mk endif endif -- 2.45.2