WINAPI HRESULT IDirect3D9_CreateDevice( void *this_, UINT Adapter, D3DDEVTYPE DeviceType, HWND hFocusWindow, DWORD BehaviorFlags, D3DPRESENT_PARAMETERS *pPresentationParameters, void** ppReturnedDeviceInterface ) { NuLog("IDirect3D9::CreateDevice"); INIT_CLASS(IDirect3DDevice9, *ppReturnedDeviceInterface); if(pPresentationParameters->BackBufferFormat == 0) { pPresentationParameters->BackBufferFormat = D3DFMT_X8R8G8B8; } if(pPresentationParameters->BackBufferWidth == 0) { pPresentationParameters->BackBufferWidth = 1024; pPresentationParameters->BackBufferHeight = 768; pPresentationParameters->BackBufferCount = 1; } return S_OK; }
WINAPI void *Direct3DCreate9( UINT SDKVersion ) { void *ret; INIT_CLASS(IDirect3D9, ret); return ret; }
bool ModuleInit(JSContext *cx, JSObject *obj, uint32_t id) { JL_CHK( InitJslibsModule(cx, id) ); INIT_STATIC(); INIT_CLASS( Texture ); return true; JL_BAD; }
WINAPI HRESULT D3DXCompileShader( LPCSTR pSrcData, UINT srcDataLen, CONST D3DXMACRO *pDefines, LPD3DXINCLUDE pInclude, LPCSTR pFunctionName, LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER *ppShader, LPD3DXBUFFER *ppErrorMsgs, LPD3DXCONSTANTTABLE *ppConstantTable ) { NuWarn("D3DXCompileShader not yet implemented"); NuLog("%s %s", pFunctionName, pProfile); NuLog("%s", pSrcData); if(ppShader != None) { INIT_CLASS(ID3DXBuffer, *ppShader); ID3DXBuffer_Init( *ppShader, 6, "test?" ); } if(ppErrorMsgs != None) { INIT_CLASS(ID3DXBuffer, *ppErrorMsgs); ID3DXBuffer_Init( *ppErrorMsgs, 13, "No errors..." ); } if(ppConstantTable != None) { INIT_CLASS(ID3DXConstantTable, *ppConstantTable); } return S_OK; }
WINAPI HRESULT D3D10CreateStateBlock( /* ID3D10Device */ void *pDevice, D3D10_STATE_BLOCK_MASK *pStateBlockMask, /* ID3D10StateBlock */ void **ppStateBlock ) { if(ppStateBlock) { SETUP_VTABLE(D3D10); INIT_CLASS(ID3D10StateBlock, *ppStateBlock); } return S_OK; }
WINAPI HRESULT IDXGIAdapter_EnumOutputs( /* IDXGIAdapter */ void * this_, UINT Output, /* IDXGIOutput */ void **ppOutput ) { NuWarn("IDXGIAdapter::EnumOutputs not yet implemented"); if(Output > 0) return DXGI_ERROR_NOT_FOUND; if(ppOutput != NULL) INIT_CLASS(IDXGIOutput, *ppOutput); return S_OK; }
bool ModuleInit( JSContext *cx, JS::HandleObject obj ) { JLDisableThreadNotifications(); JL_ASSERT( jl::Host::getJLHost(cx)->checkCompatId( JL_HOST_VERSIONID ), E_MODULE, E_NOTCOMPATIBLE, E_HOST ); // JL_ASSERT( vi == NULL, E_LIB, E_STR("videoinput"), E_INIT ); // "Invalid case: videoInput already initialized'" videoInput::setVerbose(false); videoInput *vi = new videoInput(); JL_ASSERT_ALLOC( vi ); jl::Host::getJLHost(cx)->moduleManager().modulePrivateT<videoInput*>( moduleId() ) = vi; struct ReleaseModule : jl::Callback { jl::HostRuntime &_hostRuntime; videoInput *_vi; ReleaseModule(jl::HostRuntime &hostRuntime, videoInput *vi) : _hostRuntime(hostRuntime), _vi(vi) { } bool operator()( EventType &ev ) { ASSERT( _hostRuntime ); if ( _hostRuntime.skipCleanup() ) return true; if ( _vi != NULL ) delete _vi; return true; } }; jl::HostRuntime &hostRuntime = jl::HostRuntime::getJLRuntime(cx); hostRuntime.addListener(jl::EventId::AFTER_DESTROY_RUNTIME, new ReleaseModule(hostRuntime, vi)); // frees mpv after rt and cx has been destroyed INIT_CLASS( VideoInput ); return true; JL_BAD; }
bool ModuleInit(JSContext *cx, JSObject *obj, uint32_t id) { JL_CHK( InitJslibsModule(cx, id) ); rsvg_init(); struct ReleaseModule : jl::Callback { bool operator()( EventType &ev ) { rsvg_term(); return true; } }; jl::HostRuntime::getJLRuntime(cx).addListener(jl::EventId::AFTER_DESTROY_RUNTIME, new ReleaseModule()); // frees mpv after rt and cx has been destroyed INIT_CLASS( SVG ); return true; JL_BAD; }
*/ #include <dev/char.h> #include <dev/hw/uart.h> #include <kernel/class.h> #include <kernel/obj.h> #include <mm/mm.h> static void uart_dtor(struct obj *o); struct obj_type uart_type_s = { .offset = offset_of(struct uart, obj), .dtor = &uart_dtor, }; struct class uart_class = INIT_CLASS(uart_class, "uart", &uart_type_s); static void uart_dtor(struct obj *o) { struct uart *uart; struct uart_ops *ops; assert_type(o, &uart_type_s); uart = to_uart(o); ops = (struct uart_ops *) o->ops; ops->deinit(uart); /* Deinitialize, but don't destroy the UART */ } static int uart_read(struct char_device *dev, char *buf, size_t num) { struct uart *uart;
}; /* * Barometers are never destroyed. When their refcount reaches zero, * this destructor is called, and the barometer is deinitialized (possibly * going into a low power state), but it remains registered and available for * use for the duration of the OS. */ void baro_dtor(struct obj *o) { struct baro *baro; struct baro_ops *ops; assert_type(o, &baro_type_s); baro = to_baro(o); ops = (struct baro_ops *) o->ops; ops->deinit(baro); } struct class baro_class = INIT_CLASS(baro_class, "baro", &baro_type_s); /* Set up barometer system */ int baro_setup(void) { /* Set up baro_class */ obj_init(&baro_class.obj, system_class.type, "baro"); /* Register baro_class with /system/dev */ register_with_system(&dev_system, &baro_class); return 0; } CORE_INITIALIZER(baro_setup)