From 08cd03b05c0cfe000262f956f8d804b101718a19 Mon Sep 17 00:00:00 2001 From: Odilitime Date: Sun, 21 Jan 2018 02:58:47 -0800 Subject: [PATCH] Javascript class refactor --- src/interfaces/components/DocumentComponent.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/interfaces/components/DocumentComponent.cpp b/src/interfaces/components/DocumentComponent.cpp index 3975e13..3a4d3af 100644 --- a/src/interfaces/components/DocumentComponent.cpp +++ b/src/interfaces/components/DocumentComponent.cpp @@ -83,11 +83,8 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f std::cout << "DocumentComponent::DocumentComponent - ERROR: Could not load res/ntr_bootstrap.js" << std::endl; } else { //std::cout << "DocumentComponent::DocumentComponent - Loaded [" << bootstrap_js << "] ntr_bootstrap.js\n"; - JSParser jsparser; this->bootstrapScript = std::make_shared(); - this->bootstrapScript->tokens = jsparser.getTokens(bootstrap_js); - jsparser.parseTokens(this->bootstrapScript->tokens, &this->bootstrapScript->rootScope); - //this->bootstrapScript = jsparser.parse(bootstrap_js); + this->bootstrapScript->parse(bootstrap_js); } //std::cout << "DocumentComponent::DocumentComponent - our size" << static_cast(width) << "x" << static_cast(height) << std::endl; @@ -292,7 +289,7 @@ DocumentComponent::DocumentComponent(const float rawX, const float rawY, const f if (key == GLFW_KEY_V && action == GLFW_RELEASE) { printf("Printing JS Variables\n\n"); //std::cout << "DocumentComponent::render - JS var state" << std::endl; - for(auto it : this->mainScript->rootScope.variables) { + for(auto it : this->mainScript->rootScope.locals.value) { std::cout << "[" << it.first << "=" << it.second << "]" << std::endl; } printf("\n\n"); @@ -423,8 +420,8 @@ void DocumentComponent::setDOM(const std::shared_ptr rootNode) { mainScript = std::make_shared(); if (this->bootstrapScript) { - JSParser jsparser; - jsparser.append(mainScript, this->bootstrapScript); + mainScript->applyScope(this->bootstrapScript); + mainScript->append(this->bootstrapScript); } else { std::cout << "DocumentComponent::setDOM - no bootstrap JS loaded\n"; }