From d9c911529b1480684bb8b6280410f2d09c8525a1 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Wed, 25 Nov 2015 21:49:01 -0800 Subject: [PATCH] Use -fvisibility=hidden to avoid slow symbol stub. --- Complete.cpp | 190 +++++++++++++++++++++++++++++++++++++ Console.cpp | 215 +++++------------------------------------- Driver.cpp | 16 ++++ Driver.hpp | 6 +- Error.hpp | 2 +- Exception.hpp | 2 +- Execute.cpp | 14 ++- Handler.cpp | 8 +- Highlight.cpp | 2 +- Library.cpp | 2 +- Makefile.am | 8 +- Makefile.in | 75 ++++++++------- Network.cpp | 4 +- ObjectiveC/Library.mm | 4 +- Standard.hpp | 5 + String.hpp | 1 - cycript.hpp | 5 +- xcode.map | 1 + 18 files changed, 309 insertions(+), 251 deletions(-) create mode 100644 Complete.cpp diff --git a/Complete.cpp b/Complete.cpp new file mode 100644 index 0000000..b378b60 --- /dev/null +++ b/Complete.cpp @@ -0,0 +1,190 @@ +/* Cycript - Optimizing JavaScript Compiler/Runtime + * Copyright (C) 2009-2015 Jay Freeman (saurik) +*/ + +/* GNU Affero General Public License, Version 3 {{{ */ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program 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 Affero General Public License for more details. + + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . +**/ +/* }}} */ + +#include "cycript.hpp" + +#include "Driver.hpp" +#include "Cycript.tab.hh" +#include "Replace.hpp" +#include "String.hpp" + +static CYExpression *ParseExpression(CYUTF8String code) { + std::stringstream stream; + stream << '(' << code << ')'; + CYDriver driver(stream); + + cy::parser parser(driver); + if (parser.parse() != 0 || !driver.errors_.empty()) + return NULL; + + CYOptions options; + CYContext context(options); + + CYStatement *statement(driver.program_->code_); + _assert(statement != NULL); + _assert(statement->next_ == NULL); + + CYExpress *express(dynamic_cast(driver.program_->code_)); + _assert(express != NULL); + + CYParenthetical *parenthetical(dynamic_cast(express->expression_)); + _assert(parenthetical != NULL); + + return parenthetical->expression_; +} + +_visible char **CYComplete(const char *word, const std::string &line, CYUTF8String (*run)(CYPool &pool, const std::string &)) { + CYLocalPool pool; + + std::istringstream stream(line); + CYDriver driver(stream); + + driver.auto_ = true; + + cy::parser parser(driver); + if (parser.parse() != 0 || !driver.errors_.empty()) + return NULL; + + if (driver.mode_ == CYDriver::AutoNone) + return NULL; + + CYExpression *expression; + + CYOptions options; + CYContext context(options); + + std::ostringstream prefix; + + switch (driver.mode_) { + case CYDriver::AutoPrimary: + expression = $ CYThis(); + break; + + case CYDriver::AutoDirect: + expression = driver.context_; + break; + + case CYDriver::AutoIndirect: + expression = $ CYIndirect(driver.context_); + break; + + case CYDriver::AutoMessage: { + CYDriver::Context &thing(driver.contexts_.back()); + expression = $M($C1($V("object_getClass"), thing.context_), $S("messages")); + for (CYDriver::Context::Words::const_iterator part(thing.words_.begin()); part != thing.words_.end(); ++part) + prefix << (*part)->word_ << ':'; + } break; + + default: + _assert(false); + } + + std::string begin(prefix.str()); + + driver.program_ = $ CYProgram($ CYExpress($C3(ParseExpression( + " function(object, prefix, word) {\n" + " var names = [];\n" + " var before = prefix.length;\n" + " prefix += word;\n" + " var entire = prefix.length;\n" + " for (var name in object)\n" + " if (name.substring(0, entire) == prefix)\n" + " names.push(name.substr(before));\n" + " return names;\n" + " }\n" + ), expression, $S(begin.c_str()), $S(word)))); + + driver.program_->Replace(context); + + std::stringbuf str; + CYOutput out(str, options); + out << *driver.program_; + + std::string code(str.str()); + CYUTF8String json(run(pool, code)); + // XXX: if this fails we should not try to parse it + + CYExpression *result(ParseExpression(json)); + if (result == NULL) + return NULL; + + CYArray *array(dynamic_cast(result->Primitive(context))); + if (array == NULL) + return NULL; + + // XXX: use an std::set? + typedef std::vector Completions; + Completions completions; + + std::string common; + bool rest(false); + + CYForEach (element, array->elements_) { + CYString *string(dynamic_cast(element->value_)); + _assert(string != NULL); + + std::string completion; + if (string->size_ != 0) + completion.assign(string->value_, string->size_); + else if (driver.mode_ == CYDriver::AutoMessage) + completion = "]"; + else + continue; + + completions.push_back(completion); + + if (!rest) { + common = completion; + rest = true; + } else { + size_t limit(completion.size()), size(common.size()); + if (size > limit) + common = common.substr(0, limit); + else + limit = size; + for (limit = 0; limit != size; ++limit) + if (common[limit] != completion[limit]) + break; + if (limit != size) + common = common.substr(0, limit); + } + } + + size_t count(completions.size()); + if (count == 0) + return NULL; + + size_t colon(common.find(':')); + if (colon != std::string::npos) + common = common.substr(0, colon + 1); + if (completions.size() == 1) + common += ' '; + + char **results(reinterpret_cast(malloc(sizeof(char *) * (count + 2)))); + + results[0] = strdup(common.c_str()); + size_t index(0); + for (Completions::const_iterator i(completions.begin()); i != completions.end(); ++i) + results[++index] = strdup(i->c_str()); + results[count + 1] = NULL; + + return results; +} diff --git a/Console.cpp b/Console.cpp index 3089edc..f57ecea 100644 --- a/Console.cpp +++ b/Console.cpp @@ -63,10 +63,9 @@ #include #include "Display.hpp" -#include "Replace.hpp" - -#include "Cycript.tab.hh" #include "Driver.hpp" +#include "Highlight.hpp" +#include "Replace.hpp" static volatile enum { Working, @@ -94,26 +93,21 @@ static void sigint(int) { } } -#if YYDEBUG static bool bison_; -#endif static bool strict_; static bool pretty_; -void Setup(CYDriver &driver, cy::parser &parser) { -#if YYDEBUG +void Setup(CYDriver &driver) { if (bison_) - parser.set_debug_level(1); -#endif + driver.debug_ = 1; if (strict_) driver.strict_ = true; } -void Setup(CYOutput &out, CYDriver &driver, CYOptions &options, bool lower) { +void Setup(CYPool &pool, CYOutput &out, CYDriver &driver, CYOptions &options, bool lower) { out.pretty_ = pretty_; - CYContext context(options); if (lower) - driver.program_->Replace(context); + driver.Replace(pool, options); } static CYUTF8String Run(CYPool &pool, int client, CYUTF8String code) { @@ -212,180 +206,16 @@ int (*append_history$)(int, const char *); static std::string command_; -static CYExpression *ParseExpression(CYUTF8String code) { - std::stringstream stream; - stream << '(' << code << ')'; - CYDriver driver(stream); - - cy::parser parser(driver); - Setup(driver, parser); - - if (parser.parse() != 0 || !driver.errors_.empty()) - return NULL; - - CYOptions options; - CYContext context(options); - - CYStatement *statement(driver.program_->code_); - _assert(statement != NULL); - _assert(statement->next_ == NULL); - - CYExpress *express(dynamic_cast(driver.program_->code_)); - _assert(express != NULL); - - CYParenthetical *parenthetical(dynamic_cast(express->expression_)); - _assert(parenthetical != NULL); +static int client_; - return parenthetical->expression_; +static CYUTF8String Run(CYPool &pool, const std::string &code) { + return Run(pool, client_, code); } -static int client_; - static char **Complete(const char *word, int start, int end) { rl_attempted_completion_over = ~0; - - CYLocalPool pool; - std::string line(rl_line_buffer, start); - std::istringstream stream(command_ + line); - CYDriver driver(stream); - - driver.auto_ = true; - - cy::parser parser(driver); - Setup(driver, parser); - - if (parser.parse() != 0 || !driver.errors_.empty()) - return NULL; - - if (driver.mode_ == CYDriver::AutoNone) - return NULL; - - CYExpression *expression; - - CYOptions options; - CYContext context(options); - - std::ostringstream prefix; - - switch (driver.mode_) { - case CYDriver::AutoPrimary: - expression = $ CYThis(); - break; - - case CYDriver::AutoDirect: - expression = driver.context_; - break; - - case CYDriver::AutoIndirect: - expression = $ CYIndirect(driver.context_); - break; - - case CYDriver::AutoMessage: { - CYDriver::Context &thing(driver.contexts_.back()); - expression = $M($C1($V("object_getClass"), thing.context_), $S("messages")); - for (CYDriver::Context::Words::const_iterator part(thing.words_.begin()); part != thing.words_.end(); ++part) - prefix << (*part)->word_ << ':'; - } break; - - default: - _assert(false); - } - - std::string begin(prefix.str()); - - driver.program_ = $ CYProgram($ CYExpress($C3(ParseExpression( - " function(object, prefix, word) {\n" - " var names = [];\n" - " var before = prefix.length;\n" - " prefix += word;\n" - " var entire = prefix.length;\n" - " for (var name in object)\n" - " if (name.substring(0, entire) == prefix)\n" - " names.push(name.substr(before));\n" - " return names;\n" - " }\n" - ), expression, $S(begin.c_str()), $S(word)))); - - driver.program_->Replace(context); - - std::stringbuf str; - CYOutput out(str, options); - out << *driver.program_; - - std::string code(str.str()); - CYUTF8String json(Run(pool, client_, code)); - // XXX: if this fails we should not try to parse it - - CYExpression *result(ParseExpression(json)); - if (result == NULL) - return NULL; - - CYArray *array(dynamic_cast(result->Primitive(context))); - if (array == NULL) { - *out_ << '\n'; - Output(false, json, out_); - rl_forced_update_display(); - return NULL; - } - - // XXX: use an std::set? - typedef std::vector Completions; - Completions completions; - - std::string common; - bool rest(false); - - CYForEach (element, array->elements_) { - CYString *string(dynamic_cast(element->value_)); - _assert(string != NULL); - - std::string completion; - if (string->size_ != 0) - completion.assign(string->value_, string->size_); - else if (driver.mode_ == CYDriver::AutoMessage) - completion = "]"; - else - continue; - - completions.push_back(completion); - - if (!rest) { - common = completion; - rest = true; - } else { - size_t limit(completion.size()), size(common.size()); - if (size > limit) - common = common.substr(0, limit); - else - limit = size; - for (limit = 0; limit != size; ++limit) - if (common[limit] != completion[limit]) - break; - if (limit != size) - common = common.substr(0, limit); - } - } - - size_t count(completions.size()); - if (count == 0) - return NULL; - - size_t colon(common.find(':')); - if (colon != std::string::npos) - common = common.substr(0, colon + 1); - if (completions.size() == 1) - common += ' '; - - char **results(reinterpret_cast(malloc(sizeof(char *) * (count + 2)))); - - results[0] = strdup(common.c_str()); - size_t index(0); - for (Completions::const_iterator i(completions.begin()); i != completions.end(); ++i) - results[++index] = strdup(i->c_str()); - results[count + 1] = NULL; - - return results; + return CYComplete(word, command_ + line, &Run); } // need char *, not const char * @@ -548,15 +378,14 @@ static void Console(CYOptions &options) { if (bypass) code = command_; else { - CYLocalPool pool; - std::istringstream stream(command_); CYDriver driver(stream); + Setup(driver); - cy::parser parser(driver); - Setup(driver, parser); + CYPool pool; + bool failed(driver.Parse(pool)); - if (parser.parse() != 0 || !driver.errors_.empty()) { + if (failed || !driver.errors_.empty()) { for (CYDriver::Errors::const_iterator error(driver.errors_.begin()); error != driver.errors_.end(); ++error) { CYPosition begin(error->location_.begin); if (begin.line != lines.size() + 1 || error->warning_) { @@ -595,7 +424,7 @@ static void Console(CYOptions &options) { std::stringbuf str; CYOutput out(str, options); - Setup(out, driver, options, lower); + Setup(pool, out, driver, options, lower); out << *driver.program_; code = str.str(); } @@ -689,10 +518,8 @@ int Main(int argc, char * const argv[], char const * const envp[]) { if (false); else if (strcmp(optarg, "rename") == 0) options.verbose_ = true; -#if YYDEBUG else if (strcmp(optarg, "bison") == 0) bison_ = true; -#endif else { fprintf(stderr, "invalid name for -g\n"); return 1; @@ -907,8 +734,6 @@ int Main(int argc, char * const argv[], char const * const envp[]) { if (script == NULL && tty) Console(options); else { - CYLocalPool pool; - std::istream *stream; if (script == NULL) { stream = &std::cin; @@ -919,16 +744,18 @@ int Main(int argc, char * const argv[], char const * const envp[]) { } CYDriver driver(*stream, script); - cy::parser parser(driver); - Setup(driver, parser); + Setup(driver); + + CYPool pool; + bool failed(driver.Parse(pool)); - if (parser.parse() != 0 || !driver.errors_.empty()) { + if (failed || !driver.errors_.empty()) { for (CYDriver::Errors::const_iterator i(driver.errors_.begin()); i != driver.errors_.end(); ++i) std::cerr << i->location_.begin << ": " << i->message_ << std::endl; } else if (driver.program_ != NULL) { std::stringbuf str; CYOutput out(str, options); - Setup(out, driver, options, true); + Setup(pool, out, driver, options, true); out << *driver.program_; std::string code(str.str()); if (compile) diff --git a/Driver.cpp b/Driver.cpp index 7e9c7ad..e529cbc 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -25,6 +25,7 @@ CYDriver::CYDriver(std::istream &data, const std::string &filename) : state_(CYClear), data_(data), + debug_(0), strict_(false), commented_(false), filename_(filename), @@ -42,6 +43,21 @@ CYDriver::~CYDriver() { ScannerDestroy(); } +bool CYDriver::Parse(CYPool &pool) { + CYLocal local(&pool); + cy::parser parser(*this); +#ifdef YYDEBUG + parser.set_debug_level(debug_); +#endif + return parser.parse() != 0; +} + +void CYDriver::Replace(CYPool &pool, CYOptions &options) { + CYLocal local(&pool); + CYContext context(options); + program_->Replace(context); +} + void CYDriver::Warning(const cy::parser::location_type &location, const char *message) { if (!strict_) return; diff --git a/Driver.hpp b/Driver.hpp index 5c330e7..cd39cfb 100644 --- a/Driver.hpp +++ b/Driver.hpp @@ -37,7 +37,7 @@ enum CYState { CYNewLine }; -class CYDriver { +class _visible CYDriver { public: void *scanner_; @@ -52,6 +52,7 @@ class CYDriver { std::istream &data_; + int debug_; bool strict_; bool commented_; @@ -109,6 +110,9 @@ class CYDriver { CYDriver(std::istream &data, const std::string &filename = ""); ~CYDriver(); + bool Parse(CYPool &pool); + void Replace(CYPool &pool, CYOptions &options); + Condition GetCondition(); void SetCondition(Condition condition); diff --git a/Error.hpp b/Error.hpp index 30cd052..4d899e0 100644 --- a/Error.hpp +++ b/Error.hpp @@ -45,7 +45,7 @@ struct CYJSError : }; #endif -struct CYPoolError : +struct _visible CYPoolError : CYException { CYPool pool_; diff --git a/Exception.hpp b/Exception.hpp index ff63b8c..994dd7b 100644 --- a/Exception.hpp +++ b/Exception.hpp @@ -35,7 +35,7 @@ class CYPool; -struct CYException { +struct _visible CYException { virtual ~CYException() { } diff --git a/Execute.cpp b/Execute.cpp index c871ef5..9f45354 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -368,7 +368,7 @@ static JSValueRef $cyq(JSContextRef context, JSObjectRef object, JSObjectRef _th static void (*JSSynchronousGarbageCollectForDebugging$)(JSContextRef); -void CYGarbageCollect(JSContextRef context) { +_visible void CYGarbageCollect(JSContextRef context) { (JSSynchronousGarbageCollectForDebugging$ ?: &JSGarbageCollect)(context); } @@ -1538,7 +1538,7 @@ static JSStaticFunction Type_staticFunctions[14] = { static JSObjectRef (*JSObjectMakeArray$)(JSContextRef, size_t, const JSValueRef[], JSValueRef *); -void CYSetArgs(int argc, const char *argv[]) { +_visible void CYSetArgs(int argc, const char *argv[]) { JSContextRef context(CYGetJSContext()); JSValueRef args[argc]; for (int i(0); i != argc; ++i) @@ -1596,7 +1596,7 @@ static bool CYShouldTerminate(JSContextRef context, void *arg) { return cancel_; } -const char *CYExecute(JSContextRef context, CYPool &pool, CYUTF8String code) { +_visible const char *CYExecute(JSContextRef context, CYPool &pool, CYUTF8String code) { JSValueRef exception(NULL); if (false) error: return CYPoolCString(pool, context, CYJSString(context, exception)); @@ -1624,7 +1624,7 @@ const char *CYExecute(JSContextRef context, CYPool &pool, CYUTF8String code) { return json; } -void CYCancel() { +_visible void CYCancel() { cancel_ = true; } @@ -1759,8 +1759,6 @@ JSGlobalContextRef CYGetJSContext(JSContextRef context) { return reinterpret_cast(JSObjectGetPrivate(CYCastJSObject(context, CYGetProperty(context, CYGetGlobalObject(context), cy_s))))->context_; } -extern "C" bool CydgetMemoryParse(const uint16_t **data, size_t *size); - void *CYMapFile(const char *path, size_t *psize) { int fd(_syscall_(open(path, O_RDONLY), 1, ENOENT)); if (fd == -1) @@ -1960,7 +1958,7 @@ extern "C" void CYSetupContext(JSGlobalContextRef context) { static JSGlobalContextRef context_; -JSGlobalContextRef CYGetJSContext() { +_visible JSGlobalContextRef CYGetJSContext() { CYInitializeDynamic(); if (context_ == NULL) { @@ -1971,7 +1969,7 @@ JSGlobalContextRef CYGetJSContext() { return context_; } -void CYDestroyContext() { +_visible void CYDestroyContext() { if (context_ == NULL) return; JSGlobalContextRelease(context_); diff --git a/Handler.cpp b/Handler.cpp index 30ea4f4..d048d83 100644 --- a/Handler.cpp +++ b/Handler.cpp @@ -153,7 +153,7 @@ static void *OnClient(void *data) { return NULL; } -extern "C" void CYHandleClient(int socket) { +void CYHandleClient(int socket) { // XXX: this leaks memory... really? CYPool *pool(new CYPool()); CYClient *client(new(*pool) CYClient(socket)); @@ -174,7 +174,7 @@ static void CYHandleSocket(const char *path) { CYHandleClient(socket); } -extern "C" void CYHandleServer(pid_t pid) { try { +_extern void CYHandleServer(pid_t pid) { try { char path[1024]; sprintf(path, "/tmp/.s.cy.%u", pid); CYHandleSocket(path); @@ -183,7 +183,7 @@ extern "C" void CYHandleServer(pid_t pid) { try { fprintf(stderr, "%s\n", error.PoolCString(pool)); } } -extern "C" char *MSmain0(int argc, char *argv[]) { try { +_extern char *MSmain0(int argc, char *argv[]) { try { _assert(argc == 2); CYHandleSocket(argv[1]); @@ -248,7 +248,7 @@ static void *OnServer(void *data) { return NULL; } -extern "C" void CYListenServer(short port) { +_extern void CYListenServer(short port) { CYInitializeDynamic(); CYServer *server(new CYServer(port)); diff --git a/Highlight.cpp b/Highlight.cpp index fd9cfe6..73814ec 100644 --- a/Highlight.cpp +++ b/Highlight.cpp @@ -55,7 +55,7 @@ struct CYColor { } }; -void CYLexerHighlight(const char *data, size_t size, std::ostream &output, bool ignore) { +_visible void CYLexerHighlight(const char *data, size_t size, std::ostream &output, bool ignore) { CYStream stream(data, data + size); CYDriver driver(stream); driver.commented_ = true; diff --git a/Library.cpp b/Library.cpp index 5c5c97d..b04f2ca 100644 --- a/Library.cpp +++ b/Library.cpp @@ -240,7 +240,7 @@ CYPool &CYGetGlobalPool() { return pool; } -void CYThrow(const char *format, ...) { +_visible void CYThrow(const char *format, ...) { va_list args; va_start(args, format); throw CYPoolError(format, args); diff --git a/Makefile.am b/Makefile.am index 8be16df..2cc8b2a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,12 @@ ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = -DYYDEBUG=1 AM_CPPFLAGS += -include config.h -include $(srcdir)/unconfig.h -AM_OBJCXXFLAGS = -fobjc-exceptions +AM_CFLAGS = -fvisibility=hidden +AM_CXXFLAGS = -fvisibility=hidden +AM_OBJCXXFLAGS = -fvisibility=hidden +AM_LDFLAGS = -fvisibility=hidden + +AM_OBJCXXFLAGS += -fobjc-exceptions CY_LDFLAGS = -no-undefined -avoid-version -export-dynamic @@ -47,6 +52,7 @@ if CY_CONSOLE bin_PROGRAMS = cycript cycript_SOURCES = Console.cpp Display.cpp cycript_LDADD = libcycript.la $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) $(PTHREAD_CFLAGS) -ldl +libcycript_la_SOURCES += Complete.cpp endif if CY_EXECUTE diff --git a/Makefile.in b/Makefile.in index d380f6c..399da56 100644 --- a/Makefile.in +++ b/Makefile.in @@ -109,22 +109,23 @@ POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ @CY_CONSOLE_TRUE@bin_PROGRAMS = cycript$(EXEEXT) -@CY_EXECUTE_TRUE@am__append_1 = sig/ffi_type.cpp sig/parse.cpp \ +@CY_CONSOLE_TRUE@am__append_1 = Complete.cpp +@CY_EXECUTE_TRUE@am__append_2 = sig/ffi_type.cpp sig/parse.cpp \ @CY_EXECUTE_TRUE@ sig/copy.cpp Bridge.cpp Execute.cpp \ @CY_EXECUTE_TRUE@ JavaScriptCore.cpp -@CY_EXECUTE_TRUE@am__append_2 = $(LTJAVASCRIPTCORE) -@CY_EXECUTE_TRUE@am__append_3 = -DCY_EXECUTE -@CY_EXECUTE_TRUE@am__append_4 = C -@CY_EXECUTE_TRUE@am__append_5 = Bridge.gperf Bridge.hpp -@CY_JAVA_TRUE@am__append_6 = Java -@CY_JAVA_TRUE@am__append_7 = Java/Execute.cpp -@CY_JAVA_TRUE@am__append_8 = $(LTJAVA) -@CY_OBJECTIVEC_TRUE@am__append_9 = ObjectiveC -@CY_OBJECTIVEC_TRUE@am__append_10 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm -@CY_OBJECTIVEC_TRUE@am__append_11 = $(LTOBJECTIVEC) -@CY_ATTACH_TRUE@am__append_12 = Handler.cpp -@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__append_13 = Inject.cpp -@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__append_14 = -DCY_ATTACH +@CY_EXECUTE_TRUE@am__append_3 = $(LTJAVASCRIPTCORE) +@CY_EXECUTE_TRUE@am__append_4 = -DCY_EXECUTE +@CY_EXECUTE_TRUE@am__append_5 = C +@CY_EXECUTE_TRUE@am__append_6 = Bridge.gperf Bridge.hpp +@CY_JAVA_TRUE@am__append_7 = Java +@CY_JAVA_TRUE@am__append_8 = Java/Execute.cpp +@CY_JAVA_TRUE@am__append_9 = $(LTJAVA) +@CY_OBJECTIVEC_TRUE@am__append_10 = ObjectiveC +@CY_OBJECTIVEC_TRUE@am__append_11 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm +@CY_OBJECTIVEC_TRUE@am__append_12 = $(LTOBJECTIVEC) +@CY_ATTACH_TRUE@am__append_13 = Handler.cpp +@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__append_14 = Inject.cpp +@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__append_15 = -DCY_ATTACH subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ @@ -180,23 +181,26 @@ libcycript_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) am__libcycript_la_SOURCES_DIST = ConvertUTF.c Decode.cpp Driver.cpp \ Highlight.cpp Library.cpp Network.cpp Output.cpp Parser.cpp \ - Replace.cpp Cycript.tab.cc lex.cy.cpp sig/ffi_type.cpp \ - sig/parse.cpp sig/copy.cpp Bridge.cpp Execute.cpp \ - JavaScriptCore.cpp Java/Execute.cpp ObjectiveC/Output.cpp \ - ObjectiveC/Replace.cpp ObjectiveC/Library.mm Handler.cpp + Replace.cpp Cycript.tab.cc lex.cy.cpp Complete.cpp \ + sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp Bridge.cpp \ + Execute.cpp JavaScriptCore.cpp Java/Execute.cpp \ + ObjectiveC/Output.cpp ObjectiveC/Replace.cpp \ + ObjectiveC/Library.mm Handler.cpp +@CY_CONSOLE_TRUE@am__objects_1 = Complete.lo am__dirstamp = $(am__leading_dot)dirstamp -@CY_EXECUTE_TRUE@am__objects_1 = sig/ffi_type.lo sig/parse.lo \ +@CY_EXECUTE_TRUE@am__objects_2 = sig/ffi_type.lo sig/parse.lo \ @CY_EXECUTE_TRUE@ sig/copy.lo Bridge.lo Execute.lo \ @CY_EXECUTE_TRUE@ JavaScriptCore.lo -@CY_JAVA_TRUE@am__objects_2 = Java/Execute.lo -@CY_OBJECTIVEC_TRUE@am__objects_3 = ObjectiveC/Output.lo \ +@CY_JAVA_TRUE@am__objects_3 = Java/Execute.lo +@CY_OBJECTIVEC_TRUE@am__objects_4 = ObjectiveC/Output.lo \ @CY_OBJECTIVEC_TRUE@ ObjectiveC/Replace.lo \ @CY_OBJECTIVEC_TRUE@ ObjectiveC/Library.lo -@CY_ATTACH_TRUE@am__objects_4 = Handler.lo +@CY_ATTACH_TRUE@am__objects_5 = Handler.lo am_libcycript_la_OBJECTS = ConvertUTF.lo Decode.lo Driver.lo \ Highlight.lo Library.lo Network.lo Output.lo Parser.lo \ Replace.lo Cycript.tab.lo lex.cy.lo $(am__objects_1) \ - $(am__objects_2) $(am__objects_3) $(am__objects_4) + $(am__objects_2) $(am__objects_3) $(am__objects_4) \ + $(am__objects_5) libcycript_la_OBJECTS = $(am_libcycript_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -207,9 +211,9 @@ libcycript_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ $(OBJCXXFLAGS) $(libcycript_la_LDFLAGS) $(LDFLAGS) -o $@ PROGRAMS = $(bin_PROGRAMS) am__cycript_SOURCES_DIST = Console.cpp Display.cpp Inject.cpp -@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__objects_5 = Inject.$(OBJEXT) +@CY_ATTACH_TRUE@@CY_CONSOLE_TRUE@am__objects_6 = Inject.$(OBJEXT) @CY_CONSOLE_TRUE@am_cycript_OBJECTS = Console.$(OBJEXT) \ -@CY_CONSOLE_TRUE@ Display.$(OBJEXT) $(am__objects_5) +@CY_CONSOLE_TRUE@ Display.$(OBJEXT) $(am__objects_6) cycript_OBJECTS = $(am_cycript_OBJECTS) @CY_CONSOLE_TRUE@cycript_DEPENDENCIES = libcycript.la \ @CY_CONSOLE_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -532,25 +536,29 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = subdir-objects -CLEANFILES = $(am__append_5) Cycript.yy Cycript.l lex.cy.cpp \ +CLEANFILES = $(am__append_6) Cycript.yy Cycript.l lex.cy.cpp \ Cycript.tab.cc Cycript.tab.hh stack.hh Cycript.output SUBDIRS = ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = -DYYDEBUG=1 -include config.h -include \ - $(srcdir)/unconfig.h $(am__append_3) $(am__append_14) -AM_OBJCXXFLAGS = -fobjc-exceptions + $(srcdir)/unconfig.h $(am__append_4) $(am__append_15) +AM_CFLAGS = -fvisibility=hidden +AM_CXXFLAGS = -fvisibility=hidden +AM_OBJCXXFLAGS = -fvisibility=hidden -fobjc-exceptions +AM_LDFLAGS = -fvisibility=hidden CY_LDFLAGS = -no-undefined -avoid-version -export-dynamic lib_LTLIBRARIES = libcycript.la libcycript_la_LDFLAGS = $(CY_LDFLAGS) -libcycript_la_LIBADD = $(LTLIBFFI) $(LTLIBGCC) -ldl $(am__append_2) \ - $(am__append_8) $(am__append_11) +libcycript_la_LIBADD = $(LTLIBFFI) $(LTLIBGCC) -ldl $(am__append_3) \ + $(am__append_9) $(am__append_12) libcycript_la_SOURCES = ConvertUTF.c Decode.cpp Driver.cpp \ Highlight.cpp Library.cpp Network.cpp Output.cpp Parser.cpp \ Replace.cpp Cycript.tab.cc lex.cy.cpp $(am__append_1) \ - $(am__append_7) $(am__append_10) $(am__append_12) -filters = $(am__append_4) $(am__append_6) $(am__append_9) + $(am__append_2) $(am__append_8) $(am__append_11) \ + $(am__append_13) +filters = $(am__append_5) $(am__append_7) $(am__append_10) @CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp Display.cpp \ -@CY_CONSOLE_TRUE@ $(am__append_13) +@CY_CONSOLE_TRUE@ $(am__append_14) @CY_CONSOLE_TRUE@cycript_LDADD = libcycript.la $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) $(PTHREAD_CFLAGS) -ldl all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -738,6 +746,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Bridge.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Complete.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Console.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConvertUTF.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Cycript.tab.Plo@am__quote@ diff --git a/Network.cpp b/Network.cpp index d9537bc..af9cff8 100644 --- a/Network.cpp +++ b/Network.cpp @@ -26,7 +26,7 @@ #include "Error.hpp" -bool CYRecvAll_(int socket, uint8_t *data, size_t size) { +_visible bool CYRecvAll_(int socket, uint8_t *data, size_t size) { while (size != 0) if (size_t writ = _syscall(recv(socket, data, size, 0))) { data += writ; size -= writ; @@ -35,7 +35,7 @@ bool CYRecvAll_(int socket, uint8_t *data, size_t size) { return true; } -bool CYSendAll_(int socket, const uint8_t *data, size_t size) { +_visible bool CYSendAll_(int socket, const uint8_t *data, size_t size) { while (size != 0) if (size_t writ = _syscall(send(socket, data, size, 0))) { data += writ; size -= writ; diff --git a/ObjectiveC/Library.mm b/ObjectiveC/Library.mm index c302305..8c1528d 100644 --- a/ObjectiveC/Library.mm +++ b/ObjectiveC/Library.mm @@ -2995,11 +2995,11 @@ static CYHook CYObjectiveCHook = { CYRegisterHook CYObjectiveC(&CYObjectiveCHook); -extern "C" void CydgetSetupContext(JSGlobalContextRef context) { CYObjectiveTry_ { +_extern void CydgetSetupContext(JSGlobalContextRef context) { CYObjectiveTry_ { CYSetupContext(context); } CYObjectiveCatch } -extern "C" void CydgetMemoryParse(const uint16_t **data, size_t *size) { try { +_extern void CydgetMemoryParse(const uint16_t **data, size_t *size) { try { CYPool pool; CYUTF8String utf8(CYPoolUTF8String(pool, CYUTF16String(*data, *size))); diff --git a/Standard.hpp b/Standard.hpp index 6c9da9f..f2f93b3 100644 --- a/Standard.hpp +++ b/Standard.hpp @@ -39,4 +39,9 @@ #define _noreturn \ __attribute__((__noreturn__)) +#define _visible \ + __attribute__((__visibility__("default"))) +#define _extern \ + extern "C" _visible + #endif/*CYCRIPT_STANDARD_HPP*/ diff --git a/String.hpp b/String.hpp index a00a5e2..ce48f2c 100644 --- a/String.hpp +++ b/String.hpp @@ -22,7 +22,6 @@ #ifndef CYCRIPT_STRING_HPP #define CYCRIPT_STRING_HPP -#include "cycript.hpp" #include "Pooling.hpp" #include diff --git a/cycript.hpp b/cycript.hpp index 6494cad..0f6ed13 100644 --- a/cycript.hpp +++ b/cycript.hpp @@ -26,6 +26,7 @@ #include #include "Pooling.hpp" +#include "String.hpp" bool CYRecvAll_(int socket, uint8_t *data, size_t size); bool CYSendAll_(int socket, const uint8_t *data, size_t size); @@ -36,7 +37,7 @@ void CYStringify(std::ostringstream &str, const char *data, size_t size); double CYCastDouble(const char *value, size_t size); double CYCastDouble(const char *value); -extern "C" void CYHandleClient(int socket); +void CYHandleClient(int socket); template bool CYRecvAll(int socket, Type_ *data, size_t size) { @@ -50,4 +51,6 @@ bool CYSendAll(int socket, const Type_ *data, size_t size) { CYPool &CYGetGlobalPool(); +char **CYComplete(const char *word, const std::string &line, CYUTF8String (*run)(CYPool &pool, const std::string &)); + #endif/*CYCRIPT_HPP*/ diff --git a/xcode.map b/xcode.map index f1ce371..1619d65 100644 --- a/xcode.map +++ b/xcode.map @@ -1 +1,2 @@ _CYListenServer +.objc_class_name_CY* -- 2.45.2