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
#!/usr/bin/python | |
#-*- coding: UTF-8 -*- | |
def getA1Notation(num): | |
if num == 0 : | |
print('A') | |
notations = [] | |
alphabetNum = 26 | |
while num != 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
echo off | |
python errorlevel.py | |
echo %ERRORLEVEL% | |
pause |
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 GEventMgr = {} | |
local ClassModule = require "Class" | |
local Traceback = Traceback | |
local globalEventRegCache = {}--eventName<eventName<obj,true>> | |
function GEventMgr.RegEvent( eventName, obj ) | |
if not obj[eventName] then | |
logwarning("GEventMgr.RegEvent","eventName:",eventName,"is not in obj:",ClassModule.GetClassName(obj)) | |
end | |
local eventRegs = globalEventRegCache[eventName] |
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
function class(classname, super) | |
--superType获取父类类型,可以使nil、function以及table. | |
local superType = type(super) | |
local cls | |
--如果父类既不是函数也不是table则说明父类为空 | |
if superType ~= "function" and superType ~= "table" then | |
superType = nil | |
super = nil | |
end |
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
void luaS_resize (lua_State *L, int newsize) { | |
GCObject **newhash; | |
stringtable *tb; | |
int i; | |
if (G(L)->gcstate == GCSsweepstring) | |
return; /* cannot resize during GC traverse */ | |
newhash = luaM_newvector(L, newsize, GCObject *); | |
tb = &G(L)->strt; | |
for (i=0; i<newsize; i++) newhash[i] = NULL; | |
/* rehash */ |
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
/* | |
** search function for integers | |
*/ | |
const TValue *luaH_getnum (Table *t, int key) { | |
/* (1 <= key && key <= t->sizearray) */ | |
if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray))//如果输入的Key是一个正整数,并且它的位大于0并且少等于或等于数组的大小,尝试在数组部分查找 | |
return &t->array[key-1]; | |
else {//如果不是,尝试在散列表部分查找,计算出该`Key`的散列值,根据此散列值访问`Node`数组得到散列桶所在的位置,遍历该散列桶下的所有链表元素,直到找到该`Key`为止。 | |
lua_Number nk = cast_num(key); | |
Node *n = hashnum(t, nk); |
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
void luaC_link (lua_State *L, GCObject *o, lu_byte tt) { | |
global_State *g = G(L); | |
o->gch.next = g->rootgc; | |
g->rootgc = o;//将对象挂载到 rootgc链表上 | |
o->gch.marked = luaC_white(g);//设置颜色为白色 | |
o->gch.tt = tt;//设置数据的类型 | |
} | |
void luaC_linkupval (lua_State *L, UpVal *uv) { | |
global_State *g = G(L); |
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
static void f_parser (lua_State *L, void *ud) { | |
int i; | |
Proto *tf; | |
Closure *cl; | |
struct SParser *p = cast(struct SParser *, ud); | |
int c = luaZ_lookahead(p->z); | |
luaC_checkGC(L); | |
tf = ((c == LUA_SIGNATURE[0]) ? luaU_undump : luaY_parser)(L, p->z, | |
&p->buff, p->name); | |
cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); |
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
/* | |
** basic types | |
*/ | |
#define LUA_TNONE (-1) | |
#define LUA_TNIL 0 | |
#define LUA_TBOOLEAN 1 | |
#define LUA_TLIGHTUSERDATA 2 //void * | |
#define LUA_TNUMBER 3 //lua3后采用double精度表示数字整型 | |
#define LUA_TSTRING 4 //TString |
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
LUA_API lua_State *lua_newthread (lua_State *L) { | |
lua_State *L1; | |
lua_lock(L); | |
luaC_checkGC(L); | |
L1 = luaE_newthread(L); | |
setthvalue(L, L->top, L1); | |
api_incr_top(L); | |
lua_unlock(L); | |
luai_userstatethread(L, L1); | |
return L1; |
OlderNewer