|
|
|
Регистрация метода в Lua
|
|||
|---|---|---|---|
|
#18+
Добрый день || вечер || …! Не подскажете, почему я не могу зарегистрировать метод класса как функцию в lua??? Выпадает вот такая ошибка: error C2664: 'lua_pushcclosure' : cannot convert parameter 2 from 'int (struct lua_State *)' to 'int (__cdecl *)(struct lua_State *)' None of the functions with this name in scope match the target type И что же делать? Нужно то всего перенести метод в скрипт который установил бы некоторые свойства и добавлял бы элементы в wxListCtrl (см. ниже), может кто сталкивался с подобным? Файл MyFrame.h: extern "C"{ #include "lauxlib.h" #include "lua.h" #include "lualib.h" } #pragma comment(lib, "lua502.lib") class main_win:public wxFrame { public: main_win(); main_win(wxWindow* parent, wxWindowID id, const wxString& title = wxT(""), const void lua_init(); void lua_deinit(); int l_add_item_kadr( lua_State *l); // экспортировать в скрипт void add_item_kadr_prep(const char* fio, const char* mr, const char* stavka, const char* ch); lua_State *l_state; wxListCtrl *kadr_prep; … }; Файл MyFrame.cpp: #include "MyFrame.h" int main_win::l_add_item_kadr(lua_State *l) { add_item_kadr_prep(lua_tostring(l, -4), lua_tostring(l, -3), lua_tostring(l, -2), lua_tostring(l, -1)); return 1; } void main_win::lua_init() { l_state = lua_open(); lua_baselibopen(l_state); lua_tablibopen(l_state); lua_iolibopen(l_state); lua_strlibopen(l_state); lua_mathlibopen(l_state); lua_dblibopen(l_state); lua_register(l_state, "add_item_kadr", l_add_item_kadr); // УПС } void main_win::lua_deinit() { lua_close(l_state); } main_win::main_win(…) { Create(parent,id,title,pos,size,style,name); kadr_prep=new wxListCtrl(panel2,-1,wxPoint(6,18),wxSize(20,20),wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_HRULES|wxLC_VRULES); lua_init(); lua_dofile(l_state, “config.lua”); lua_deinit(); Refresh(); Centre(); Maximize(true); Show(true); } void main_win::add_item_kadr_prep(const char* fio, const char* mr, const char* stavka, const char* ch) { int size = kadr_prep->GetItemCount(); int num = kadr_prep->InsertItem(size, ""); if (size%2) kadr_prep->SetItemBackgroundColour(size, wxColour(255,255,255)); else kadr_prep->SetItemBackgroundColour(size, wxColour(240,250,240)); kadr_prep->SetItem(num,0, fio); kadr_prep->SetItem(num,1, mr); kadr_prep->SetItem(num,2, stavka); kadr_prep->SetItem(num,3, ch); kadr_prep->Update(); } Файл config.lua: add_item_kadr(“1”, “2”, “3”, “4”); add_item_kadr(“1”, “2”, “3”, “4”); add_item_kadr(“1”, “2”, “3”, “4”); add_item_kadr(“1”, “2”, “3”, “4”); add_item_kadr(“1”, “2”, “3”, “4”); ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 20.02.2006, 10:09 |
|
||
|
|

start [/forum/topic.php?fid=57&tid=2031911]: |
0ms |
get settings: |
11ms |
get forum list: |
17ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
42ms |
get topic data: |
12ms |
get forum data: |
4ms |
get page messages: |
34ms |
get tp. blocked users: |
2ms |
| others: | 252ms |
| total: | 382ms |

| 0 / 0 |
