Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive variable and function access through macros #29

Closed
NQNStudios opened this issue Nov 13, 2017 · 0 comments
Closed

Recursive variable and function access through macros #29

NQNStudios opened this issue Nov 13, 2017 · 0 comments

Comments

@NQNStudios
Copy link
Collaborator

NQNStudios commented Nov 13, 2017

Function and variable macros are currently expanded like this in Core.ts:

			case '#':
			{
				// Return the result of the named function call
				let functionName = macro.substring(1);
				let fn = window[functionName];
				if(typeof fn === "function") { result = fn(); }
				else { console.log(functionName + " is not a function"); }
				break;
			}
			case '$':
			{
				// Return the value of the named variable
				result = window[macro.substring(1)];
				break;
			}
	

This restricts Fractive's access only to variables and functions in the global scope. Properties and functions of objects cannot be accessed, but the code could be modified to allow this:

  • Split the macro using . as a delimiter
  • Loop through, starting with window, and [] accessing each property from the successive object that's found, until no more .'s are there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant