From: Jay Freeman (saurik) Date: Thu, 1 Oct 2009 21:56:37 +0000 (+0000) Subject: Change mind (again) and use tightly-coupled C++ API. X-Git-Tag: v0.9.432~387 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/30ddc20c1c3efe4e1b090316c884fb885cea9024 Change mind (again) and use tightly-coupled C++ API. --- diff --git a/Application.mm b/Application.mm index 56a3cc1..c5c6936 100644 --- a/Application.mm +++ b/Application.mm @@ -1,7 +1,7 @@ #define _GNU_SOURCE #include -#include "cycript.h" +#include "cycript.hpp" #include #include diff --git a/Library.mm b/Library.mm index b6b2f71..f56e14b 100644 --- a/Library.mm +++ b/Library.mm @@ -40,7 +40,7 @@ #define _GNU_SOURCE #include -#include "cycript.h" +#include "cycript.hpp" #include "sig/parse.hpp" #include "sig/ffi_type.hpp" @@ -261,7 +261,7 @@ JSObjectRef CYMakeObject(JSContextRef context, id object) { @end -extern "C" JSContextRef CYGetJSContext() { +JSContextRef CYGetJSContext() { return Context_; } @@ -394,7 +394,7 @@ JSValueRef CYCastJSValue(JSContextRef context, id value) { return value == nil ? JSValueMakeNull(context) : [value cy$JSValueInContext:context]; } -extern "C" void CYThrowNSError(JSContextRef context, id error, JSValueRef *exception) { +void CYThrow(JSContextRef context, id error, JSValueRef *exception) { *exception = CYCastJSValue(context, error); } @@ -469,7 +469,7 @@ extern "C" void CYThrowNSError(JSContextRef context, id error, JSValueRef *excep @end -extern "C" CFStringRef CYCopyJSONString(JSContextRef context, JSValueRef value) { +CFStringRef CYCopyJSONString(JSContextRef context, JSValueRef value) { id object(CYCastNSObject(context, value)); return reinterpret_cast([(object == nil ? @"null" : [object cy$toJSON]) retain]); } diff --git a/cycript.h b/cycript.h deleted file mode 100644 index 482d3f7..0000000 --- a/cycript.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef CYCRIPT_H -#define CYCRIPT_H - -#ifdef __OBJC__ -#include -#endif - -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -JSContextRef CYGetJSContext(); -CFStringRef CYCopyJSONString(JSContextRef context, JSValueRef value); - -#ifdef __OBJC__ -void CYThrowNSError(JSContextRef context, id error, JSValueRef *exception); -#endif - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -inline void CYThrow(JSContextRef context, id error, JSValueRef *exception) { - return CYThrowNSError(context, error, exception); -} -#endif - -#endif/*CYCRIPT_H*/ diff --git a/cycript.hpp b/cycript.hpp new file mode 100644 index 0000000..c1e6751 --- /dev/null +++ b/cycript.hpp @@ -0,0 +1,22 @@ +#ifndef CYCRIPT_H +#define CYCRIPT_H + +#ifdef __OBJC__ +#include +#endif + +#include +#include +#include +#include +#include +#include + +JSContextRef CYGetJSContext(); +CFStringRef CYCopyJSONString(JSContextRef context, JSValueRef value); + +#ifdef __OBJC__ +void CYThrow(JSContextRef context, id error, JSValueRef *exception); +#endif + +#endif/*CYCRIPT_H*/ diff --git a/makefile b/makefile index 791a071..d178765 100644 --- a/makefile +++ b/makefile @@ -50,10 +50,10 @@ lex.cy.o: lex.cy.c Cycript.tab.hh Parser.hpp Pooling.hpp Output.o: Output.cpp Parser.hpp Pooling.hpp $(target)g++ $(flags) -c -o $@ $< -Library.o: Library.mm Cycript.tab.hh Parser.hpp Pooling.hpp Struct.hpp cycript.h +Library.o: Library.mm Cycript.tab.hh Parser.hpp Pooling.hpp Struct.hpp cycript.hpp $(target)g++ $(flags) -c -o $@ $< -Application.o: Application.mm Cycript.tab.hh Parser.hpp Pooling.hpp cycript.h +Application.o: Application.mm Cycript.tab.hh Parser.hpp Pooling.hpp cycript.hpp $(target)g++ $(flags) -c -o $@ $< libcycript.dylib: ffi_type.o parse.o Output.o Cycript.tab.o lex.cy.o Library.o