diff --git a/examples/proto_debuger/base_form.cpp b/examples/proto_debuger/base_form.cpp
index afbb63ce..d1809ffd 100644
--- a/examples/proto_debuger/base_form.cpp
+++ b/examples/proto_debuger/base_form.cpp
@@ -104,12 +104,11 @@ LRESULT BasicForm::HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
mRightShow->SetVisible(false);
p->SetVisible(true);
mRightShow = p;
+ wprintf(L"%s",p->GetName());
mRightSide->SelectItem(p->GetName());
-
}
else {
p->SetVisible(true);
-
mRightSide->SelectItem(p->GetName());
mRightShow = p;
}
diff --git a/examples/proto_debuger/lua_wraper.cpp b/examples/proto_debuger/lua_wraper.cpp
index 0fbb0cb5..198c4c5e 100644
--- a/examples/proto_debuger/lua_wraper.cpp
+++ b/examples/proto_debuger/lua_wraper.cpp
@@ -55,51 +55,6 @@ void LuaDelegate::OnSerialData(std::string data){
lua_call(mVM,1,0);
}
-///
-// 这部分代码可以写成一个统一的c++ 调用lua的接口,核心在于
-// lua_getglobal这个函数调用,其他的参数可以通过回调函数传入,不排除RTTI等技术使用
-//
-//
-//
-//
-void LuaDelegate::OnNetworkData(char *addr, char *data, uint32_t port)
-{
- std::cout<<"call lua network callback";
- int ret = lua_getglobal(mVM,"OnNetworkData");
- if(ret == 0)
- return;
- std::cout<);
+ LuaDelegate(std::map);
int DoFile(std::string);
void Stop();
int DoString(std::string);
int UpdateScript(std::string);
-
- template
- void pushstack(T arg1,Types... rest) {
- const std::type_info &t1 = typeid(arg1);
- pushstack(rest...);
+ template
+ void pushstack(T arg1);
+ void pushstack(lua_Number arg) {
+ lua_pushnumber(mVM, arg);
}
+ void pushstack(lua_Integer arg) {
+ lua_pushinteger(mVM, arg);
+ }
+ void pushstack(void* arg) {
+ lua_pushlightuserdata(mVM, arg);
+ }
+ void pushstack(const char* arg) {
+ lua_pushstring(mVM,arg);
+ }
+ void pushstack(bool arg) {
+ lua_pushboolean (mVM, arg);
+ }
+ void pushstack(std::string arg) {
+ lua_pushstring(mVM, arg.c_str());
+ }
+ void pushstack(lua_CFunction fn, int n) {
+ lua_pushcclosure(mVM, fn, n);
+ }
+ template
+ void pushstack(T arg1, Types... rest);
+ template
+ void pushstack(lua_Number arg1, Types... rest) {
+ lua_pushnumber(mVM, arg1);
+ pushstack(rest...);
+ }
+ template
+ void pushstack(lua_Integer arg1, Types... rest) {
+ lua_pushinteger (mVM, arg1);
+ pushstack(rest...);
+ }
+ template
+ void pushstack(bool arg1, Types... rest) {
+ lua_pushboolean(mVM, arg1);
+ pushstack(rest...);
+ }
+ template
+ void pushstack(std::string arg1, Types... rest) {
+ lua_pushstring(mVM, arg1.c_str());
+ pushstack(rest...);
+ }
+ template
+ void pushstack(void* arg1, Types... rest) {
+ lua_pushlightuserdata(mVM, arg1);
+ pushstack(rest...);
+ }
+ template
+ void pushstack(lua_CFunction fn, int n, Types... rest) {
+ lua_pushcclosure(mVM, fn,n);
+ pushstack(rest...);
+ }
+ template
+ void pushstack(const char* arg1, Types... rest) {
+ lua_pushstring(mVM, arg1);
+ pushstack(rest...);
+ }
template
void CallFuntion(std::string name,T... para){
int i = lua_getglobal(mVM,name.c_str());
@@ -39,6 +93,7 @@ public:
}
pushstack(para...);
}
+
void PrintError(lua_State *L);
void OnSerialData(std::string);
diff --git a/examples/proto_debuger/main.cpp b/examples/proto_debuger/main.cpp
index cac8f399..34d370a7 100644
--- a/examples/proto_debuger/main.cpp
+++ b/examples/proto_debuger/main.cpp
@@ -5,6 +5,8 @@
#include "base_form.h"
#include"resource1.h"
#include
+#include "lua_wraper.h"
+
enum ThreadId
{
@@ -47,6 +49,11 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
AllocConsole();
freopen("CONOUT$", "w", stdout);
+ LuaDelegate lua;
+ std::cout << std::endl;
+
+ lua.CallFuntion< lua_Number>(std::string("sds"),
+ 123.0);
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
diff --git a/examples/proto_debuger/tcp_client_form.cpp b/examples/proto_debuger/tcp_client_form.cpp
index 4592c106..07b54560 100644
--- a/examples/proto_debuger/tcp_client_form.cpp
+++ b/examples/proto_debuger/tcp_client_form.cpp
@@ -1,4 +1,5 @@
#include "tcp_client_form.h"
+#include "utils.h"
TcpClientForm::TcpClientForm(ui::Window* hwnd,std::string url, uint32_t port, TcpClientLibevent* p)
{
@@ -6,6 +7,9 @@ TcpClientForm::TcpClientForm(ui::Window* hwnd,std::string url, uint32_t port, Tc
if (nullptr != hwnd) {
this->SetWindow(hwnd, nullptr, false);
}
+ m_url = url;
+ m_port = port;
+
}
void TcpClientForm::Init()
@@ -22,6 +26,11 @@ void TcpClientForm::Init()
m_check_box_3 = dynamic_cast(FindSubControl(L"check_hex_send"));
m_check_box_4 = dynamic_cast(FindSubControl(L"check_hex_recv"));
+
+ wchar_t p[100] = { 0 };
+ wsprintf(p, L"ַ%s,˿ں%d ", string2wstring(m_url).c_str(),m_port);
+ m_label_1->SetText(std::wstring(p));
+
}
diff --git a/examples/proto_debuger/tcp_client_form.h b/examples/proto_debuger/tcp_client_form.h
index 7898ac25..0295846b 100644
--- a/examples/proto_debuger/tcp_client_form.h
+++ b/examples/proto_debuger/tcp_client_form.h
@@ -36,4 +36,7 @@ private:
virtual void HandleMessage(ui::EventArgs& msg);
+ std::string m_url;
+ int m_port;
+
};
\ No newline at end of file