From 7d8946475d60b27e2cc7ac03789ee06dd3653113 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Tue, 10 Sep 2013 21:15:11 -0700 Subject: [PATCH] Allow the type to be recovered from a Functor. --- .gitignore | 1 + Cycript.h | 35 +++++++++++++++++++++++++++++++++++ Execute.cpp | 12 ++++++++++++ xcode.mk | 22 ++++++++++++++++++++-- 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 Cycript.h diff --git a/.gitignore b/.gitignore index e1cc9b2..cc51ea0 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ readline-6.2 readline-6.2.tar.gz libffi.* build.* +Cycript.framework diff --git a/Cycript.h b/Cycript.h new file mode 100644 index 0000000..cdff446 --- /dev/null +++ b/Cycript.h @@ -0,0 +1,35 @@ +/* Cycript - Optimizing JavaScript Compiler/Runtime + * Copyright (C) 2009-2013 Jay Freeman (saurik) +*/ + +/* GNU General Public License, Version 3 {{{ */ +/* + * Cycript is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation, either version 3 of the License, + * or (at your option) any later version. + * + * Cycript is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Cycript. If not, see . +**/ +/* }}} */ + +#ifndef CYCRIPT_CYCRIPT_H +#define CYCRIPT_CYCRIPT_H + +#ifdef __cplusplus +extern "C" { +#endif + +void CYListenServer(short port); + +#ifdef __cplusplus +} +#endif + +#endif/*CYCRIPT_CYCRIPT_H*/ diff --git a/Execute.cpp b/Execute.cpp index 4c9e198..5fe0439 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -1188,6 +1188,12 @@ static JSValueRef Pointer_callAsFunction_toCYON(JSContextRef context, JSObjectRe } } CYCatch(NULL) } +static JSValueRef Functor_getProperty_type(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { + cy::Functor *internal(reinterpret_cast(JSObjectGetPrivate(object))); + CYPool pool; + return CYCastJSValue(context, Unparse(pool, &internal->signature_)); +} + static JSValueRef Type_getProperty_alignment(JSContextRef context, JSObjectRef object, JSStringRef property, JSValueRef *exception) { Type_privateData *internal(reinterpret_cast(JSObjectGetPrivate(object))); return CYCastJSValue(context, internal->GetFFI()->alignment); @@ -1247,6 +1253,11 @@ namespace cy { JSStaticFunction const * const Functor::StaticFunctions = Functor_staticFunctions; } +static JSStaticValue Functor_staticValues[2] = { + {"type", &Functor_getProperty_type, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, + {NULL, NULL, NULL, 0} +}; + static JSStaticValue Type_staticValues[4] = { {"alignment", &Type_getProperty_alignment, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, {"name", &Type_getProperty_name, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete}, @@ -1361,6 +1372,7 @@ void CYInitializeDynamic() { definition = kJSClassDefinitionEmpty; definition.className = "Functor"; definition.staticFunctions = cy::Functor::StaticFunctions; + definition.staticValues = Functor_staticValues; definition.callAsFunction = &Functor_callAsFunction; definition.finalize = &CYFinalize; Functor_ = JSClassCreate(&definition); diff --git a/xcode.mk b/xcode.mk index 0766d6f..d87951f 100644 --- a/xcode.mk +++ b/xcode.mk @@ -30,7 +30,17 @@ libs += .libs/libcycript-sys.dylib libs += .libs/libcycript-sim.dylib libs += .libs/libcycript.o -all: cycript $(libs) +framework := +framework += Cycript.framework/Cycript +framework += Cycript.framework/Headers/Cycript.h + +all: cycript $(libs) $(framework) + +cycript.zip: all + rm -f $@ + zip -r9y $@ .libs/cycript .libs/*.dylib Cycript.framework + +package: cycript.zip clean: rm -rf cycript .libs @@ -104,8 +114,16 @@ $(foreach arch,armv6,$(eval $(call build_arm,$(arch)))) .libs/libcycript.o: .libs/libcycript-ios-armv6.o .libs/libcycript-ios-armv7.o .libs/libcycript-ios-armv7s.o .libs/libcycript-sim-i386.o $(lipo) -create -output $@ $^ +Cycript.framework/Cycript: .libs/libcycript.o + @mkdir -p $(dir $@) + cp -a $< $@ + +Cycript.framework/Headers/Cycript.h: Cycript.h + @mkdir -p $(dir $@) + cp -a $< $@ + cycript: cycript.in cp -af $< $@ chmod 755 $@ -.PHONY: all clean +.PHONY: all clean package -- 2.47.2