Skip to content

Instantly share code, notes, and snippets.

云风 cloudwu

Block or report user

Report or block cloudwu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cacheserver.lua
local skynet = require "skynet"
local socket = require "skynet.socket"
local db_path = assert(skynet.getenv "cache_db") .. "/"
local mode = (...) or "main"
local function tohex(c)
return string.format("%02x", c:byte())
end
@cloudwu
cloudwu / bgfxcsgen.lua
Created Jun 27, 2019
Generate c shape interface for bgfx
View bgfxcsgen.lua
local idl = require "idl"
do
local doxygen = require "doxygen"
local source = doxygen.load "bgfx.idl"
local f = assert(load(source, "bgfx.idl" , "t", idl))
f()
local codegen = require "codegen"
codegen.nameconversion(idl.types, idl.funcs)
@cloudwu
cloudwu / luavm.c
Created Aug 15, 2018
Lua VM wrapper
View luavm.c
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#include <stdarg.h>
#include <string.h>
#define ERRLOG 1
#define MSGTABLE 2
#define RETOP 2
@cloudwu
cloudwu / tableunpack.c
Created Jun 22, 2018
unpack lua table { ... }
View tableunpack.c
// Unpack lua table create by { ... }
#define LUA_LIB
#include <lua.h>
#include <lauxlib.h>
static int
max_index(lua_State *L, int index) {
int n = lua_rawlen(L, index);
if (n == 0) {
View report.txt
net=5.422477ms,cluster=91.399046ms,cpu=323.263431ms,latency=5.447901ms,time=425.532855ms
login1:00000063 122.286771ms trace gm
login1:00000063 102.904420ms(net=3.207950ms,cluster=0.250590ms,cpu=3.580064ms,time=7.038604ms) call : @./service/agent/player/war_base.lua:363 @./service/agent/player/war_base.lua:130 @./service/agent/agent_lock.lua:62
login1:00000009 3.568610ms request
login1:00000009 3.458540ms(time=0.250590ms) sleep : @./skynet/lualib/skynet/socketchannel.lua:374 @./skynet/service/clusterd.lua:147 @./skynet/service/clusterd.lua:252
center:0000005d 0.250590ms tracecall begin
center:00000056 0.069562ms request
center:00000056 response
center:0000005d tracecall end
login1:00000009 0.011454ms resume
@cloudwu
cloudwu / linalg.c
Last active Jul 18, 2018
A linear algebra lua library
View linalg.c
// C module for data stack manager
// See below for lua lib wrapper
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define MINCAP 128
View ecs.lua
local core = require "ecs.core"
local ecs = {}
local entities = {} -- all Entities, eid -> entity
local entity_id = 0
ecs.entities = entities
-- cset: component set
local cset = { __mode = "kv" }
View shadowcopy.lua
local shadowcopy = {}
local weak = { __mode = "k" }
local NIL = {}
local queue = setmetatable({}, weak) -- object -> queue
local map = setmetatable({}, weak) -- copy -> { object = obj, values = {} }
local direct_mt = {
__index = function(t,k)
@cloudwu
cloudwu / pdx.lua
Created Jul 7, 2017
paradox file parser
View pdx.lua
local pdx = {}
do
local lpeg = require "lpeg"
local P = lpeg.P
local S = lpeg.S
local R = lpeg.R
local C = lpeg.C
@cloudwu
cloudwu / lclonetable.c
Last active Sep 17, 2019
Clone a lua table
View lclonetable.c
// gcc -o clonetable.so --shared lclonetable.c -I$(LUAINCLUDE)
#include <lobject.h>
#include <ltable.h>
#include <lgc.h>
#include <lstate.h>
#include <lauxlib.h>
#include <lualib.h>
#include <lua.h>
#include <string.h>
You can’t perform that action at this time.