| 1 | /* | 
|---|
| 2 |    orxonox - the future of 3D-vertical-scrollers | 
|---|
| 3 |  | 
|---|
| 4 |    Copyright (C) 2004 orx | 
|---|
| 5 |  | 
|---|
| 6 |    This program is free software; you can redistribute it and/or modify | 
|---|
| 7 |    it under the terms of the GNU General Public License as published by | 
|---|
| 8 |    the Free Software Foundation; either version 2, or (at your option) | 
|---|
| 9 |    any later version. | 
|---|
| 10 |  | 
|---|
| 11 |    ### File Specific: | 
|---|
| 12 |    main-programmer: Benjamin Grauer | 
|---|
| 13 |    co-programmer: ... | 
|---|
| 14 | */ | 
|---|
| 15 |  | 
|---|
| 16 | //#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ | 
|---|
| 17 |  | 
|---|
| 18 | #include "script_class.h" | 
|---|
| 19 | #include "script.h" | 
|---|
| 20 | #include "debug.h" | 
|---|
| 21 | #include <cassert> | 
|---|
| 22 |  | 
|---|
| 23 | ObjectListDefinition(ScriptClass); | 
|---|
| 24 |  | 
|---|
| 25 | CREATE_SCRIPTABLE_CLASS(Script, | 
|---|
| 26 |                     addMethod("addObject", Executor2<Script, lua_State*,const std::string&, const std::string& >(&Script::addObject)) | 
|---|
| 27 |                     ->addMethod("addObjectAsName", Executor3<Script, lua_State*,const std::string&, const std::string&, const std::string& >(&Script::addObjectAsName)) | 
|---|
| 28 |                     ->addMethod("registerClass", Executor1<Script, lua_State*,const std::string&>(&Script::registerClass)) | 
|---|
| 29 |                     ->addMethod("selectFunction", Executor2ret<Script, lua_State*, bool, const std::string&, int >(&Script::selectFunction)) | 
|---|
| 30 |                     ->addMethod("executeFunction", Executor0ret<Script, lua_State*,bool >(&Script::executeFunction)) | 
|---|
| 31 |                      ); | 
|---|
| 32 | /** | 
|---|
| 33 |  * @brief standard constructor | 
|---|
| 34 |  * @todo this constructor is not jet implemented - do it | 
|---|
| 35 | */ | 
|---|
| 36 | ScriptClass::ScriptClass(const std::string& name, const ClassID& classID, ScriptMethod* scriptMethods) | 
|---|
| 37 |     : BaseObject(name), _classID(classID) | 
|---|
| 38 | { | 
|---|
| 39 |   PRINTF(4)("Name %s\n", name.c_str()); | 
|---|
| 40 |   assert(scriptMethods != NULL); | 
|---|
| 41 |   this->registerObject(this, ScriptClass::_objectList); | 
|---|
| 42 |  | 
|---|
| 43 |   this->_classID = classID; | 
|---|
| 44 |  | 
|---|
| 45 |   this->_scriptMethods = scriptMethods; | 
|---|
| 46 | } | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 | /** | 
|---|
| 50 |  * standard deconstructor | 
|---|
| 51 | */ | 
|---|
| 52 | ScriptClass::~ScriptClass () | 
|---|
| 53 | { | 
|---|
| 54 |   delete this->_scriptMethods; | 
|---|
| 55 | } | 
|---|