00001 #include "luapp_state.hpp" 00002 #include "luapp_function.hpp" 00003 00004 namespace lua 00005 { 00006 data::data() : sName_(""), mLuaType_(TYPE_NIL), pParent_(nullptr) 00007 { 00008 } 00009 00010 data::data(const std::string& name, type mLuaType, argument* pParent) : 00011 sName_(name), mLuaType_(mLuaType), pParent_(pParent) 00012 { 00013 } 00014 00015 void data::set(state* pLua, int iIndex) 00016 { 00017 if (mLuaType_ == TYPE_BOOLEAN) 00018 mValue_ = pLua->get_bool(iIndex); 00019 else if (mLuaType_ == TYPE_NUMBER) 00020 mValue_ = pLua->get_number(iIndex); 00021 else if (mLuaType_ == TYPE_STRING) 00022 mValue_ = pLua->get_string(iIndex); 00023 else if (mLuaType_ == TYPE_TABLE) 00024 mValue_ = iIndex; 00025 else if (mLuaType_ == TYPE_FUNCTION) 00026 mValue_ = iIndex; 00027 else if (mLuaType_ == TYPE_USERDATA) 00028 mValue_ = iIndex; 00029 else if (mLuaType_ == TYPE_NIL) 00030 mValue_ = var(); 00031 00032 pParent_->set_data(this); 00033 } 00034 00035 const std::string& data::get_name() const 00036 { 00037 return sName_; 00038 } 00039 00040 const var& data::get_value() const 00041 { 00042 return mValue_; 00043 } 00044 00045 type data::get_type() const 00046 { 00047 return mLuaType_; 00048 } 00049 }