scripting C++

  • Thread starter christopher diggins
  • Start date
C

christopher diggins

Using the OOTL (Object Oriented Template Library, http://www.ootl.org ) it
would very feasable to write a scripting engine for C++ programs.

The way this hypothetical engine would work is that any OOTL object (that is
an object containing the OOTL_DEF_OBJECT macro) could be exposed along with
an interface written using the BIL (Boost Interfaces Library) IDL
(Interfaces Description Language).

Using the scripting library, would look like this (pardon any C++ usage
errors):

CppScriptEngine theEngine;

std::list<ootl::String> gList;

class MyClass {
DEF_OOTL_OBJECT(MyClass);
void Push(ool::String x) {
gList.push_back(x);
}
};

BOOST_IDL_BEGIN(IMyInterface)
BOOST_IDL_FN0(Push, void, (ootl::String, x))
BOOST_IDL_END(IMyInterface)

int main() {
theEngine.Expose("MyClass", MyClass, IMyInterface);
theEngine.RunInteractiveSession();
while (!gList.empty()) {
std::cout << gList.back() << std::endl;
gList.pop_back();
}
return 0;
}

When this program is run, it would go into a console mode, where it would
allow a limited C++ syntax, and support the core OOTL objects, i.e. Int,
Bool, Char, String, etc. So a possible user session might look like this:

String s = "hello";
MyClass m;
m.Push(s);
m.Push("world");
^Z

Does this kind of tool (open-source of course) interest anyone? Anyone
potentially interested in collaborating?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,778
Messages
2,569,605
Members
45,238
Latest member
Top CryptoPodcasts

Latest Threads

Top