Go Back   ZeroC Forums > Projects

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 02-05-2009
Sheff Sheff is offline
Registered User
 
Name: Stanislav Vorobiov
Organization: FocusMedia
Project: Object System
 
Join Date: Nov 2008
Posts: 13
tree script and slice2lua

While working on a distributed object network project in my company, I've came across with Ice and I've had (and having) great experiences
with it, thanks to guys at ZeroC !!!
During my work on the project I've developed several tools for Ice, one of them is 'tree script' and other is slice2lua.

1.tree script. is a small scripting language that allows you to make calls to ice server without having the slice interfaces, using dynamic
Ice. For example, suppose I have the following slice definition on server:
Code:
module MyMod {

class TestA
{
    float a;
    int b;
};
    
class TestB extends TestA
{
    TestA c;
    int d;
    TestA e;        
};

interface SomeInterface
{              
    TestA someFunc(TestA a, TestB b, out TestB c);
};

};
I can invoke operation 'someFunc' from client, without having those slice interfaces, from tree script like this:
Code:
/* command 'call' states that we want to make a function call */
call
/* a call can be 'normal' or 'idempotent' */
normal 
/*since we don't have a slice interface we need to describe the return
   types explicitly, here we describe the TestB type, we describe all members
   of a class TestB and all it's slices using special syntax */
(
  ((float int) int (float int) | float int) /* the type of 'out c', which is TestB */
  (float int) /* the return type, which is TestA */
)
/*next, we must specify an identity of an object on which we want to
   call a method */
/path/to/object/on/server
// next we specify the name of the method
someFunc
// the input parameters follow
(::MyMod::TestA 12.34f 11i) /* the value of the first parameter */
( /* the value of the second parameter*/
    ::MyMod::TestB /* typeid of first slice */
    (::MyMod::TestA 1.2f 2i) 9i (::MyMod::TestA 1.3f 3i) /* first slice data */
    ::MyMod::TestA /* typeid of second slice */
    0.1f 12i /* second slice data */
);
'tree scipt' supports all slice basic data types, structs, classes, sequences, dictionaries and all their superpositions.
one thing 'tree script' doesn't support is proxies, because that would make a need for variables in the language and would add extra complexity,
and I just needed a simple scripting language that could invoke methods and display return values.

2.slice2lua is a slice compiler (which uses libSlice) which generates C++ code that allows you to access Ice objects from lua scripts.
You just compile your .ice files, create lua_State* from your program/library, pass that context to initialization function and
there you have access to all Ice stuff from lua (in that particular context). You can invoke methods on classes/interfaces/proxies, set/get
data members, instanciate objects, create and register proxies with object adapter, etc.
slice2lua also generates so called 'server-side code', which allows you to write Ice servants in lua, i.e when some remote caller calls
a method on your servant, that servant calls lua function and it does all the processing.
Also slice2lua supports almost all of the options slice2cpp supports on command line.
slice2lua can be very handy if you want to script some behaviour in your ice client or server.

Right now those utilities are part of another project, but if someone is interested I can easily make them separate and place source code
on sourceforge or something...
Reply With Quote
  #2 (permalink)  
Old 03-16-2009
skosenko skosenko is offline
Registered User
 
Name: Sergey Kosenko
Organization: Credit Suisse
Project: POC
 
Join Date: Nov 2008
Posts: 5
Stanislav,

There might be a great degree of interest to slice2lua of yours. I could use it for custom expression evaluator in one of the projects of mine - low latency derivatives risk management system. Could you post your code here? It might save us quite a bit of time.

Thanks,
Sergei Kosenko
Reply With Quote
  #3 (permalink)  
Old 03-17-2009
Sheff Sheff is offline
Registered User
 
Name: Stanislav Vorobiov
Organization: FocusMedia
Project: Object System
 
Join Date: Nov 2008
Posts: 13
Hello.
As I was saying before, the slice2lua project right now is in another project tree,
and unfortunately I'm too busy to make it a separate project right now with docs, tests, demos, etc... If you're in a hurry I can publish the source code as is, it would compile and work, but there won't be any documentation, demos, etc. If this doesn't stop you I can publish the code within few days, also I'm almost always available via ICQ and jabber, if you'll have any questions I'll gladly help. Do this sound ok to you ?
Reply With Quote
  #4 (permalink)  
Old 03-18-2009
skosenko skosenko is offline
Registered User
 
Name: Sergey Kosenko
Organization: Credit Suisse
Project: POC
 
Join Date: Nov 2008
Posts: 5
Stanislav,

Thanks for your response.
There is no rush here, whenever you can.
Its just feels natural to have LUA language mapping in Ice and it also will help us to save some time.

Thanks,
Sergei Kosenko
Reply With Quote
  #5 (permalink)  
Old 03-19-2009
Sheff Sheff is offline
Registered User
 
Name: Stanislav Vorobiov
Organization: FocusMedia
Project: Object System
 
Join Date: Nov 2008
Posts: 13
I've create a project at sourceforge, svn repository with source code is available here:
https://slice2lua.svn.sourceforge.ne...lice2lua/trunk
right now it only contains slice2lua itself, it's runtime library and demo project I wrote
today in a hurry, it only demonstrates how to use client side lua for now, but that should be a good start for you.
to compile the project you'll need:
1.Ice 3.3.0 source code and dynamic libraries
2.lua 5.1.4 COMPILED WITH C++ (i.e CC=g++) as static library

before compiling open Make.rules at root and edit ICE_HOME, ICE_SOURCE and LUA_HOME as needed, after that run:

make depend
make

if you want to cleanup the tree, run:

make clean

after successful compiling go to bin and launch test_lua.sh, that should run test_lua executable (the demo project).
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script peter Help Center 3 10-29-2009 11:59 AM
could I load more than one ice profile in one php script ucdriver Help Center 5 04-17-2009 03:46 AM
Problems when launch icegridnode inside init.d script xdm Help Center 1 06-21-2006 11:41 PM
how to invoke an external shell script in ice? ewiniar Help Center 2 04-21-2006 03:28 AM
Ice dependency tree eclipze Help Center 2 04-09-2004 05:24 PM


All times are GMT -4. The time now is 11:56 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2009 ZeroC, Inc.