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
@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 Jul 5, 2017
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>
@cloudwu
cloudwu / pimpl.cpp
Last active Jul 3, 2017
My version of pimpl
View pimpl.cpp
// My version of pimpl (cloudwu@gmail.com)
// See http://en.cppreference.com/w/cpp/language/pimpl
#include <iostream>
// interface (widget.h)
class widget {
struct impl;
public:
static widget* create(int); // replacement of new
@cloudwu
cloudwu / ttfont.c
Last active May 8, 2019
sample for stb truetype
View ttfont.c
#include <stdio.h>
#define HEIGHT 24
#define STB_TRUETYPE_IMPLEMENTATION
#define STBTT_STATIC
// gcc -Wall -Wno-unused-function -g ttfont.c -o ttfont.exe
// https://github.com/nothings/stb/blob/master/stb_truetype.h
#include "stb_truetype.h"
You can’t perform that action at this time.