From 96d36aaa89e579a53bd5848c22a462ca8eb13f80 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" <saurik@saurik.com> Date: Mon, 5 Sep 2016 20:37:16 -0700 Subject: [PATCH] Repair build when JavaScriptCore is not available. --- Console.cpp | 10 ++++- Execute.cpp | 16 +------- JavaScript.hpp | 4 +- Makefile.am | 14 +++---- Makefile.in | 100 +++++++++++++++++++++++++------------------------ Parser.ypp.in | 24 ++++++++---- String.hpp | 14 +++++-- cycript.hpp | 2 - 8 files changed, 99 insertions(+), 85 deletions(-) diff --git a/Console.cpp b/Console.cpp index 2f24e58..7f68ecd 100644 --- a/Console.cpp +++ b/Console.cpp @@ -220,7 +220,7 @@ static void sigint(int) { case Parsing: longjmp(ctrlc_, 1); case Running: -#ifndef __ANDROID__ +#ifdef CY_EXECUTE CYCancel(); #endif return; @@ -341,6 +341,7 @@ class CYSocketRemote : } }; +#ifdef CY_EXECUTE void InjectLibrary(pid_t, std::ostream &stream, int, const char *const []); class CYInjectRemote : @@ -366,6 +367,7 @@ class CYInjectRemote : return CYUTF8String(strdup(json.c_str()), json.size()); } }; +#endif static std::ostream *out_; @@ -775,12 +777,14 @@ static void Console(CYOptions &options) { } else if (data == "debug") { debug = !debug; *out_ << "debug == " << (debug ? "true" : "false") << std::endl; +#ifdef CY_EXECUTE } else if (data == "destroy") { CYDestroyContext(); } else if (data == "gc") { *out_ << "collecting... " << std::flush; CYGarbageCollect(CYGetJSContext()); *out_ << "done." << std::endl; +#endif } else if (data == "exit") { return; } else if (data == "lower") { @@ -879,7 +883,9 @@ int Main(int argc, char * const argv[], char const * const envp[]) { const char *host(NULL); const char *port(NULL); +#ifdef CY_EXECUTE const char *argv0(argv[0]); +#endif optind = 1; @@ -1057,8 +1063,10 @@ int Main(int argc, char * const argv[], char const * const envp[]) { CYSetArgs(argv0, script, argc, const_cast<const char **>(argv)); #endif +#ifdef CY_EXECUTE if (remote_ == NULL && pid != _not(pid_t)) remote_ = new CYInjectRemote(pid); +#endif if (remote_ == NULL && host != NULL && port != NULL) remote_ = new CYSocketRemote(host, port); diff --git a/Execute.cpp b/Execute.cpp index 18bdce6..b92b478 100644 --- a/Execute.cpp +++ b/Execute.cpp @@ -144,18 +144,6 @@ CYUTF16String CYCastUTF16String(JSStringRef value) { return CYUTF16String(JSStringGetCharactersPtr(value), JSStringGetLength(value)); } -const char *CYPoolCString(CYPool &pool, CYUTF8String utf8) { - return pool.strndup(utf8.data, utf8.size); -} - -CYUTF8String CYPoolUTF8String(CYPool &pool, CYUTF8String utf8) { - return {pool.strndup(utf8.data, utf8.size), utf8.size}; -} - -_visible CYUTF8String CYPoolUTF8String(CYPool &pool, const std::string &value) { - return {pool.strndup(value.data(), value.size()), value.size()}; -} - CYUTF8String CYPoolUTF8String(CYPool &pool, JSContextRef context, JSStringRef value) { return CYPoolUTF8String(pool, CYCastUTF16String(value)); } @@ -2137,11 +2125,11 @@ _visible const char *CYExecute(JSContextRef context, CYPool &pool, CYUTF8String } } -#ifndef __ANDROID__ _visible void CYCancel() { +#ifndef __ANDROID__ cancel_ = true; -} #endif +} const char *CYPoolLibraryPath(CYPool &pool); diff --git a/JavaScript.hpp b/JavaScript.hpp index 3265b2e..c959b69 100644 --- a/JavaScript.hpp +++ b/JavaScript.hpp @@ -37,6 +37,8 @@ #include <ffi.h> #endif +#include "sig/types.hpp" + #include "Pooling.hpp" #include "String.hpp" #include "Utility.hpp" @@ -67,9 +69,7 @@ JSObjectRef CYGetGlobalObject(JSContextRef context); extern "C" void CYSetupContext(JSGlobalContextRef context); const char *CYExecute(JSContextRef context, CYPool &pool, CYUTF8String code); -#ifndef __ANDROID__ void CYCancel(); -#endif void CYSetArgs(const char *argv0, const char *script, int argc, const char *argv[]); diff --git a/Makefile.am b/Makefile.am index 289dd16..57a3cfa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -57,7 +57,7 @@ lib_LTLIBRARIES += libcycript.la libcycript_la_LDFLAGS = $(CY_LDFLAGS) libcycript_la_LIBADD = $(LTLIBUV) $(LTLIBFFI) $(LTLIBSQLITE3) $(LTLIBGCC) -ldl -libcycript_la_SOURCES = ConvertUTF.c Decode.cpp Driver.cpp Error.cpp Highlight.cpp Library.cpp Network.cpp Output.cpp Replace.cpp Syntax.cpp +libcycript_la_SOURCES = ConvertUTF.c Driver.cpp Error.cpp Highlight.cpp Library.cpp Network.cpp Output.cpp Replace.cpp Syntax.cpp libcycript_la_SOURCES += Parser.cpp Scanner.cpp filters = @@ -68,6 +68,10 @@ cycript_SOURCES = Console.cpp cycript_LDADD = libcycript.la $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) $(PTHREAD_CFLAGS) -ldl libcycript_la_SOURCES += Complete.cpp +if CY_EXECUTE +cycript_SOURCES += Inject.cpp +endif + if CY_ANDROID bin_PROGRAMS += cycript-pie cycript_pie_SOURCES = pie.c @@ -77,7 +81,7 @@ endif if CY_EXECUTE libcycript_la_SOURCES += sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp -libcycript_la_SOURCES += Execute.cpp JavaScriptCore.cpp +libcycript_la_SOURCES += Decode.cpp Execute.cpp Handler.cpp JavaScriptCore.cpp libcycript_la_LIBADD += $(LTJAVASCRIPTCORE) dat_DATA += libcycript.db @@ -155,12 +159,6 @@ libcycript_la_SOURCES += ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC libcycript_la_LIBADD += $(LTOBJECTIVEC) endif -libcycript_la_SOURCES += Handler.cpp - -if CY_CONSOLE -cycript_SOURCES += Inject.cpp -endif - CLEANFILES += Parser.ypp Parser.ypp: Parser.ypp.in $(srcdir)/Filter.sh $< >$@ $(filters) diff --git a/Makefile.in b/Makefile.in index 232244b..25c9a0c 100644 --- a/Makefile.in +++ b/Makefile.in @@ -113,16 +113,18 @@ host_triplet = @host@ @CY_ANDROID_TRUE@am__append_2 = -rdynamic -fPIE -pie @CY_CONSOLE_TRUE@bin_PROGRAMS = cycript$(EXEEXT) $(am__EXEEXT_1) @CY_CONSOLE_TRUE@am__append_3 = Complete.cpp -@CY_ANDROID_TRUE@@CY_CONSOLE_TRUE@am__append_4 = cycript-pie -@CY_EXECUTE_TRUE@am__append_5 = sig/ffi_type.cpp sig/parse.cpp \ -@CY_EXECUTE_TRUE@ sig/copy.cpp Execute.cpp JavaScriptCore.cpp -@CY_EXECUTE_TRUE@am__append_6 = $(LTJAVASCRIPTCORE) -@CY_EXECUTE_TRUE@am__append_7 = libcycript.db -@CY_EXECUTE_TRUE@am__append_8 = -DCY_EXECUTE -@CY_EXECUTE_TRUE@am__append_9 = C -@CY_EXECUTE_TRUE@am__append_10 = libcycript.db -@CY_EXECUTE_TRUE@@CY_PRELINK_TRUE@am__append_11 = Analyze Bridge.def -@CY_EXECUTE_TRUE@@CY_PRELINK_FALSE@am__append_12 = Bridge.def +@CY_CONSOLE_TRUE@@CY_EXECUTE_TRUE@am__append_4 = Inject.cpp +@CY_ANDROID_TRUE@@CY_CONSOLE_TRUE@am__append_5 = cycript-pie +@CY_EXECUTE_TRUE@am__append_6 = sig/ffi_type.cpp sig/parse.cpp \ +@CY_EXECUTE_TRUE@ sig/copy.cpp Decode.cpp Execute.cpp \ +@CY_EXECUTE_TRUE@ Handler.cpp JavaScriptCore.cpp +@CY_EXECUTE_TRUE@am__append_7 = $(LTJAVASCRIPTCORE) +@CY_EXECUTE_TRUE@am__append_8 = libcycript.db +@CY_EXECUTE_TRUE@am__append_9 = -DCY_EXECUTE +@CY_EXECUTE_TRUE@am__append_10 = C +@CY_EXECUTE_TRUE@am__append_11 = libcycript.db +@CY_EXECUTE_TRUE@@CY_PRELINK_TRUE@am__append_12 = Analyze Bridge.def +@CY_EXECUTE_TRUE@@CY_PRELINK_FALSE@am__append_13 = Bridge.def #CLEANFILES += Hasher.gperf #Hasher.gperf: Hasher.def Hasher.sh @@ -131,20 +133,20 @@ host_triplet = @host@ #CLEANFILES += Hasher.hpp #Hasher.hpp: Hasher.gperf # $(GPERF) $< >$@ -@CY_JAVA_TRUE@am__append_13 = Java -@CY_JAVA_TRUE@am__append_14 = Java/Execute.cpp -@CY_JAVA_TRUE@am__append_15 = libcycript.jar -@CY_JAVA_TRUE@am__append_16 = Class libcycript.jar -@CY_RUBY_TRUE@am__append_17 = Ruby -@CY_RUBY_TRUE@am__append_18 = Ruby/Execute.cpp -@CY_RUBY_TRUE@am__append_19 = $(LTRUBY) -@CY_PYTHON_TRUE@am__append_20 = Python -@CY_PYTHON_TRUE@am__append_21 = Python/Execute.cpp -@CY_PYTHON_TRUE@am__append_22 = $(LTPYTHON) -@CY_OBJECTIVEC_TRUE@am__append_23 = -DCY_OBJECTIVEC -@CY_OBJECTIVEC_TRUE@am__append_24 = ObjectiveC -@CY_OBJECTIVEC_TRUE@am__append_25 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm -@CY_OBJECTIVEC_TRUE@am__append_26 = $(LTOBJECTIVEC) +@CY_JAVA_TRUE@am__append_14 = Java +@CY_JAVA_TRUE@am__append_15 = Java/Execute.cpp +@CY_JAVA_TRUE@am__append_16 = libcycript.jar +@CY_JAVA_TRUE@am__append_17 = Class libcycript.jar +@CY_RUBY_TRUE@am__append_18 = Ruby +@CY_RUBY_TRUE@am__append_19 = Ruby/Execute.cpp +@CY_RUBY_TRUE@am__append_20 = $(LTRUBY) +@CY_PYTHON_TRUE@am__append_21 = Python +@CY_PYTHON_TRUE@am__append_22 = Python/Execute.cpp +@CY_PYTHON_TRUE@am__append_23 = $(LTPYTHON) +@CY_OBJECTIVEC_TRUE@am__append_24 = -DCY_OBJECTIVEC +@CY_OBJECTIVEC_TRUE@am__append_25 = ObjectiveC +@CY_OBJECTIVEC_TRUE@am__append_26 = ObjectiveC/Output.cpp ObjectiveC/Replace.cpp ObjectiveC/Library.mm +@CY_OBJECTIVEC_TRUE@am__append_27 = $(LTOBJECTIVEC) subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \ @@ -203,28 +205,29 @@ libcycript_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) \ $(am__DEPENDENCIES_5) -am__libcycript_la_SOURCES_DIST = ConvertUTF.c Decode.cpp Driver.cpp \ - Error.cpp Highlight.cpp Library.cpp Network.cpp Output.cpp \ - Replace.cpp Syntax.cpp Parser.cpp Scanner.cpp Complete.cpp \ - sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp Execute.cpp \ - JavaScriptCore.cpp Java/Execute.cpp Ruby/Execute.cpp \ - Python/Execute.cpp ObjectiveC/Output.cpp \ - ObjectiveC/Replace.cpp ObjectiveC/Library.mm Handler.cpp +am__libcycript_la_SOURCES_DIST = ConvertUTF.c Driver.cpp Error.cpp \ + Highlight.cpp Library.cpp Network.cpp Output.cpp Replace.cpp \ + Syntax.cpp Parser.cpp Scanner.cpp Complete.cpp \ + sig/ffi_type.cpp sig/parse.cpp sig/copy.cpp Decode.cpp \ + Execute.cpp Handler.cpp JavaScriptCore.cpp Java/Execute.cpp \ + Ruby/Execute.cpp Python/Execute.cpp ObjectiveC/Output.cpp \ + ObjectiveC/Replace.cpp ObjectiveC/Library.mm @CY_CONSOLE_TRUE@am__objects_1 = Complete.lo am__dirstamp = $(am__leading_dot)dirstamp @CY_EXECUTE_TRUE@am__objects_2 = sig/ffi_type.lo sig/parse.lo \ -@CY_EXECUTE_TRUE@ sig/copy.lo Execute.lo JavaScriptCore.lo +@CY_EXECUTE_TRUE@ sig/copy.lo Decode.lo Execute.lo Handler.lo \ +@CY_EXECUTE_TRUE@ JavaScriptCore.lo @CY_JAVA_TRUE@am__objects_3 = Java/Execute.lo @CY_RUBY_TRUE@am__objects_4 = Ruby/Execute.lo @CY_PYTHON_TRUE@am__objects_5 = Python/Execute.lo @CY_OBJECTIVEC_TRUE@am__objects_6 = ObjectiveC/Output.lo \ @CY_OBJECTIVEC_TRUE@ ObjectiveC/Replace.lo \ @CY_OBJECTIVEC_TRUE@ ObjectiveC/Library.lo -am_libcycript_la_OBJECTS = ConvertUTF.lo Decode.lo Driver.lo Error.lo \ +am_libcycript_la_OBJECTS = ConvertUTF.lo Driver.lo Error.lo \ Highlight.lo Library.lo Network.lo Output.lo Replace.lo \ Syntax.lo Parser.lo Scanner.lo $(am__objects_1) \ $(am__objects_2) $(am__objects_3) $(am__objects_4) \ - $(am__objects_5) $(am__objects_6) Handler.lo + $(am__objects_5) $(am__objects_6) libcycript_la_OBJECTS = $(am_libcycript_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -236,8 +239,9 @@ libcycript_la_LINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \ @CY_ANDROID_TRUE@@CY_CONSOLE_TRUE@am__EXEEXT_1 = cycript-pie$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) am__cycript_SOURCES_DIST = Console.cpp Inject.cpp +@CY_CONSOLE_TRUE@@CY_EXECUTE_TRUE@am__objects_7 = Inject.$(OBJEXT) @CY_CONSOLE_TRUE@am_cycript_OBJECTS = Console.$(OBJEXT) \ -@CY_CONSOLE_TRUE@ Inject.$(OBJEXT) +@CY_CONSOLE_TRUE@ $(am__objects_7) cycript_OBJECTS = $(am_cycript_OBJECTS) @CY_CONSOLE_TRUE@cycript_DEPENDENCIES = libcycript.la \ @CY_CONSOLE_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ @@ -595,15 +599,15 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = subdir-objects -CLEANFILES = $(am__append_10) $(am__append_11) $(am__append_12) \ - $(am__append_16) Parser.ypp Scanner.lpp Scanner.cpp \ +CLEANFILES = $(am__append_11) $(am__append_12) $(am__append_13) \ + $(am__append_17) Parser.ypp Scanner.lpp Scanner.cpp \ Scanner.output lex.backup Parser.cpp Parser.hpp stack.hh \ Parser.output SUBDIRS = ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = -DYYDEBUG=1 -DCY_SYSTEM="\"$(CY_SYSTEM)\"" -include \ - config.h -include $(srcdir)/unconfig.h $(am__append_8) \ - $(am__append_23) + config.h -include $(srcdir)/unconfig.h $(am__append_9) \ + $(am__append_24) CY_FLAGS = -fvisibility=hidden $(am__append_1) AM_CFLAGS = $(CY_FLAGS) AM_CXXFLAGS = $(CY_FLAGS) @@ -611,20 +615,20 @@ AM_OBJCXXFLAGS = $(CY_FLAGS) -fobjc-exceptions AM_LDFLAGS = $(CY_FLAGS) $(am__append_2) CY_LDFLAGS = -no-undefined -avoid-version -export-dynamic datdir = $(libdir) -dat_DATA = $(am__append_7) $(am__append_15) +dat_DATA = $(am__append_8) $(am__append_16) lib_LTLIBRARIES = libcycript.la libcycript_la_LDFLAGS = $(CY_LDFLAGS) libcycript_la_LIBADD = $(LTLIBUV) $(LTLIBFFI) $(LTLIBSQLITE3) \ - $(LTLIBGCC) -ldl $(am__append_6) $(am__append_19) \ - $(am__append_22) $(am__append_26) -libcycript_la_SOURCES = ConvertUTF.c Decode.cpp Driver.cpp Error.cpp \ + $(LTLIBGCC) -ldl $(am__append_7) $(am__append_20) \ + $(am__append_23) $(am__append_27) +libcycript_la_SOURCES = ConvertUTF.c Driver.cpp Error.cpp \ Highlight.cpp Library.cpp Network.cpp Output.cpp Replace.cpp \ Syntax.cpp Parser.cpp Scanner.cpp $(am__append_3) \ - $(am__append_5) $(am__append_14) $(am__append_18) \ - $(am__append_21) $(am__append_25) Handler.cpp -filters = $(am__append_9) $(am__append_13) $(am__append_17) \ - $(am__append_20) $(am__append_24) -@CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp Inject.cpp + $(am__append_6) $(am__append_15) $(am__append_19) \ + $(am__append_22) $(am__append_26) +filters = $(am__append_10) $(am__append_14) $(am__append_18) \ + $(am__append_21) $(am__append_25) +@CY_CONSOLE_TRUE@cycript_SOURCES = Console.cpp $(am__append_4) @CY_CONSOLE_TRUE@cycript_LDADD = libcycript.la $(LTLIBREADLINE) $(LTLIBTERMCAP) $(LTLIBGCC) $(PTHREAD_CFLAGS) -ldl @CY_ANDROID_TRUE@@CY_CONSOLE_TRUE@cycript_pie_SOURCES = pie.c @CY_ANDROID_TRUE@@CY_CONSOLE_TRUE@cycript_pie_LDFLAGS = -fno-PIE diff --git a/Parser.ypp.in b/Parser.ypp.in index c076967..7fbb3d2 100644 --- a/Parser.ypp.in +++ b/Parser.ypp.in @@ -550,9 +550,6 @@ type; }) %type <expression_> ExpressionOpt %type <for_> ExpressionStatement_ %type <statement_> ExpressionStatement -%type <statement_> ExternC -%type <statement_> ExternCStatement -%type <statement_> ExternCStatementListOpt %type <finally_> Finally %type <binding_> ForBinding %type <forin_> ForDeclaration @@ -574,9 +571,7 @@ type; }) %type <statement_> HoistableDeclaration %type <identifier_> Identifier %type <identifier_> IdentifierNoOf -%type <identifier_> IdentifierType %type <identifier_> IdentifierTypeNoOf -%type <identifier_> IdentifierTypeOpt %type <word_> IdentifierName %type <variable_> IdentifierReference %type <statement_> IfStatement @@ -588,7 +583,6 @@ type; }) %type <import_> ImportsList_ %type <import_> ImportsList %type <import_> ImportsListOpt -%type <target_> IndirectExpression %type <expression_> Initializer %type <expression_> InitializerOpt %type <statement_> IterationStatement @@ -657,7 +651,6 @@ type; }) %type <span_> TemplateSpans %type <statement_> ThrowStatement %type <statement_> TryStatement -%type <statement_> TypeDefinition %type <expression_> UnaryExpression_ %type <expression_> UnaryExpression %type <binding_> VariableDeclaration @@ -676,6 +669,12 @@ type; }) @begin C %type <constant_> EnumConstantListOpt_ %type <constant_> EnumConstantListOpt +%type <statement_> ExternC +%type <statement_> ExternCStatement +%type <statement_> ExternCStatementListOpt +%type <identifier_> IdentifierType +%type <identifier_> IdentifierTypeOpt +%type <target_> IndirectExpression %type <number_> IntegerNumber %type <integral_> IntegerType %type <integral_> IntegerTypeOpt @@ -685,6 +684,7 @@ type; }) %type <structField_> StructFieldListOpt %type <typedName_> SuffixedType %type <typedName_> SuffixedTypeOpt +%type <statement_> TypeDefinition %type <typedName_> TypeSignifier %type <typedName_> TypeSignifierNone %type <typedName_> TypeSignifierOpt @@ -924,20 +924,24 @@ NewLineNot : LexNewLineOrNot "" ; +@begin C NewLineOpt : LexNewLineOrNot "\n" | NewLineNot ; +@end TerminatorSoft : LexNewLineOrNot "\n" StrictSemi | NewLineNot LexOf Terminator ; +@begin C TerminatorHard : ";" | error { if (yyla.type_get() != yyeof_) CYERR(@error, "required semi-colon"); else CYEOK(); } StrictSemi ; +@end Terminator : ";" @@ -1013,6 +1017,7 @@ IdentifierTypeNoOf @end ; +@begin C IdentifierType : IdentifierTypeNoOf[pass] { $$ = $pass; } | "of" { $$ = CYNew CYIdentifier("of"); } @@ -1022,6 +1027,7 @@ IdentifierTypeOpt : IdentifierType[pass] { $$ = $pass; } | { $$ = NULL; } ; +@end IdentifierNoOf : IdentifierTypeNoOf @@ -1249,7 +1255,9 @@ AccessExpression LeftHandSideExpression : BracedExpression[pass] { $$ = $pass; } +@begin C | IndirectExpression[pass] { $$ = $pass; } +@end ; /* }}} */ /* 12.4 Postfix Expressions {{{ */ @@ -1638,7 +1646,9 @@ ForStatementInitializer ForInStatementInitializer : LexLet LexOf BracedExpression[pass] { $$ = $pass; } +@begin C | LexLet LexOf IndirectExpression[pass] { $$ = $pass; } +@end | LexLet LexOf Var_ LexBind ForBinding[binding] { $$ = CYNew CYForVariable($binding); } | ForDeclaration[pass] { $$ = $pass; } ; diff --git a/String.hpp b/String.hpp index fe33fcb..0bc5519 100644 --- a/String.hpp +++ b/String.hpp @@ -87,9 +87,17 @@ bool CYGetOffset(const char *value, ssize_t &index); bool CYStartsWith(const CYUTF8String &haystack, const CYUTF8String &needle); -const char *CYPoolCString(CYPool &pool, CYUTF8String utf8); -CYUTF8String CYPoolUTF8String(CYPool &pool, CYUTF8String utf8); -CYUTF8String CYPoolUTF8String(CYPool &pool, const std::string &value); +_finline const char *CYPoolCString(CYPool &pool, CYUTF8String utf8) { + return pool.strndup(utf8.data, utf8.size); +} + +_finline CYUTF8String CYPoolUTF8String(CYPool &pool, CYUTF8String utf8) { + return {pool.strndup(utf8.data, utf8.size), utf8.size}; +} + +_finline CYUTF8String CYPoolUTF8String(CYPool &pool, const std::string &value) { + return {pool.strndup(value.data(), value.size()), value.size()}; +} CYUTF8String CYPoolUTF8String(CYPool &pool, CYUTF16String utf16); CYUTF16String CYPoolUTF16String(CYPool &pool, CYUTF8String utf8); diff --git a/cycript.hpp b/cycript.hpp index 44958f8..ad3ca30 100644 --- a/cycript.hpp +++ b/cycript.hpp @@ -24,8 +24,6 @@ #include <sstream> -#include <sig/types.hpp> - #include "Pooling.hpp" #include "String.hpp" -- 2.47.2