mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
remove service_lua.h
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
#include "skynet.h"
|
#include "skynet.h"
|
||||||
#include "lua-seri.h"
|
#include "lua-seri.h"
|
||||||
#include "service_lua.h"
|
|
||||||
|
|
||||||
#define KNRM "\x1B[0m"
|
#define KNRM "\x1B[0m"
|
||||||
#define KRED "\x1B[31m"
|
#define KRED "\x1B[31m"
|
||||||
@@ -11,6 +10,12 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
struct snlua {
|
||||||
|
lua_State * L;
|
||||||
|
struct skynet_context * ctx;
|
||||||
|
const char * preload;
|
||||||
|
};
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_cb(struct skynet_context * context, void * ud, int type, int session, uint32_t source, const void * msg, size_t sz) {
|
_cb(struct skynet_context * context, void * ud, int type, int session, uint32_t source, const void * msg, size_t sz) {
|
||||||
lua_State *L = ud;
|
lua_State *L = ud;
|
||||||
@@ -290,15 +295,14 @@ luaopen_skynet_c(lua_State *L) {
|
|||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "skynet_lua");
|
luaL_newlibtable(L, l);
|
||||||
struct snlua *lua = lua_touserdata(L,-1);
|
|
||||||
if (lua == NULL || lua->ctx == NULL) {
|
lua_getfield(L, LUA_REGISTRYINDEX, "skynet_context");
|
||||||
|
struct skynet_context *ctx = lua_touserdata(L,-1);
|
||||||
|
if (ctx == NULL) {
|
||||||
return luaL_error(L, "Init skynet context first");
|
return luaL_error(L, "Init skynet context first");
|
||||||
}
|
}
|
||||||
assert(lua->L == L);
|
|
||||||
|
|
||||||
luaL_newlibtable(L, l);
|
|
||||||
lua_pushlightuserdata(L, lua->ctx);
|
|
||||||
luaL_setfuncs(L,l,1);
|
luaL_setfuncs(L,l,1);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
|
|
||||||
#include "skynet_socket.h"
|
#include "skynet_socket.h"
|
||||||
#include "service_lua.h"
|
|
||||||
|
|
||||||
#define BACKLOG 32
|
#define BACKLOG 32
|
||||||
// 2 ** 12 == 4096
|
// 2 ** 12 == 4096
|
||||||
@@ -485,15 +484,12 @@ luaopen_socketdriver(lua_State *L) {
|
|||||||
{ "start", lstart },
|
{ "start", lstart },
|
||||||
{ NULL, NULL },
|
{ NULL, NULL },
|
||||||
};
|
};
|
||||||
lua_getfield(L, LUA_REGISTRYINDEX, "skynet_lua");
|
lua_getfield(L, LUA_REGISTRYINDEX, "skynet_context");
|
||||||
struct snlua *lua = lua_touserdata(L,-1);
|
struct skynet_context *ctx = lua_touserdata(L,-1);
|
||||||
if (lua == NULL || lua->ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
return luaL_error(L, "Init skynet context first");
|
return luaL_error(L, "Init skynet context first");
|
||||||
}
|
}
|
||||||
// assert(lua->L == L);
|
|
||||||
lua_pop(L,1);
|
|
||||||
|
|
||||||
lua_pushlightuserdata(L, lua->ctx);
|
|
||||||
luaL_setfuncs(L,l2,1);
|
luaL_setfuncs(L,l2,1);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
#ifndef SKYNET_SERVICE_LUA_H
|
|
||||||
#define SKYNET_SERVICE_LUA_H
|
|
||||||
|
|
||||||
struct snlua {
|
|
||||||
lua_State * L;
|
|
||||||
struct skynet_context * ctx;
|
|
||||||
const char * preload;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -4,13 +4,18 @@
|
|||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
#include <lauxlib.h>
|
#include <lauxlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "service_lua.h"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
struct snlua {
|
||||||
|
lua_State * L;
|
||||||
|
struct skynet_context * ctx;
|
||||||
|
const char * preload;
|
||||||
|
};
|
||||||
|
|
||||||
// LUA_CACHELIB may defined in patched lua for shared proto
|
// LUA_CACHELIB may defined in patched lua for shared proto
|
||||||
#ifdef LUA_CACHELIB
|
#ifdef LUA_CACHELIB
|
||||||
|
|
||||||
@@ -189,8 +194,8 @@ _init(struct snlua *l, struct skynet_context *ctx, const char * args) {
|
|||||||
l->ctx = ctx;
|
l->ctx = ctx;
|
||||||
lua_gc(L, LUA_GCSTOP, 0);
|
lua_gc(L, LUA_GCSTOP, 0);
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
lua_pushlightuserdata(L, l);
|
lua_pushlightuserdata(L, ctx);
|
||||||
lua_setfield(L, LUA_REGISTRYINDEX, "skynet_lua");
|
lua_setfield(L, LUA_REGISTRYINDEX, "skynet_context");
|
||||||
luaL_requiref(L, "skynet.codecache", codecache , 0);
|
luaL_requiref(L, "skynet.codecache", codecache , 0);
|
||||||
lua_pop(L,1);
|
lua_pop(L,1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user