From 30ddc20c1c3efe4e1b090316c884fb885cea9024 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Thu, 1 Oct 2009 21:56:37 +0000 Subject: [PATCH] Change mind (again) and use tightly-coupled C++ API. --- Application.mm | 2 +- Library.mm | 8 ++++---- cycript.h => cycript.hpp | 16 +--------------- makefile | 4 ++-- 4 files changed, 8 insertions(+), 22 deletions(-) rename cycript.h => cycript.hpp (61%) 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.hpp similarity index 61% rename from cycript.h rename to cycript.hpp index 482d3f7..c1e6751 100644 --- a/cycript.h +++ b/cycript.hpp @@ -12,25 +12,11 @@ #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); -} +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 -- 2.45.2