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

Binding the interpreter to an external envirotnment #161

Open
photopea opened this issue Sep 6, 2019 · 0 comments
Open

Binding the interpreter to an external envirotnment #161

photopea opened this issue Sep 6, 2019 · 0 comments

Comments

@photopea
Copy link

photopea commented Sep 6, 2019

I want the interpreted code to access data, which are not in the memory of the interpreter.

There should be a global object "app", similar to "window", which has many properties and methods. Some properties of the "app" have their own properties and methods. Maby my case is similar e.g. to giving scripts the access to HTML5 Canvas drawing.

Whenever a sub-property of "app" is read, or changed, or a method is called, I need my own functions to be called, which will manipulate my data (in my own representation) and possibly return a value.

My idea is, that I could give the interpreter three functions:

getProp(Obj, propName), 
setProp(Obj, propName, newValue)
callFnc(Obj, funcName, params)

When the interpreted script tries to read the property, which does not exist, getProp(Obj, propName) would be called, which would return the necessary value. Same for setting a property and calling a method.

The first accessing of the "app" would return a special object, and all other accesses to that object would perform some actions outside the environment of the interpreter.

Is there any way to do this in this interpreter?

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