Common Language Extension(CLE) is a realization of common object environment. It manages interface objects and presents interface to c/c++, lua, java, python, php, c#, etc. Through these interface, special language can create, define, and control interface objects, define their functions and events, or call their functions.
Architecture of objects in CLE is as follows,
Objects are grouped into four kinds: service group object, service object, service item object, object, where service item object may be not existed if you do not develop distributed applications.
Applications based on CLE, mainly is create and init the above four kinds of object. Specific functions or events are provided by object.
The following code is a simple example for java calling lua.
String LuaString;
LuaString = "SrvGroup = libstarcore._GetSrvGroup()\n";
LuaString = LuaString + "Service = SrvGroup:_GetService(\"\",\"\")\n";
LuaString = LuaString + "Obj=Service:_New(\"TestClass\");\n";
LuaString = LuaString + "function Obj:Add(x,y)\n";
LuaString = LuaString + " return x+y;\n";
LuaString = LuaString + "end\n";
Service._CheckPassword(false);
SrvGroup._RunScript("lua",LuaString,"");
StarObjectClass Obj = Service._GetObject("TestClass")._New();
System.out.println(Obj._Call("Add",234,567));
In above example, Interface object “TestClass” is defined by lua, for java to call its function “Add”, a new instance of TestClass is created using java language.