int luaopen_lgob_gtkglext(lua_State *L) { luaL_loadstring(L, "require('lgob.gtk')"); lua_call(L, 0, 0); luaL_loadstring(L, "glib.handle_log('GtkGLExt')"); lua_call(L, 0, 0); gtk_gl_init(NULL, NULL); luaL_register(L, "gtkglext", gtkglext); luaL_loadstring(L, "gtkglext.Object = gobject.Object"); lua_call(L, 0, 0); /* Register the classes */ register_class(L, "Config", "Object", config); register_class(L, "Widget", "Object", widget); register_class(L, "Drawable", NULL, drawable); /* Register special class table */ lua_getfield(L, LUA_REGISTRYINDEX, "lgobSpecial"); lua_pushliteral(L, "GdkGLWindowImplX11"); lua_getfield(L, -3, "Drawable"); lua_rawset(L, -3); lua_pushliteral(L, "GdkGLWindowImplWin32"); lua_getfield(L, -3, "Drawable"); lua_rawset(L, -3); lua_pop(L, 1); /* GdkGLConfigMode */ lua_pushliteral(L, "MODE_RGB"); lua_pushinteger(L, GDK_GL_MODE_RGB); lua_rawset(L, -3); lua_pushliteral(L, "MODE_RGBA"); lua_pushinteger(L, GDK_GL_MODE_RGBA); lua_rawset(L, -3); lua_pushliteral(L, "MODE_SINGLE"); lua_pushinteger(L, GDK_GL_MODE_SINGLE); lua_rawset(L, -3); lua_pushliteral(L, "MODE_INDEX"); lua_pushinteger(L, GDK_GL_MODE_INDEX); lua_rawset(L, -3); lua_pushliteral(L, "MODE_DOUBLE"); lua_pushinteger(L, GDK_GL_MODE_DOUBLE); lua_rawset(L, -3); lua_pushliteral(L, "MODE_STEREO"); lua_pushinteger(L, GDK_GL_MODE_STEREO); lua_rawset(L, -3); lua_pushliteral(L, "MODE_ALPHA"); lua_pushinteger(L, GDK_GL_MODE_ALPHA); lua_rawset(L, -3); lua_pushliteral(L, "MODE_DEPTH"); lua_pushinteger(L, GDK_GL_MODE_DEPTH); lua_rawset(L, -3); lua_pushliteral(L, "MODE_STENCIL"); lua_pushinteger(L, GDK_GL_MODE_STENCIL); lua_rawset(L, -3); lua_pushliteral(L, "MODE_ACCUM"); lua_pushinteger(L, GDK_GL_MODE_ACCUM); lua_rawset(L, -3); return 1; }
/** Object **/ void ApplicationBase::init(){ Super::init(); // basic ::init_platform(); ObjectPool::Set(New<ObjectPool>()); // misc { OPH(); // logger & monitor Logger::Init(); Monitor::Init(); // process local ProcessLocal::Init(); // register register_misc(); register_lua(); register_protocol(); register_class(); // observer & actor ObserverManager::Init(); ActorManager::Init(); } }
void objc_register_all_classes(struct objc_abi_symtab* symtab) { uint_fast32_t i; for (i = 0; i < symtab->cls_def_cnt; i++) { struct objc_abi_class* cls = (struct objc_abi_class*)symtab->defs[i]; register_class(cls); register_selectors(cls); register_selectors((struct objc_abi_class*)object_getClass((id)cls)); } for (i = 0; i < symtab->cls_def_cnt; i++) { Class cls = (Class)symtab->defs[i]; if (has_load(cls)) { setup_class(cls); if (cls->info & OBJC_CLASS_INFO_SETUP) call_load(cls); else { if (load_queue == NULL) load_queue = malloc(sizeof(Class)); else load_queue = realloc(load_queue, sizeof(Class) * (load_queue_cnt + 1)); if (load_queue == NULL) OBJC_ERROR( "Not enough memory for load " "queue!"); load_queue[load_queue_cnt++] = cls; } } else cls->info |= OBJC_CLASS_INFO_LOADED; } /* Process load queue */ for (i = 0; i < load_queue_cnt; i++) { setup_class(load_queue[i]); if (load_queue[i]->info & OBJC_CLASS_INFO_SETUP) { call_load(load_queue[i]); load_queue_cnt--; if (load_queue_cnt == 0) { free(load_queue); load_queue = NULL; continue; } load_queue[i] = load_queue[load_queue_cnt]; load_queue = realloc(load_queue, sizeof(Class) * load_queue_cnt); if (load_queue == NULL) OBJC_ERROR("Not enough memory for load queue!"); } } }
Splitter::Splitter (Manager& manager) : Droplet(manager), m_collided(false) { if( register_class("Splitter") ) { register_function("Ball", (CollideFunc) &Splitter::collide_with_ball); register_function("Droplet", (CollideFunc) &Splitter::collide_with_droplet); } }
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE dont_care, LPSTR doont_care, int dooont_care) { static LPCTSTR name = _T("Second Reality"); me.hwnd = CreateWindow(register_class(hinst, name), name, WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, NULL, NULL, hinst, NULL); if (me.hwnd) { show_window(me.hwnd, 640, 480); QueryPerformanceCounter(&me.initial_perf_counter); QueryPerformanceFrequency(&me.perf_frequency); demo_execute(); } return 0; }
/** * @brief 初始化 * * @return 成功返回0,失败返回失败的步骤 */ int init(int argc, char **argv) { init_print_level(); ///< console 消息级别 global_container_init(); ///<对象容器初始化 install_sighandler(); ///<安装信号处理函数 register_class(); poller_create(POLLER_MAX); app_init(argc, argv); if(system_threads() < 0) return -2; return 0; }
static void test_handles(void) { HWINSTA w1, w2, w3; HDESK d1, d2, d3; HANDLE hthread; DWORD id, flags, le; ATOM atom; char buffer[20]; /* win stations */ w1 = GetProcessWindowStation(); ok( GetProcessWindowStation() == w1, "GetProcessWindowStation returned different handles\n" ); ok( !CloseWindowStation(w1), "closing process win station succeeded\n" ); SetLastError( 0xdeadbeef ); ok( !CloseHandle(w1), "closing process win station handle succeeded\n" ); ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %d\n", GetLastError() ); print_object( w1 ); flags = 0; ok( GetHandleInformation( w1, &flags ), "GetHandleInformation failed\n" ); ok( !(flags & HANDLE_FLAG_PROTECT_FROM_CLOSE) || broken(flags & HANDLE_FLAG_PROTECT_FROM_CLOSE), /* set on nt4 */ "handle %p PROTECT_FROM_CLOSE set\n", w1 ); ok( DuplicateHandle( GetCurrentProcess(), w1, GetCurrentProcess(), (PHANDLE)&w2, 0, TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" ); ok( CloseWindowStation(w2), "closing dup win station failed\n" ); ok( DuplicateHandle( GetCurrentProcess(), w1, GetCurrentProcess(), (PHANDLE)&w2, 0, TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" ); ok( CloseHandle(w2), "closing dup win station handle failed\n" ); w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); le = GetLastError(); ok( w2 != 0 || le == ERROR_ACCESS_DENIED, "CreateWindowStation failed (%u)\n", le ); if (w2 != 0) { ok( w2 != w1, "CreateWindowStation returned default handle\n" ); SetLastError( 0xdeadbeef ); ok( !CloseDesktop( (HDESK)w2 ), "CloseDesktop succeeded on win station\n" ); ok( GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == 0xdeadbeef), /* wow64 */ "bad last error %d\n", GetLastError() ); ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); w2 = CreateWindowStation("WinSta0", 0, WINSTA_ALL_ACCESS, NULL ); ok( CloseHandle( w2 ), "CloseHandle failed\n" ); } else if (le == ERROR_ACCESS_DENIED) win_skip( "Not enough privileges for CreateWindowStation\n" ); w2 = OpenWindowStation("winsta0", TRUE, WINSTA_ALL_ACCESS ); ok( w2 != 0, "OpenWindowStation failed\n" ); ok( w2 != w1, "OpenWindowStation returned default handle\n" ); ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); w2 = OpenWindowStation("dummy name", TRUE, WINSTA_ALL_ACCESS ); ok( !w2, "open dummy win station succeeded\n" ); CreateMutexA( NULL, 0, "foobar" ); w2 = CreateWindowStation("foobar", 0, WINSTA_ALL_ACCESS, NULL ); le = GetLastError(); ok( w2 != 0 || le == ERROR_ACCESS_DENIED, "create foobar station failed (%u)\n", le ); if (w2 != 0) { w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); ok( w3 != 0, "open foobar station failed\n" ); ok( w3 != w2, "open foobar station returned same handle\n" ); ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); ok( CloseWindowStation( w3 ), "CloseWindowStation failed\n" ); w3 = OpenWindowStation("foobar", TRUE, WINSTA_ALL_ACCESS ); ok( !w3, "open foobar station succeeded\n" ); w2 = CreateWindowStation("foobar1", 0, WINSTA_ALL_ACCESS, NULL ); ok( w2 != 0, "create foobar station failed\n" ); w3 = CreateWindowStation("foobar2", 0, WINSTA_ALL_ACCESS, NULL ); ok( w3 != 0, "create foobar station failed\n" ); ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); ok( GetHandleInformation( w3, &flags ), "GetHandleInformation failed\n" ); SetProcessWindowStation( w2 ); atom = GlobalAddAtomA("foo"); ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" ); ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer ); ok( !CloseWindowStation( w2 ), "CloseWindowStation succeeded\n" ); ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); SetProcessWindowStation( w3 ); ok( GetHandleInformation( w2, &flags ), "GetHandleInformation failed\n" ); ok( CloseWindowStation( w2 ), "CloseWindowStation failed\n" ); ok( GlobalGetAtomNameA( atom, buffer, sizeof(buffer) ) == 3, "GlobalGetAtomName failed\n" ); ok( !lstrcmpiA( buffer, "foo" ), "bad atom value %s\n", buffer ); } else if (le == ERROR_ACCESS_DENIED) win_skip( "Not enough privileges for CreateWindowStation\n" ); /* desktops */ d1 = GetThreadDesktop(GetCurrentThreadId()); initial_desktop = d1; ok( GetThreadDesktop(GetCurrentThreadId()) == d1, "GetThreadDesktop returned different handles\n" ); flags = 0; ok( GetHandleInformation( d1, &flags ), "GetHandleInformation failed\n" ); ok( !(flags & HANDLE_FLAG_PROTECT_FROM_CLOSE), "handle %p PROTECT_FROM_CLOSE set\n", d1 ); SetLastError( 0xdeadbeef ); ok( !CloseDesktop(d1), "closing thread desktop succeeded\n" ); ok( GetLastError() == ERROR_BUSY || broken(GetLastError() == 0xdeadbeef), /* wow64 */ "bad last error %d\n", GetLastError() ); SetLastError( 0xdeadbeef ); if (CloseHandle( d1 )) /* succeeds on nt4 */ { win_skip( "NT4 desktop handle management is completely different\n" ); return; } ok( GetLastError() == ERROR_INVALID_HANDLE, "bad last error %d\n", GetLastError() ); ok( DuplicateHandle( GetCurrentProcess(), d1, GetCurrentProcess(), (PHANDLE)&d2, 0, TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" ); ok( CloseDesktop(d2), "closing dup desktop failed\n" ); ok( DuplicateHandle( GetCurrentProcess(), d1, GetCurrentProcess(), (PHANDLE)&d2, 0, TRUE, DUPLICATE_SAME_ACCESS ), "DuplicateHandle failed\n" ); ok( CloseHandle(d2), "closing dup desktop handle failed\n" ); d2 = OpenDesktop( "dummy name", 0, TRUE, DESKTOP_ALL_ACCESS ); ok( !d2, "open dummy desktop succeeded\n" ); d2 = CreateDesktop( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); ok( d2 != 0, "create foobar desktop failed\n" ); SetLastError( 0xdeadbeef ); ok( !CloseWindowStation( (HWINSTA)d2 ), "CloseWindowStation succeeded on desktop\n" ); ok( GetLastError() == ERROR_INVALID_HANDLE || broken(GetLastError() == 0xdeadbeef), /* wow64 */ "bad last error %d\n", GetLastError() ); SetLastError( 0xdeadbeef ); d3 = CreateDesktop( "foobar", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL ); ok( d3 != 0, "create foobar desktop again failed\n" ); ok( GetLastError() == 0xdeadbeef, "bad last error %d\n", GetLastError() ); ok( CloseDesktop( d3 ), "CloseDesktop failed\n" ); d3 = OpenDesktop( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS ); ok( d3 != 0, "open foobar desktop failed\n" ); ok( d3 != d2, "open foobar desktop returned same handle\n" ); ok( CloseDesktop( d2 ), "CloseDesktop failed\n" ); ok( CloseDesktop( d3 ), "CloseDesktop failed\n" ); d3 = OpenDesktop( "foobar", 0, TRUE, DESKTOP_ALL_ACCESS ); ok( !d3, "open foobar desktop succeeded\n" ); ok( !CloseHandle(d1), "closing thread desktop handle succeeded\n" ); d2 = GetThreadDesktop(GetCurrentThreadId()); ok( d1 == d2, "got different handles after close\n" ); register_class(); trace( "thread 1 desktop: %p\n", d1 ); print_object( d1 ); hthread = CreateThread( NULL, 0, thread, (LPVOID)2, 0, &id ); Sleep(1000); trace( "get other thread desktop: %p\n", GetThreadDesktop(id) ); WaitForSingleObject( hthread, INFINITE ); CloseHandle( hthread ); }
static void RegisterCustomSystemsAPI(lua_State *L) { register_class(L, LuaCustomSystem_TypeName, LuaCustomSystem_meta); register_class(L, LuaCustomSystemBody_TypeName, LuaCustomSystemBody_meta); }
static void RegisterFactionsAPI(lua_State *L) { register_class(L, LuaFaction_TypeName, LuaFaction_meta); }
void register_nbt(lua_State *state) { register_class(state, NBTTAG_CLASSNAME, nbt_meta_methods, nbt_methods); register_class_constants(state, NBTTAG_CLASSNAME, constants); }