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