Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8271 in orxonox.OLD for trunk/src/lib/script_engine


Ignore:
Timestamp:
Jun 8, 2006, 4:50:50 PM (18 years ago)
Author:
bensch
Message:

merge

Location:
trunk/src/lib/script_engine
Files:
4 deleted
3 edited
9 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/script_engine/Makefile.am

    r8061 r8271  
    11MAINSRCDIR=../..
    22include $(MAINSRCDIR)/defs/include_paths.am
     3
     4
     5LIB_PREFIX=$(MAINSRCDIR)/lib
     6include $(MAINSRCDIR)/lib/BuildLibs.am
     7
     8
    39
    410INCLUDES= -I../../../extern_libs
     
    612noinst_LIBRARIES = libORXscript.a
    713
    8 libORXscript_a_SOURCES =
     14libORXscript_a_SOURCES = \
     15                script.cc\
     16                script_manager.cc\
     17                script_class.cc\
     18                account.cc \
     19                object.cc
     20
    921
    1022AM_CPPFLAGS= @LUA_INCLUDES@
    1123
    12 bin_PROGRAMS = account
    13 account_SOURCES = \
    14                 account.cc\
    15                 Script.cc
     24noinst_HEADERS = \
     25                lunar.h\
     26                script.h\
     27                script_manager.h\
     28                script_class.h
    1629
    1730
    1831
    19 account_LDADD = libORXscript.a -L../../../extern_libs @LUA_LIBS@
    2032
    21 #main_LDFLAGS =
     33check_PROGRAMS = example
    2234
    2335
    24 noinst_HEADERS = \
    25                 lunar.h\
    26                 Script.h
     36
     37
     38
     39
     40
     41example_DEPENDENCIES = \
     42                $(MAINSRCDIR)/world_entities/libORXwe.a \
     43                $(libORXlibs_a_LIBRARIES_) \
     44                $(MAINSRCDIR)/util/libORXutils.a
     45
     46example_LDADD = \
     47                $(MAINSRCDIR)/util/libORXutils.a \
     48                $(libORXlibs_a_LIBRARIES_) \
     49                libORXscript.a -L../../../extern_libs @LUA_LIBS@ \
     50                $(MAINSRCDIR)/world_entities/libORXwe.a \
     51                $(libORXlibs_a_LIBRARIES_) \
     52                $(MAINSRCDIR)/util/libORXutils.a
     53
     54example_SOURCES= \
     55                example.cc \
     56                \
     57                ../util/executor/executor_lua.cc
  • trunk/src/lib/script_engine/lunar.h

    r8061 r8271  
    33
    44#include <string>
    5 #include "Script.h"
     5#include <cassert>
     6#include "script.h"
    67
    78#include "luaincl.h"
     9#include "executor/executor_lua.h"
    810
    911
     
    1214      typedef struct { T *pT; } userdataType;
    1315    public:
    14       typedef int (T::*mfp)(lua_State *L);
     16      typedef Executor* mfp;
    1517      typedef struct { const char *name; mfp mfunc; } RegType;
    1618
     
    139141      static int insertObject(Script* script, T* obj, const std::string& name, bool gc=false)
    140142      {
    141         if(script != NULL)
    142           return insertObject(script->getLuaState(), obj, name, gc);
    143 
    144 
     143        assert (script != NULL);
     144        return insertObject(script->getLuaState(), obj, name, gc);
    145145      }
    146146
     
    163163        // get member function from upvalue
    164164        RegType *l = static_cast<RegType*>(lua_touserdata(L, lua_upvalueindex(1)));
    165         return (obj->*(l->mfunc))(L);  // call member function
     165        int value;
     166        (*l->mfunc)(obj, value, L);  // call member function
     167        return value;
    166168      }
    167169
  • trunk/src/lib/script_engine/lunartest2.lua

    r8061 r8271  
    1515getmetatable(Account).__index = parent
    1616
     17
     18function test()
     19io.write("Hi i'm test\n")
     20end
     21
     22
    1723function main(arg)
     24  -- use parameter
    1825  io.write("main received ", arg)
    1926  io.write(" as parameter\n")
     27
     28  --call member of an inserted object
    2029  Obj:printName()
     30
     31  --create object of a registered type
     32  o = Object()
     33  o:printName()
     34
     35  --take returnvalue from c
     36  callCount = Obj:getCallCount()
     37  io.write("callCount is now ",callCount)
     38  io.write("\n")
     39
     40  --pass parameters to a c++ method
     41  Obj:takeParam(3)
     42
     43  --print object information
    2144  print('a =', a)
    2245  print('b =', b)
     
    2851  Obj:printName()
    2952
    30   return 2
     53  return 2,false,2.72
     54
    3155  --debug.debug()
    3256end
Note: See TracChangeset for help on using the changeset viewer.