]> git.saurik.com Git - cycript.git/blobdiff - Complete.cpp
Do not allow JavaMethod calls on non-Java objects.
[cycript.git] / Complete.cpp
index 8240068428fc4e060dd5308415bf7868e93c173b..820895c9c91776af12b040caace6244758274367 100644 (file)
@@ -93,6 +93,16 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
             expression = $M(driver.context_, $S("$cyr"));
         break;
 
             expression = $M(driver.context_, $S("$cyr"));
         break;
 
+        case CYDriver::AutoStruct:
+            expression = $ CYThis();
+            prefix << "$cys";
+        break;
+
+        case CYDriver::AutoEnum:
+            expression = $ CYThis();
+            prefix << "$cye";
+        break;
+
         default:
             _assert(false);
     }
         default:
             _assert(false);
     }
@@ -108,7 +118,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
     "       if (false) {\n"
     "           for (var name in object)\n"
     "               if (name.substring(0, entire) == prefix)\n"
     "       if (false) {\n"
     "           for (var name in object)\n"
     "               if (name.substring(0, entire) == prefix)\n"
-    "                   names.push(name.substr(before));\n"
+    "                   names.push(name);\n"
     "       } else do {\n"
     "           if (object.hasOwnProperty(\"cy$complete\")) {\n"
     "               names = names.concat(object.cy$complete(prefix));\n"
     "       } else do {\n"
     "           if (object.hasOwnProperty(\"cy$complete\")) {\n"
     "               names = names.concat(object.cy$complete(prefix));\n"
@@ -121,7 +131,7 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
     "           }\n"
     "           for (var name of local)\n"
     "               if (name.substring(0, entire) == prefix)\n"
     "           }\n"
     "           for (var name of local)\n"
     "               if (name.substring(0, entire) == prefix)\n"
-    "                   names.push(name.substr(before));\n"
+    "                   names.push(name);\n"
     "       } while (object = typeof object === 'object' ? Object.getPrototypeOf(object) : object.__proto__);\n"
     "       return names;\n"
     "   }\n"
     "       } while (object = typeof object === 'object' ? Object.getPrototypeOf(object) : object.__proto__);\n"
     "       return names;\n"
     "   }\n"
@@ -168,9 +178,11 @@ _visible char **CYComplete(const char *word, const std::string &line, CYUTF8Stri
         else
             continue;
 
         else
             continue;
 
+        completion.data += begin.size();
+        completion.size -= begin.size();
+
         if (CYStartsWith(completion, "$cy"))
             continue;
         if (CYStartsWith(completion, "$cy"))
             continue;
-
         completions.push_back(completion);
 
         if (!rest) {
         completions.push_back(completion);
 
         if (!rest) {