int InitializeMessages(TMessage *&messages, int &count, CFTPClient *clientInstance) { int size = 3; //we have to know how many messages we know about messages = (TMessage *) malloc(size * sizeof(TMessage)); //allocate enough space for them //and then fill them one by one :( InitMessage(messages[0], CMD_HELP, "help", Binder(&CFTPClient::HandleHelpCommand, clientInstance)); InitMessage(messages[1], CMD_LIST, "list", Binder(&CFTPClient::HandleListCommand, clientInstance)); InitMessage(messages[2], CMD_STAT, "stat", Binder(&CFTPClient::HandleStatCommand, clientInstance)); }
void TAB_enter(TAB_table t, void *key, void *value){ int index; assert(t && key); index = ((unsigned)key) % TABSIZE; t->table[index] = Binder(key, value,t->table[index], t->top); t->top = key; }
EngineEntityT::EngineEntityT(IntrusivePtrT<GameEntityI> Entity_, unsigned long CreationFrameNr) : Entity(Entity_), EntityStateFrameNr(CreationFrameNr), m_BaseLine(), BaseLineFrameNr(CreationFrameNr), m_OldStates() { m_BaseLine=GetState(); for (unsigned long OldStateNr=0; OldStateNr<16 /*MUST be a power of 2*/; OldStateNr++) m_OldStates.PushBack(m_BaseLine); // For entities that are named in the map file (e.g. "Soldier_Barney"), // assign the alter ego to a global variable in the map script with the same name. if (Entity->GetName() != "") { cf::UniScriptStateT& ScriptState = Entity->GetGameWorld()->GetScriptState(); lua_State* LuaState = ScriptState.GetLuaState(); cf::ScriptBinderT Binder(LuaState); // lua_getglobal(LuaState, Entity->GetName().c_str()); // if (!lua_isnil(LuaState, -1)) // Console->Warning("Global variable \""+Entity->GetName()+"\" already exists, overwriting...\n"); // lua_pop(LuaState, 1); Binder.Push(Entity); lua_setglobal(LuaState, Entity->GetName().c_str()); // Console->DevPrint("Info: Entity \""+Entity->GetName()+"\" of class \""+EntClassName+"\" (\""+CppClassName+"\") instantiated.\n"); } }
void S_push(S_table t, S_symbol sym, void *value) { int index; index = ((unsigned)sym) % SIZE; S_binder binder = Binder(sym, value,t->table[index], t->top); //printf("debug sym->name: %s sym: %x index: %d\n", S_name(sym), sym, index); t->table[index] = binder; t->top = binder; }
void TAB_enter(TAB_table t, void *key, void *value) { long index; unsigned long hval = (unsigned long)key; assert(t && key); if( t->hash_func ) hval = (unsigned long)t->hash_func(key); index = hval % t->size; t->table[index] = Binder(key, value, t->table[index], t->top); t->top = key; }
EngineEntityT::~EngineEntityT() { // Remove this entity from the script state. cf::UniScriptStateT& ScriptState = Entity->GetGameWorld()->GetScriptState(); lua_State* LuaState = ScriptState.GetLuaState(); cf::ScriptBinderT Binder(LuaState); if (Binder.IsBound(Entity.get())) { // _G[GameEntityI->GetName()] = nil lua_pushnil(LuaState); lua_setglobal(LuaState, Entity->GetName().c_str()); Binder.Disconnect(Entity.get()); } }
int CommandHandler::Handle(CFTPClient *instance, TParam1 param1, TParam2 param2) { TMethodCallback methodCallback = Binder(callback, instance); return methodCallback(param1, param2); }