]> git.saurik.com Git - cycript.git/blobdiff - Complete.cpp
Attach FFI closure deallocation to Functor's pool.
[cycript.git] / Complete.cpp
index 6ce6671c7d0cdde879990da4faeebd4f70197cf8..276ccaf5e2111827ef28693137df42074f74cfc5 100644 (file)
@@ -28,7 +28,7 @@
 static CYExpression *ParseExpression(CYPool &pool, CYUTF8String code) {
     std::stringstream stream;
     stream << '(' << code << ')';
-    CYDriver driver(pool, stream);
+    CYDriver driver(pool, *stream.rdbuf());
     if (driver.Parse() || !driver.errors_.empty())
         return NULL;
 
@@ -51,7 +51,7 @@ static CYExpression *ParseExpression(CYPool &pool, CYUTF8String code) {
 _visible char **CYComplete(const char *word, const std::string &line, CYUTF8String (*run)(CYPool &pool, const std::string &)) {
     CYLocalPool pool;
 
-    std::istringstream stream(line);
+    std::stringbuf stream(line);
     CYDriver driver(pool, stream);
 
     driver.auto_ = true;
@@ -106,6 +106,10 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
     "               if (name.substring(0, entire) == prefix)\n"
     "                   names.push(name.substr(before));\n"
     "       } else do {\n"
+    "           if (object.hasOwnProperty(\"cy$complete\")) {\n"
+    "               names = names.concat(object.cy$complete(prefix));\n"
+    "               continue;\n"
+    "           }\n"
     "           try {\n"
     "               var local = Object.getOwnPropertyNames(object);\n"
     "           } catch (e) {\n"