Giter Site home page Giter Site logo

tiny-js's Issues

CTinyJS not defined?

I have tried to compile TinyJS on my Mac, but got:

Script.cpp:50:5: error: use of undeclared identifier 'CTinyJS'; did you mean 'TinyJS'?
    CTinyJS *js = (CTinyJS*)userdata;
    ^~~~~~~
    TinyJS
./TinyJS_Functions.h:35:11: note: 'TinyJS' declared here
namespace TinyJS {
          ^
Script.cpp:50:5: error: unexpected namespace name 'TinyJS': expected expression
    CTinyJS *js = (CTinyJS*)userdata;
    ^
Script.cpp:50:14: error: use of undeclared identifier 'js'
    CTinyJS *js = (CTinyJS*)userdata;
             ^
Script.cpp:50:20: error: use of undeclared identifier 'CTinyJS'; did you mean 'TinyJS'?
    CTinyJS *js = (CTinyJS*)userdata;
                   ^~~~~~~
                   TinyJS
./TinyJS_Functions.h:35:11: note: 'TinyJS' declared here
namespace TinyJS {
          ^
Script.cpp:50:20: error: unexpected namespace name 'TinyJS': expected expression
    CTinyJS *js = (CTinyJS*)userdata;
                   ^
Script.cpp:50:28: error: expected expression
    CTinyJS *js = (CTinyJS*)userdata;
                           ^
Script.cpp:51:5: error: use of undeclared identifier 'js'
    js->root->trace(">  ");
    ^
7 errors generated.

Should I use -DCTinyJS=TinyJS, maybe?

Get name of a cloned objects definition

Is there a way to get the name of an object? For e.g if i create an object like this

var myBaseObject = {
    name: "Test",
    value: 3
};

and now i want to get the name of the object myBaseObject. How can i do that? For e.g i want to write a function to tell me the name of the object

var test = myBaseObject.clone();
var theName = test.getObjectName();

Afterwards the variable theName should output myBaseObjetct.

Is that possible?

String.split

auto jsEngine = make_unique<CTinyJS>();
registerFunctions(jsEngine.get());
string js = "String('ape katt').split(' ');";
jsEngine->execute(js);

==> Error Expecting 'String' to be a function

build error Script.cpp:50:5: CTinyJS was not declared in this scope

commit db198df

Error details (console output)
make g++ -c -g -Wall -rdynamic -D_DEBUG run_tests.cpp -o run_tests.o g++ -c -g -Wall -rdynamic -D_DEBUG TinyJS.cpp -o TinyJS.o g++ -c -g -Wall -rdynamic -D_DEBUG TinyJS_Functions.cpp -o TinyJS_Functions.o g++ -c -g -Wall -rdynamic -D_DEBUG TinyJS_MathFunctions.cpp -o TinyJS_MathFunctions.o g++ -g -rdynamic run_tests.o TinyJS.o TinyJS_Functions.o TinyJS_MathFunctions.o -o run_tests g++ -c -g -Wall -rdynamic -D_DEBUG Script.cpp -o Script.o Script.cpp: In function ‘void js_dump(TinyJS::Variable*, void*)’: Script.cpp:50:5: error: ‘CTinyJS’ was not declared in this scope CTinyJS *js = (CTinyJS*)userdata; ^~~~~~~ Script.cpp:50:14: error: ‘js’ was not declared in this scope CTinyJS *js = (CTinyJS*)userdata; ^~ Script.cpp:50:28: error: expected primary-expression before ‘)’ token CTinyJS *js = (CTinyJS*)userdata; ^ Makefile:21: recipe for target 'Script.o' failed make: *** [Script.o] Error 1

Solution
replace in file Script.cpp line 50
CTinyJS *js = (CTinyJS*)userdata;
with
TinyJS::Interpreter *js = (TinyJS::Interpreter*)userdata;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.