This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local pdx = {} | |
do | |
local lpeg = require "lpeg" | |
local P = lpeg.P | |
local S = lpeg.S | |
local R = lpeg.R | |
local C = lpeg.C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// My version of pimpl ([email protected]) | |
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <lua.h> | |
#include <lauxlib.h> | |
#include <ltable.h> | |
#include <lstate.h> | |
#include <lobject.h> | |
#include <stdio.h> | |
#include <string.h> | |
#define MAGIC_VECTOR 1.23456789 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use mingw in windows | |
// gcc -O2 -o utf8.exe utf8to16.c | |
#include <stdio.h> | |
#include <fcntl.h> | |
#include <io.h> | |
#include <wchar.h> | |
static const char trailingBytesForUTF8[256] = { | |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, | |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -g -Wall -o alloc alloc.c | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <assert.h> | |
#include <string.h> | |
#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) | |
#include <windows.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* $Id: md5.c,v 1.2 2008/03/24 20:59:12 mascarenhas Exp $ | |
* Hash function MD5 | |
* @author Marcela Ozorio Suarez, Roberto I. | |
*/ | |
#include <string.h> | |
//#include "md5.h" |