Browse Source

flush out browserjs

master
Odilitime 2 years ago
parent
commit
84630b55a3
1 changed files with 33 additions and 0 deletions
  1. 33
    0
      src/parsers/scripting/javascript/BrowserJS.cpp

+ 33
- 0
src/parsers/scripting/javascript/BrowserJS.cpp View File

@@ -1 +1,34 @@
#include "BrowserJS.h"

std::vector<std::string> getConstructs() {
std::vector<std::string> constructs;
constructs.push_back("document.addEventListener");
constructs.push_back("document.querySelector");
return constructs;
}

bool isConstruct(std::string construct) {
std::vector<std::string> constructs = getConstructs();
std::vector<std::string>::iterator it = std::find(constructs.begin(), constructs.end(), construct);
std::cout << "isConstruct [" << construct << "](" << ((it != constructs.end())?"true":"false") << ")\n";
return it != constructs.end();
}

js_internal_storage *executeConstruct(std::string functionName, std::string params, js_function &scope) {
std::vector<std::string> constructs = getConstructs();
std::vector<std::string>::iterator it = std::find(constructs.begin(), constructs.end(), functionName);
if (it == constructs.end()) {
return nullptr;
}
std::cout << "executeConstruct [" << functionName << "](" << params << ")\n";
if (functionName == "document.querySelector") {
return jsConstruct_querySelector(params, scope);
}
return nullptr;
}

js_internal_storage *jsConstruct_querySelector(std::string params, js_function &scope) {
js_bool *jb = new js_bool;
jb->value = false;
return jb;
}

Loading…
Cancel
Save