strattonbrazil
12th July 2011, 17:15
Could someone explain to me how to get namespacing in the QScriptEngine extensions? I've set it up so I have a directory foo/ under script/, with an __init__.js file being executed.
Here's my javascript file:
__setupPackage__(__extension__);
print(__extension__);
hello = function() { return 5; };
And in my C++ code:
engine.evaluate("hello();"); // works fine
So my question is, what's the point of the file hierarchy like foo/bar/whatever (foo.bar.whatever), if they all get lumped into a global namespace? I've seen some examples, where they try to create a namespace in the code, but I can't seem to get that to work without getting a compiler error.
foo = {
hello : function() { return 5; }
};
engine.evaluate("foo.hello();");
Am I misunderstanding the way Qt handles namespaces? Should everything indeed be mashed into a global scope regardless of which file it was taken from? Is there a proper example for creating these type of namespaces? Thanks.
Here's my javascript file:
__setupPackage__(__extension__);
print(__extension__);
hello = function() { return 5; };
And in my C++ code:
engine.evaluate("hello();"); // works fine
So my question is, what's the point of the file hierarchy like foo/bar/whatever (foo.bar.whatever), if they all get lumped into a global namespace? I've seen some examples, where they try to create a namespace in the code, but I can't seem to get that to work without getting a compiler error.
foo = {
hello : function() { return 5; }
};
engine.evaluate("foo.hello();");
Am I misunderstanding the way Qt handles namespaces? Should everything indeed be mashed into a global scope regardless of which file it was taken from? Is there a proper example for creating these type of namespaces? Thanks.