diff --git a/examples/same-game/fonts.ts b/examples/same-game/fonts.ts index 3e575ea..2f1b492 100644 --- a/examples/same-game/fonts.ts +++ b/examples/same-game/fonts.ts @@ -10,7 +10,7 @@ type GlyphData = { }; export type FontAtlas = { - texture: SDL.Texture; + texture: Pointer; glyphs: Record; }; diff --git a/examples/same-game/main.ts b/examples/same-game/main.ts index c8a2750..884c29b 100644 --- a/examples/same-game/main.ts +++ b/examples/same-game/main.ts @@ -93,7 +93,7 @@ function update(elapsed: bigint, board: Board): void { function draw( renderer: Pointer, board: Board, - blockTexture: SDL.Texture, + blockTexture: Pointer, font: FontAtlas ): void { SDL.SetRenderDrawColor(renderer, 0, 0, 0, 255); diff --git a/examples/same-game/rendering/board.ts b/examples/same-game/rendering/board.ts index 96fab06..c345f39 100644 --- a/examples/same-game/rendering/board.ts +++ b/examples/same-game/rendering/board.ts @@ -6,7 +6,7 @@ import { BlockColors } from "../logic/blockColors.ts"; export function drawBoard( renderer: Pointer, board: Board, - blockTexture: SDL.Texture, + blockTexture: Pointer, ): void { SDL.SetTextureBlendMode(blockTexture, SDL.BlendMode.BLEND); diff --git a/src/SDL/functions.ts b/src/SDL/functions.ts index 310591b..e5b5657 100644 --- a/src/SDL/functions.ts +++ b/src/SDL/functions.ts @@ -218,15 +218,15 @@ export function CreateRGBSurfaceWithFormat( CreateRGBSurfaceWithFormat.symbolName = "SDL_CreateRGBSurfaceWithFormat"; export function CreateRenderer( - window: PointerLike, + window: Pointer, index: int, flags: Uint32, -): Renderer { - const _result = Renderer.of(Platform.fromPlatformPointer(_library.symbols.SDL_CreateRenderer( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.SDL_CreateRenderer( Platform.toPlatformPointer(window), index, flags, - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -235,19 +235,19 @@ export function CreateRenderer( CreateRenderer.symbolName = "SDL_CreateRenderer"; export function CreateTexture( - renderer: PointerLike, + renderer: Pointer, format: Uint32, access: int, w: int, h: int, -): Texture { - const _result = Texture.of(Platform.fromPlatformPointer(_library.symbols.SDL_CreateTexture( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.SDL_CreateTexture( Platform.toPlatformPointer(renderer), format, access, w, h, - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -256,13 +256,13 @@ export function CreateTexture( CreateTexture.symbolName = "SDL_CreateTexture"; export function CreateTextureFromSurface( - renderer: PointerLike, + renderer: Pointer, surface: PointerLike, -): Texture { - const _result = Texture.of(Platform.fromPlatformPointer(_library.symbols.SDL_CreateTextureFromSurface( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.SDL_CreateTextureFromSurface( Platform.toPlatformPointer(renderer), Platform.toPlatformPointer(surface), - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -277,7 +277,7 @@ export function CreateWindow( w: int, h: int, flags: WindowFlags, -): Window; +): Pointer; export function CreateWindow( title: string, x: int, @@ -285,7 +285,7 @@ export function CreateWindow( w: int, h: int, flags: WindowFlags, -): Window; +): Pointer; export function CreateWindow( title: string, x: WindowPos | int, @@ -293,15 +293,15 @@ export function CreateWindow( w: int, h: int, flags: WindowFlags, -): Window { - const _result = Window.of(Platform.fromPlatformPointer(_library.symbols.SDL_CreateWindow( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.SDL_CreateWindow( Platform.toPlatformString(title), x, y, w, h, flags, - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -332,10 +332,10 @@ CreateWindowAndRenderer.symbolName = "SDL_CreateWindowAndRenderer"; export function CreateWindowFrom( data: PointerLike, -): Window { - const _result = Window.of(Platform.fromPlatformPointer(_library.symbols.SDL_CreateWindowFrom( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.SDL_CreateWindowFrom( Platform.toPlatformPointer(data), - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -364,7 +364,7 @@ export function DelEventWatch( DelEventWatch.symbolName = "SDL_DelEventWatch"; export function DestroyRenderer( - renderer: PointerLike, + renderer: Pointer, ): void { _library.symbols.SDL_DestroyRenderer( Platform.toPlatformPointer(renderer), @@ -373,7 +373,7 @@ export function DestroyRenderer( DestroyRenderer.symbolName = "SDL_DestroyRenderer"; export function DestroyTexture( - texture: PointerLike, + texture: Pointer, ): void { _library.symbols.SDL_DestroyTexture( Platform.toPlatformPointer(texture), @@ -382,7 +382,7 @@ export function DestroyTexture( DestroyTexture.symbolName = "SDL_DestroyTexture"; export function DestroyWindow( - window: PointerLike, + window: Pointer, ): void { _library.symbols.SDL_DestroyWindow( Platform.toPlatformPointer(window), @@ -391,7 +391,7 @@ export function DestroyWindow( DestroyWindow.symbolName = "SDL_DestroyWindow"; export function DestroyWindowSurface( - window: PointerLike, + window: Pointer, ): int { const _result = _library.symbols.SDL_DestroyWindowSurface( Platform.toPlatformPointer(window), @@ -415,7 +415,7 @@ export function FillRect( FillRect.symbolName = "SDL_FillRect"; export function FlashWindow( - window: PointerLike, + window: Pointer, operation: FlashOperation, ): int { const _result = _library.symbols.SDL_FlashWindow( @@ -462,9 +462,9 @@ export function GetError(): string { } GetError.symbolName = "SDL_GetError"; -export function GetGrabbedWindow(): Window | null { - const _result = Window.of( - Platform.fromPlatformPointer(_library.symbols.SDL_GetGrabbedWindow() as PlatformPointer), +export function GetGrabbedWindow(): Pointer | null { + const _result = Platform.fromPlatformPointer( + _library.symbols.SDL_GetGrabbedWindow() as PlatformPointer>, ); return _result; } @@ -483,7 +483,7 @@ export function GetKeyboardState(): Uint8Array { GetKeyboardState.symbolName = "SDL_GetKeyboardState"; export function GetRendererInfo( - renderer: PointerLike, + renderer: Pointer, ): RendererInfo { const info = new RendererInfo(); const _result = _library.symbols.SDL_GetRendererInfo( @@ -533,7 +533,7 @@ export function GetSystemRAM(): int { GetSystemRAM.symbolName = "SDL_GetSystemRAM"; export function GetTextureAlphaMod( - texture: PointerLike, + texture: Pointer, alpha: PointerLike, ): int { const _result = _library.symbols.SDL_GetTextureAlphaMod( @@ -545,7 +545,7 @@ export function GetTextureAlphaMod( GetTextureAlphaMod.symbolName = "SDL_GetTextureAlphaMod"; export function GetTextureBlendMode( - texture: PointerLike, + texture: Pointer, blendMode: PointerLike, ): int { const _result = _library.symbols.SDL_GetTextureBlendMode( @@ -557,7 +557,7 @@ export function GetTextureBlendMode( GetTextureBlendMode.symbolName = "SDL_GetTextureBlendMode"; export function GetTextureColorMod( - texture: PointerLike, + texture: Pointer, r: PointerLike, g: PointerLike, b: PointerLike, @@ -594,7 +594,7 @@ export function GetVersion( GetVersion.symbolName = "SDL_GetVersion"; export function GetWindowBordersSize( - window: PointerLike, + window: Pointer, top: PointerLike, left: PointerLike, bottom: PointerLike, @@ -612,7 +612,7 @@ export function GetWindowBordersSize( GetWindowBordersSize.symbolName = "SDL_GetWindowBordersSize"; export function GetWindowBrightness( - window: PointerLike, + window: Pointer, ): float { const _result = _library.symbols.SDL_GetWindowBrightness( Platform.toPlatformPointer(window), @@ -622,7 +622,7 @@ export function GetWindowBrightness( GetWindowBrightness.symbolName = "SDL_GetWindowBrightness"; export function GetWindowData( - window: PointerLike, + window: Pointer, name: string, ): Pointer { const _result = Platform.fromPlatformPointer(_library.symbols.SDL_GetWindowData( @@ -634,7 +634,7 @@ export function GetWindowData( GetWindowData.symbolName = "SDL_GetWindowData"; export function GetWindowDisplayIndex( - window: PointerLike, + window: Pointer, ): int { const _result = _library.symbols.SDL_GetWindowDisplayIndex( Platform.toPlatformPointer(window), @@ -644,7 +644,7 @@ export function GetWindowDisplayIndex( GetWindowDisplayIndex.symbolName = "SDL_GetWindowDisplayIndex"; export function GetWindowDisplayMode( - window: PointerLike, + window: Pointer, mode: PointerLike, ): int { const _result = _library.symbols.SDL_GetWindowDisplayMode( @@ -656,7 +656,7 @@ export function GetWindowDisplayMode( GetWindowDisplayMode.symbolName = "SDL_GetWindowDisplayMode"; export function GetWindowFlags( - window: PointerLike, + window: Pointer, ): Uint32 { const _result = _library.symbols.SDL_GetWindowFlags( Platform.toPlatformPointer(window), @@ -667,16 +667,16 @@ GetWindowFlags.symbolName = "SDL_GetWindowFlags"; export function GetWindowFromID( id: Uint32, -): Window | null { - const _result = Window.of(Platform.fromPlatformPointer(_library.symbols.SDL_GetWindowFromID( +): Pointer | null { + const _result = Platform.fromPlatformPointer(_library.symbols.SDL_GetWindowFromID( id, - ) as PlatformPointer)); + ) as PlatformPointer>); return _result; } GetWindowFromID.symbolName = "SDL_GetWindowFromID"; export function GetWindowGammaRamp( - window: PointerLike, + window: Pointer, red: PointerLike, green: PointerLike, blue: PointerLike, @@ -692,7 +692,7 @@ export function GetWindowGammaRamp( GetWindowGammaRamp.symbolName = "SDL_GetWindowGammaRamp"; export function GetWindowGrab( - window: PointerLike, + window: Pointer, ): boolean { const _result = _library.symbols.SDL_GetWindowGrab( Platform.toPlatformPointer(window), @@ -702,7 +702,7 @@ export function GetWindowGrab( GetWindowGrab.symbolName = "SDL_GetWindowGrab"; export function GetWindowICCProfile( - window: PointerLike, + window: Pointer, size: PointerLike, ): Pointer { const _result = Platform.fromPlatformPointer(_library.symbols.SDL_GetWindowICCProfile( @@ -714,7 +714,7 @@ export function GetWindowICCProfile( GetWindowICCProfile.symbolName = "SDL_GetWindowICCProfile"; export function GetWindowID( - window: PointerLike, + window: Pointer, ): Uint32 { const _result = _library.symbols.SDL_GetWindowID( Platform.toPlatformPointer(window), @@ -724,7 +724,7 @@ export function GetWindowID( GetWindowID.symbolName = "SDL_GetWindowID"; export function GetWindowKeyboardGrab( - window: PointerLike, + window: Pointer, ): boolean { const _result = _library.symbols.SDL_GetWindowKeyboardGrab( Platform.toPlatformPointer(window), @@ -734,7 +734,7 @@ export function GetWindowKeyboardGrab( GetWindowKeyboardGrab.symbolName = "SDL_GetWindowKeyboardGrab"; export function GetWindowMaximumSize( - window: PointerLike, + window: Pointer, w: PointerLike, h: PointerLike, ): void { @@ -747,7 +747,7 @@ export function GetWindowMaximumSize( GetWindowMaximumSize.symbolName = "SDL_GetWindowMaximumSize"; export function GetWindowMinimumSize( - window: PointerLike, + window: Pointer, w: PointerLike, h: PointerLike, ): void { @@ -760,7 +760,7 @@ export function GetWindowMinimumSize( GetWindowMinimumSize.symbolName = "SDL_GetWindowMinimumSize"; export function GetWindowMouseGrab( - window: PointerLike, + window: Pointer, ): boolean { const _result = _library.symbols.SDL_GetWindowMouseGrab( Platform.toPlatformPointer(window), @@ -770,7 +770,7 @@ export function GetWindowMouseGrab( GetWindowMouseGrab.symbolName = "SDL_GetWindowMouseGrab"; export function GetWindowMouseRect( - window: PointerLike, + window: Pointer, ): Rect | null { const _result = Rect.of(Platform.fromPlatformPointer(_library.symbols.SDL_GetWindowMouseRect( Platform.toPlatformPointer(window), @@ -780,7 +780,7 @@ export function GetWindowMouseRect( GetWindowMouseRect.symbolName = "SDL_GetWindowMouseRect"; export function GetWindowOpacity( - window: PointerLike, + window: Pointer, out_opacity: PointerLike, ): int { const _result = _library.symbols.SDL_GetWindowOpacity( @@ -792,7 +792,7 @@ export function GetWindowOpacity( GetWindowOpacity.symbolName = "SDL_GetWindowOpacity"; export function GetWindowPixelFormat( - window: PointerLike, + window: Pointer, ): Uint32 { const _result = _library.symbols.SDL_GetWindowPixelFormat( Platform.toPlatformPointer(window), @@ -802,7 +802,7 @@ export function GetWindowPixelFormat( GetWindowPixelFormat.symbolName = "SDL_GetWindowPixelFormat"; export function GetWindowPosition( - window: PointerLike, + window: Pointer, x: PointerLike, y: PointerLike, ): void { @@ -815,7 +815,7 @@ export function GetWindowPosition( GetWindowPosition.symbolName = "SDL_GetWindowPosition"; export function GetWindowSize( - window: PointerLike, + window: Pointer, w: PointerLike, h: PointerLike, ): void { @@ -828,7 +828,7 @@ export function GetWindowSize( GetWindowSize.symbolName = "SDL_GetWindowSize"; export function GetWindowSizeInPixels( - window: PointerLike, + window: Pointer, w: PointerLike, h: PointerLike, ): void { @@ -841,11 +841,10 @@ export function GetWindowSizeInPixels( GetWindowSizeInPixels.symbolName = "SDL_GetWindowSizeInPixels"; export function GetWindowSurface( - window: PointerLike, + window: Pointer, ): Surface { - const windowPtr = Platform.toPlatformPointer(window); const _result = Surface.of(Platform.fromPlatformPointer(_library.symbols.SDL_GetWindowSurface( - windowPtr, + Platform.toPlatformPointer(window), ) as PlatformPointer)); if (_result === null) { throw new SDLError(GetError()); @@ -855,7 +854,7 @@ export function GetWindowSurface( GetWindowSurface.symbolName = "SDL_GetWindowSurface"; export function GetWindowTitle( - window: PointerLike, + window: Pointer, ): string { const _result = Platform.fromPlatformString(_library.symbols.SDL_GetWindowTitle( Platform.toPlatformPointer(window), @@ -865,7 +864,7 @@ export function GetWindowTitle( GetWindowTitle.symbolName = "SDL_GetWindowTitle"; export function GetWindowWMInfo( - window: PointerLike, + window: Pointer, info: PointerLike, ): boolean { const _result = _library.symbols.SDL_GetWindowWMInfo( @@ -899,7 +898,7 @@ export function HasIntersection( HasIntersection.symbolName = "SDL_HasIntersection"; export function HasWindowSurface( - window: PointerLike, + window: Pointer, ): boolean { const _result = _library.symbols.SDL_HasWindowSurface( Platform.toPlatformPointer(window), @@ -909,7 +908,7 @@ export function HasWindowSurface( HasWindowSurface.symbolName = "SDL_HasWindowSurface"; export function HideWindow( - window: PointerLike, + window: Pointer, ): void { _library.symbols.SDL_HideWindow( Platform.toPlatformPointer(window), @@ -944,7 +943,7 @@ export function IntersectRect( IntersectRect.symbolName = "SDL_IntersectRect"; export function IsShapedWindow( - window: PointerLike, + window: Pointer, ): boolean { const _result = _library.symbols.SDL_IsShapedWindow( Platform.toPlatformPointer(window), @@ -954,7 +953,7 @@ export function IsShapedWindow( IsShapedWindow.symbolName = "SDL_IsShapedWindow"; export function LoadBMP_RW( - src: PointerLike, + src: Pointer, freesrc: int, ): Surface { const _result = Surface.of(Platform.fromPlatformPointer(_library.symbols.SDL_LoadBMP_RW( @@ -1035,7 +1034,7 @@ export function MapRGBA( MapRGBA.symbolName = "SDL_MapRGBA"; export function MaximizeWindow( - window: PointerLike, + window: Pointer, ): void { _library.symbols.SDL_MaximizeWindow( Platform.toPlatformPointer(window), @@ -1044,7 +1043,7 @@ export function MaximizeWindow( MaximizeWindow.symbolName = "SDL_MaximizeWindow"; export function MinimizeWindow( - window: PointerLike, + window: Pointer, ): void { _library.symbols.SDL_MinimizeWindow( Platform.toPlatformPointer(window), @@ -1095,7 +1094,7 @@ export function PollEvent( PollEvent.symbolName = "SDL_PollEvent"; export function QueryTexture( - texture: PointerLike, + texture: Pointer, format: PointerLike | null, access: PointerLike | null, w: PointerLike, @@ -1138,11 +1137,11 @@ QueueAudio.symbolName = "SDL_QueueAudio"; export function RWFromFile( file: string, mode: RWMode, -): RWops { - const _result = RWops.of(Platform.fromPlatformPointer(_library.symbols.SDL_RWFromFile( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.SDL_RWFromFile( Platform.toPlatformString(file), Platform.toPlatformString(mode), - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -1151,7 +1150,7 @@ export function RWFromFile( RWFromFile.symbolName = "SDL_RWFromFile"; export function RaiseWindow( - window: PointerLike, + window: Pointer, ): void { _library.symbols.SDL_RaiseWindow( Platform.toPlatformPointer(window), @@ -1163,7 +1162,7 @@ RaiseWindow.symbolName = "SDL_RaiseWindow"; // SDL_RemoveTimer export function RenderClear( - renderer: PointerLike, + renderer: Pointer, ): int { const _result = _library.symbols.SDL_RenderClear( Platform.toPlatformPointer(renderer), @@ -1176,8 +1175,8 @@ export function RenderClear( RenderClear.symbolName = "SDL_RenderClear"; export function RenderCopy( - renderer: PointerLike, - texture: PointerLike, + renderer: Pointer, + texture: Pointer, srcrect: PointerLike | null, dstrect: PointerLike | null, ): int { @@ -1195,8 +1194,8 @@ export function RenderCopy( RenderCopy.symbolName = "SDL_RenderCopy"; export function RenderCopyEx( - renderer: PointerLike, - texture: PointerLike, + renderer: Pointer, + texture: Pointer, srcrect: PointerLike, dstrect: PointerLike, angle: double, @@ -1220,7 +1219,7 @@ export function RenderCopyEx( RenderCopyEx.symbolName = "SDL_RenderCopyEx"; export function RenderDrawLine( - renderer: PointerLike, + renderer: Pointer, x1: int, y1: int, x2: int, @@ -1241,7 +1240,7 @@ export function RenderDrawLine( RenderDrawLine.symbolName = "SDL_RenderDrawLine"; export function RenderDrawLines( - renderer: PointerLike, + renderer: Pointer, points: PointerLike, count: int, ): int { @@ -1258,7 +1257,7 @@ export function RenderDrawLines( RenderDrawLines.symbolName = "SDL_RenderDrawLines"; export function RenderDrawPoint( - renderer: PointerLike, + renderer: Pointer, x: int, y: int, ): int { @@ -1275,7 +1274,7 @@ export function RenderDrawPoint( RenderDrawPoint.symbolName = "SDL_RenderDrawPoint"; export function RenderDrawPoints( - renderer: PointerLike, + renderer: Pointer, points: PointerLike, count: int, ): int { @@ -1292,7 +1291,7 @@ export function RenderDrawPoints( RenderDrawPoints.symbolName = "SDL_RenderDrawPoints"; export function RenderDrawRect( - renderer: PointerLike, + renderer: Pointer, rect: PointerLike, ): int { const _result = _library.symbols.SDL_RenderDrawRect( @@ -1307,7 +1306,7 @@ export function RenderDrawRect( RenderDrawRect.symbolName = "SDL_RenderDrawRect"; export function RenderDrawRects( - renderer: PointerLike, + renderer: Pointer, rects: PointerLike, count: int, ): int { @@ -1324,7 +1323,7 @@ export function RenderDrawRects( RenderDrawRects.symbolName = "SDL_RenderDrawRects"; export function RenderFillRect( - renderer: PointerLike, + renderer: Pointer, rect: PointerLike, ): int { const _result = _library.symbols.SDL_RenderFillRect( @@ -1339,7 +1338,7 @@ export function RenderFillRect( RenderFillRect.symbolName = "SDL_RenderFillRect"; export function RenderFillRects( - renderer: PointerLike, + renderer: Pointer, rects: PointerLike, count: int, ): int { @@ -1356,7 +1355,7 @@ export function RenderFillRects( RenderFillRects.symbolName = "SDL_RenderFillRects"; export function RenderFlush( - renderer: PointerLike, + renderer: Pointer, ): int { const _result = _library.symbols.SDL_RenderFlush( Platform.toPlatformPointer(renderer), @@ -1369,11 +1368,11 @@ export function RenderFlush( RenderFlush.symbolName = "SDL_RenderFlush"; export function RenderGetWindow( - renderer: PointerLike, -): Window { - const _result = Window.of(Platform.fromPlatformPointer(_library.symbols.SDL_RenderGetWindow( + renderer: Pointer, +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.SDL_RenderGetWindow( Platform.toPlatformPointer(renderer), - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -1382,7 +1381,7 @@ export function RenderGetWindow( RenderGetWindow.symbolName = "SDL_RenderGetWindow"; export function RenderSetLogicalSize( - renderer: PointerLike, + renderer: Pointer, width: int, height: int, ): int { @@ -1399,7 +1398,7 @@ export function RenderSetLogicalSize( RenderSetLogicalSize.symbolName = "SDL_RenderSetLogicalSize"; export function RenderLogicalToWindow( - renderer: PointerLike, + renderer: Pointer, logicalX: float, logicalY: float, windowX: PointerLike, @@ -1416,7 +1415,7 @@ export function RenderLogicalToWindow( RenderLogicalToWindow.symbolName = "SDL_RenderLogicalToWindow"; export function RenderPresent( - renderer: PointerLike, + renderer: Pointer, ): void { _library.symbols.SDL_RenderPresent( Platform.toPlatformPointer(renderer), @@ -1425,7 +1424,7 @@ export function RenderPresent( RenderPresent.symbolName = "SDL_RenderPresent"; export function RenderWindowToLogical( - renderer: PointerLike, + renderer: Pointer, windowX: int, windowY: int, logicalX: PointerLike, @@ -1442,7 +1441,7 @@ export function RenderWindowToLogical( RenderWindowToLogical.symbolName = "SDL_RenderWindowToLogical"; export function RestoreWindow( - window: PointerLike, + window: Pointer, ): void { _library.symbols.SDL_RestoreWindow( Platform.toPlatformPointer(window), @@ -1468,7 +1467,7 @@ export function SetColorKey( SetColorKey.symbolName = "SDL_SetColorKey"; export function SetRenderDrawBlendMode( - renderer: PointerLike, + renderer: Pointer, blendMode: BlendMode, ): int { const _result = _library.symbols.SDL_SetRenderDrawBlendMode( @@ -1483,7 +1482,7 @@ export function SetRenderDrawBlendMode( SetRenderDrawBlendMode.symbolName = "SDL_SetRenderDrawBlendMode"; export function SetRenderDrawColor( - renderer: PointerLike, + renderer: Pointer, r: Uint8, g: Uint8, b: Uint8, @@ -1519,7 +1518,7 @@ export function SetSurfaceBlendMode( SetSurfaceBlendMode.symbolName = "SDL_SetSurfaceBlendMode"; export function SetTextureAlphaMod( - texture: PointerLike, + texture: Pointer, alpha: Uint8, ): int { const _result = _library.symbols.SDL_SetTextureAlphaMod( @@ -1534,7 +1533,7 @@ export function SetTextureAlphaMod( SetTextureAlphaMod.symbolName = "SDL_SetTextureAlphaMod"; export function SetTextureBlendMode( - texture: PointerLike, + texture: Pointer, blendMode: BlendMode, ): int { const _result = _library.symbols.SDL_SetTextureBlendMode( @@ -1549,7 +1548,7 @@ export function SetTextureBlendMode( SetTextureBlendMode.symbolName = "SDL_SetTextureBlendMode"; export function SetTextureColorMod( - texture: PointerLike, + texture: Pointer, r: Uint8, g: Uint8, b: Uint8, @@ -1568,7 +1567,7 @@ export function SetTextureColorMod( SetTextureColorMod.symbolName = "SDL_SetTextureColorMod"; export function SetWindowAlwaysOnTop( - window: PointerLike, + window: Pointer, on_top: boolean, ): void { _library.symbols.SDL_SetWindowAlwaysOnTop( @@ -1579,7 +1578,7 @@ export function SetWindowAlwaysOnTop( SetWindowAlwaysOnTop.symbolName = "SDL_SetWindowAlwaysOnTop"; export function SetWindowBordered( - window: PointerLike, + window: Pointer, bordered: boolean, ): void { _library.symbols.SDL_SetWindowBordered( @@ -1590,7 +1589,7 @@ export function SetWindowBordered( SetWindowBordered.symbolName = "SDL_SetWindowBordered"; export function SetWindowBrightness( - window: PointerLike, + window: Pointer, brightness: float, ): int { const _result = _library.symbols.SDL_SetWindowBrightness( @@ -1605,7 +1604,7 @@ export function SetWindowBrightness( SetWindowBrightness.symbolName = "SDL_SetWindowBrightness"; export function SetWindowData( - window: PointerLike, + window: Pointer, name: string, userdata: PointerLike, ): Pointer { @@ -1619,7 +1618,7 @@ export function SetWindowData( SetWindowData.symbolName = "SDL_SetWindowData"; export function SetWindowDisplayMode( - window: PointerLike, + window: Pointer, mode: PointerLike, ): int { const _result = _library.symbols.SDL_SetWindowDisplayMode( @@ -1634,7 +1633,7 @@ export function SetWindowDisplayMode( SetWindowDisplayMode.symbolName = "SDL_SetWindowDisplayMode"; export function SetWindowFullscreen( - window: PointerLike, + window: Pointer, flags: Uint32, ): int { const _result = _library.symbols.SDL_SetWindowFullscreen( @@ -1649,7 +1648,7 @@ export function SetWindowFullscreen( SetWindowFullscreen.symbolName = "SDL_SetWindowFullscreen"; export function SetWindowGammaRamp( - window: PointerLike, + window: Pointer, red: PointerLike, green: PointerLike, blue: PointerLike, @@ -1668,7 +1667,7 @@ export function SetWindowGammaRamp( SetWindowGammaRamp.symbolName = "SDL_SetWindowGammaRamp"; export function SetWindowGrab( - window: PointerLike, + window: Pointer, grabbed: boolean, ): void { _library.symbols.SDL_SetWindowGrab( @@ -1682,7 +1681,7 @@ SetWindowGrab.symbolName = "SDL_SetWindowGrab"; // SDL_SetWindowHitTest export function SetWindowIcon( - window: PointerLike, + window: Pointer, icon: PointerLike, ): void { _library.symbols.SDL_SetWindowIcon( @@ -1693,7 +1692,7 @@ export function SetWindowIcon( SetWindowIcon.symbolName = "SDL_SetWindowIcon"; export function SetWindowInputFocus( - window: PointerLike, + window: Pointer, ): int { const _result = _library.symbols.SDL_SetWindowInputFocus( Platform.toPlatformPointer(window), @@ -1706,7 +1705,7 @@ export function SetWindowInputFocus( SetWindowInputFocus.symbolName = "SDL_SetWindowInputFocus"; export function SetWindowKeyboardGrab( - window: PointerLike, + window: Pointer, grabbed: boolean, ): void { _library.symbols.SDL_SetWindowKeyboardGrab( @@ -1717,7 +1716,7 @@ export function SetWindowKeyboardGrab( SetWindowKeyboardGrab.symbolName = "SDL_SetWindowKeyboardGrab"; export function SetWindowMaximumSize( - window: PointerLike, + window: Pointer, max_w: int, max_h: int, ): void { @@ -1730,7 +1729,7 @@ export function SetWindowMaximumSize( SetWindowMaximumSize.symbolName = "SDL_SetWindowMaximumSize"; export function SetWindowMinimumSize( - window: PointerLike, + window: Pointer, min_w: int, min_h: int, ): void { @@ -1743,8 +1742,8 @@ export function SetWindowMinimumSize( SetWindowMinimumSize.symbolName = "SDL_SetWindowMinimumSize"; export function SetWindowModalFor( - modal_window: PointerLike, - parent_window: PointerLike, + modal_window: Pointer, + parent_window: Pointer, ): int { const _result = _library.symbols.SDL_SetWindowModalFor( Platform.toPlatformPointer(modal_window), @@ -1758,7 +1757,7 @@ export function SetWindowModalFor( SetWindowModalFor.symbolName = "SDL_SetWindowModalFor"; export function SetWindowMouseGrab( - window: PointerLike, + window: Pointer, grabbed: boolean, ): void { _library.symbols.SDL_SetWindowMouseGrab( @@ -1769,7 +1768,7 @@ export function SetWindowMouseGrab( SetWindowMouseGrab.symbolName = "SDL_SetWindowMouseGrab"; export function SetWindowMouseRect( - window: PointerLike, + window: Pointer, rect: PointerLike, ): int { const _result = _library.symbols.SDL_SetWindowMouseRect( @@ -1784,7 +1783,7 @@ export function SetWindowMouseRect( SetWindowMouseRect.symbolName = "SDL_SetWindowMouseRect"; export function SetWindowOpacity( - window: PointerLike, + window: Pointer, opacity: float, ): int { const _result = _library.symbols.SDL_SetWindowOpacity( @@ -1799,7 +1798,7 @@ export function SetWindowOpacity( SetWindowOpacity.symbolName = "SDL_SetWindowOpacity"; export function SetWindowPosition( - window: PointerLike, + window: Pointer, x: int, y: int, ): void { @@ -1812,7 +1811,7 @@ export function SetWindowPosition( SetWindowPosition.symbolName = "SDL_SetWindowPosition"; export function SetWindowResizable( - window: PointerLike, + window: Pointer, resizable: boolean, ): void { _library.symbols.SDL_SetWindowResizable( @@ -1826,7 +1825,7 @@ SetWindowResizable.symbolName = "SDL_SetWindowResizable"; // SDL_SetWindowShape export function SetWindowSize( - window: PointerLike, + window: Pointer, w: int, h: int, ): void { @@ -1839,7 +1838,7 @@ export function SetWindowSize( SetWindowSize.symbolName = "SDL_SetWindowSize"; export function SetWindowTitle( - window: PointerLike, + window: Pointer, title: string, ): void { _library.symbols.SDL_SetWindowTitle( @@ -1853,7 +1852,7 @@ SetWindowTitle.symbolName = "SDL_SetWindowTitle"; // SDL_SetWindowsMessageHook export function ShowWindow( - window: PointerLike, + window: Pointer, ): void { _library.symbols.SDL_ShowWindow( Platform.toPlatformPointer(window), @@ -1871,7 +1870,7 @@ export function UnlockSurface( UnlockSurface.symbolName = "SDL_UnlockSurface"; export function UpdateWindowSurface( - window: PointerLike, + window: Pointer, ): int { const _result = _library.symbols.SDL_UpdateWindowSurface( Platform.toPlatformPointer(window), @@ -1884,7 +1883,7 @@ export function UpdateWindowSurface( UpdateWindowSurface.symbolName = "SDL_UpdateWindowSurface"; export function UpdateWindowSurfaceRects( - window: PointerLike, + window: Pointer, rects: PointerLike, numrects: int, ): int { @@ -1923,7 +1922,7 @@ export function WaitEventTimeout( WaitEventTimeout.symbolName = "SDL_WaitEventTimeout"; export function WarpMouseInWindow( - window: PointerLike, + window: Pointer, x: int, y: int, ): void { diff --git a/src/SDL/structs.ts b/src/SDL/structs.ts index 4e165f3..5be4720 100644 --- a/src/SDL/structs.ts +++ b/src/SDL/structs.ts @@ -37,101 +37,11 @@ import { WindowPos, } from "./enums.ts"; -export class Renderer implements Struct { - public static IS_OPAQUE = true; - - public readonly _view: PlatformDataView; - - constructor( - public readonly _data: Pointer, - byteOffset: number = 0, - ) { - this._view = new Platform.DataView(this._data, byteOffset); - } - - public static of( - data: Pointer | null, - byteOffset: number = 0, - ): Renderer | null { - return data !== null ? new Renderer(data, byteOffset) : null; - } - - public get _byteOffset(): number { - return this._view.byteOffset; - } -} - -export class RWops implements Struct { - public static IS_OPAQUE = true; - - public readonly _view: PlatformDataView; - - constructor( - public readonly _data: Pointer, - byteOffset: number = 0, - ) { - this._view = new Platform.DataView(this._data, byteOffset); - } - - public static of( - data: Pointer | null, - byteOffset: number = 0, - ): RWops | null { - return data !== null ? new RWops(data, byteOffset) : null; - } - - public get _byteOffset(): number { - return this._view.byteOffset; - } -} - -export class Texture implements Struct { - public static IS_OPAQUE = true; - - public readonly _view: PlatformDataView; - - constructor( - public readonly _data: Pointer, - byteOffset: number = 0, - ) { - this._view = new Platform.DataView(this._data, byteOffset); - } - - public static of( - data: Pointer | null, - byteOffset: number = 0, - ): Texture | null { - return data !== null ? new Texture(data, byteOffset) : null; - } - - public get _byteOffset(): number { - return this._view.byteOffset; - } -} - -export class Window implements Struct { - public static IS_OPAQUE = true; - - public readonly _view: PlatformDataView; - - constructor( - public readonly _data: Pointer, - byteOffset: number = 0, - ) { - this._view = new Platform.DataView(this._data, byteOffset); - } - - public static of( - data: Pointer | null, - byteOffset: number = 0, - ): Window | null { - return data !== null ? new Window(data, byteOffset) : null; - } - - public get _byteOffset(): number { - return this._view.byteOffset; - } -} +declare const _: unique symbol; +export type Renderer = { [_]: "Renderer" }; +export type RWops = { [_]: "RWops" }; +export type Texture = { [_]: "Texture" }; +export type Window = { [_]: "Window" }; export class AudioSpec implements AllocatableStruct { public static SIZE_IN_BYTES = 32; diff --git a/src/SDL_image/functions.ts b/src/SDL_image/functions.ts index ef1ccf3..d8d5209 100644 --- a/src/SDL_image/functions.ts +++ b/src/SDL_image/functions.ts @@ -46,10 +46,10 @@ Linked_Version.symbolName = "IMG_Linked_Version"; export function Load( file: string, -): Surface { - const _result = Surface.of(Platform.fromPlatformPointer(_library.symbols.IMG_Load( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.IMG_Load( Platform.toPlatformString(file), - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -58,13 +58,13 @@ export function Load( Load.symbolName = "IMG_Load"; export function LoadTexture( - renderer: PointerLike, + renderer: Pointer, file: string, -): Texture { - const _result = Texture.of(Platform.fromPlatformPointer(_library.symbols.IMG_LoadTexture( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.IMG_LoadTexture( Platform.toPlatformPointer(renderer), Platform.toPlatformString(file), - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } diff --git a/src/SDL_ttf/functions.ts b/src/SDL_ttf/functions.ts index 22d9a80..779ced1 100644 --- a/src/SDL_ttf/functions.ts +++ b/src/SDL_ttf/functions.ts @@ -32,7 +32,7 @@ export function Init(options?: InitOptions): void { Init.symbolName = "TTF_Init"; export function CloseFont( - font: PointerLike, + font: Pointer, ): void { _library.symbols.TTF_CloseFont( Platform.toPlatformPointer(font), @@ -54,11 +54,11 @@ Linked_Version.symbolName = "TTF_Linked_Version"; export function OpenFont( file: string, ptsize: int, -): Font { - const _result = Font.of(Platform.fromPlatformPointer(_library.symbols.TTF_OpenFont( +): Pointer { + const _result = Platform.fromPlatformPointer(_library.symbols.TTF_OpenFont( Platform.toPlatformString(file), ptsize, - ) as PlatformPointer)); + ) as PlatformPointer>); if (_result === null) { throw new SDLError(GetError()); } @@ -73,7 +73,7 @@ export function Quit(): void { Quit.symbolName = "TTF_Quit"; export function RenderText_Blended( - font: PointerLike, + font: Pointer, text: string, fg: Color, ): Surface { @@ -90,7 +90,7 @@ export function RenderText_Blended( RenderText_Blended.symbolName = "TTF_RenderText_Blended"; export function RenderText_LCD( - font: PointerLike, + font: Pointer, text: string, fg: Color, bg: Color, @@ -109,7 +109,7 @@ export function RenderText_LCD( RenderText_LCD.symbolName = "TTF_RenderText_LCD"; export function RenderText_Solid( - font: PointerLike, + font: Pointer, text: string, fg: Color, ): Surface { @@ -126,7 +126,7 @@ export function RenderText_Solid( RenderText_Solid.symbolName = "TTF_RenderText_Solid"; export function RenderText_Shaded( - font: PointerLike, + font: Pointer, text: string, fg: Color, bg: Color, @@ -145,7 +145,7 @@ export function RenderText_Shaded( RenderText_Shaded.symbolName = "TTF_RenderText_Shaded"; export function RenderUTF8_Blended( - font: PointerLike, + font: Pointer, text: string, fg: Color, ): Surface { @@ -162,7 +162,7 @@ export function RenderUTF8_Blended( RenderUTF8_Blended.symbolName = "TTF_RenderUTF8_Blended"; export function RenderUTF8_LCD( - font: PointerLike, + font: Pointer, text: string, fg: Color, bg: Color, @@ -181,7 +181,7 @@ export function RenderUTF8_LCD( RenderUTF8_LCD.symbolName = "TTF_RenderUTF8_LCD"; export function RenderUTF8_Solid( - font: PointerLike, + font: Pointer, text: string, fg: Color, ): Surface { @@ -198,7 +198,7 @@ export function RenderUTF8_Solid( RenderUTF8_Solid.symbolName = "TTF_RenderUTF8_Solid"; export function RenderUTF8_Shaded( - font: PointerLike, + font: Pointer, text: string, fg: Color, bg: Color, @@ -217,7 +217,7 @@ export function RenderUTF8_Shaded( RenderUTF8_Shaded.symbolName = "TTF_RenderUTF8_Shaded"; export function SizeText( - font: PointerLike, + font: Pointer, text: string, w: PointerLike, h: PointerLike, @@ -236,7 +236,7 @@ export function SizeText( SizeText.symbolName = "TTF_SizeText"; export function SizeUTF8( - font: PointerLike, + font: Pointer, text: string, ): [int, int] { const w = new Box(int); @@ -255,7 +255,7 @@ export function SizeUTF8( SizeUTF8.symbolName = "TTF_SizeUTF8"; export function SizeUNICODE( - font: PointerLike, + font: Pointer, text: string, w: PointerLike, h: PointerLike, diff --git a/src/SDL_ttf/structs.ts b/src/SDL_ttf/structs.ts index 009cbe3..fcdf82d 100644 --- a/src/SDL_ttf/structs.ts +++ b/src/SDL_ttf/structs.ts @@ -12,26 +12,5 @@ import {} from "./callbacks.ts"; import {} from "./enums.ts"; -export class Font implements Struct { - public static IS_OPAQUE = true; - - public readonly _view: PlatformDataView; - - constructor( - public readonly _data: Pointer, - byteOffset: number = 0, - ) { - this._view = new Platform.DataView(this._data, byteOffset); - } - - public static of( - data: Pointer | null, - byteOffset: number = 0, - ): Font | null { - return data !== null ? new Font(data, byteOffset) : null; - } - - public get _byteOffset(): number { - return this._view.byteOffset; - } -} +declare const _: unique symbol; +export type Font = { [_]: "Font" }; diff --git a/src/_boxes.ts b/src/_boxes.ts index 71a03ad..d21f383 100644 --- a/src/_boxes.ts +++ b/src/_boxes.ts @@ -16,7 +16,7 @@ import { import { PlatformDataView } from "./_types.ts"; import { sizeof } from "./_utils.ts"; -type BoxValue = TypedNumber | Pointer; +export type BoxValue = TypedNumber | Pointer; export type BoxValueConstructor = Constructor; export type BoxValueFactory = Factory; diff --git a/src/_types.ts b/src/_types.ts index 36e60c0..b65696b 100644 --- a/src/_types.ts +++ b/src/_types.ts @@ -1,6 +1,7 @@ import { type Pointer } from "./types.ts"; import { Callback, PointerLike, Struct, StructConstructor } from "./types.ts"; import { DynamicCallbackDefinition, DynamicLibrary, DynamicLibraryInterface } from "./_library.ts"; +import { Box, BoxValue } from "./_boxes.ts"; declare const _: unique symbol; @@ -83,7 +84,7 @@ export interface Platform { definition: DynamicCallbackDefinition, ): PlatformCallback; - toPlatformPointer(value: PointerLike | null): PlatformPointer | null; + toPlatformPointer(value: PointerLike | (T extends BoxValue ? Box : never) | null): PlatformPointer | null; toPlatformString(value: string | null): PlatformString; diff --git a/src/types.ts b/src/types.ts index 55c78fc..ba7c596 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,6 +3,7 @@ import Platform from "./_platform.ts"; import { PlatformPointer } from "./_types.ts"; +import { throwError } from "./_utils.ts"; import { StructArray } from "./structs.ts"; declare const _: unique symbol; @@ -20,8 +21,7 @@ export type Uint16 = number; export type Uint32 = number; export type Uint64 = bigint; -// NOTE: Pointer is an opaque type. -export type Pointer = unknown; +export type Pointer = { [_]: "Pointer" }; export const double = (value = 0): double => value; export const float = (value = 0): float => value; @@ -33,7 +33,7 @@ export const Uint32 = (value = 0): Uint32 => value; export const Uint64 = (value = 0): Uint64 => BigInt(value); export const Pointer = (value: unknown): Pointer => - Platform.fromPlatformPointer(value as unknown as PlatformPointer); + Platform.fromPlatformPointer(value as unknown as PlatformPointer) ?? throwError("Cannot convert null to pointer."); export type TypedNumber = | double diff --git a/tools/codegen/SDL_image.ts b/tools/codegen/SDL_image.ts index 405b960..764efdc 100644 --- a/tools/codegen/SDL_image.ts +++ b/tools/codegen/SDL_image.ts @@ -10,19 +10,9 @@ import { structs as SDL_structs } from "./SDL/structs.ts"; const SDL_IMAGE_SRC_PATH = join(SRC_PATH, "SDL_image"); export async function codegenSDL_image(): Promise { + const allOpaqueStructs = [ "SDL_Renderer", "SDL_Surface", "SDL_Texture", ...opaqueStructs, ] + const allStructs = { - SDL_Renderer: { - ...SDL_structs["SDL_Renderer"], - doNotImport: true, - }, - SDL_Surface: { - ...SDL_structs["SDL_Surface"], - doNotImport: true, - }, - SDL_Texture: { - ...SDL_structs["SDL_Texture"], - doNotImport: true, - }, SDL_version: { ...SDL_structs["SDL_version"], doNotImport: true, @@ -38,7 +28,7 @@ export async function codegenSDL_image(): Promise { callbacks, enums, allStructs, - opaqueStructs, + allOpaqueStructs, ); // await writeCallbacks(`${SDL_IMAGE_SRC_PATH}/callbacks.ts`, callbacks, enums, structs, opaqueStructs, []); await writeFunctions( @@ -48,7 +38,7 @@ export async function codegenSDL_image(): Promise { callbacks, enums, allStructs, - opaqueStructs, + allOpaqueStructs, [ `import { GetError } from "../SDL/functions.ts";`, `import { Renderer, Surface, Texture, version } from "../SDL/structs.ts";`, diff --git a/tools/codegen/generators.ts b/tools/codegen/generators.ts index ae7f912..8d23478 100644 --- a/tools/codegen/generators.ts +++ b/tools/codegen/generators.ts @@ -588,32 +588,10 @@ export async function writeStructs( lines.push(`import { ${enumNames} } from "./enums.ts";`); lines.push(""); + lines.push("declare const _: unique symbol;"); for (const structName of opaqueStructs) { const className = stripPrefixes(structName); - lines.push(`export class ${className} implements Struct { - public static IS_OPAQUE = true; - - public readonly _view: PlatformDataView; - - constructor( - public readonly _data: Pointer<${className}>, - byteOffset: number = 0 - ) { - this._view = new Platform.DataView(this._data, byteOffset); - } - - public static of( - data: Pointer<${className}> | null, - byteOffset: number = 0 - ): ${className} | null { - return data !== null ? new ${className}(data, byteOffset) : null; - } - - public get _byteOffset(): number { - return this._view.byteOffset; - } -} -`); + lines.push(`export type ${className} = { [_]: "${className}" };`); } lines.push(""); @@ -1111,15 +1089,22 @@ function mapFunctionParamType( ) { let structName = param.type.substring("SDL_".length); - if (structName.endsWith("**")) { - structName = structName.slice(0, -2); - structName = `Box>`; - } else if (structName.endsWith("*")) { - structName = structName.slice(0, -1); - if (isReturnType) { - structName = `${structName}`; + if (isFunctionParamOpaqueStruct(opaqueStructs, param)) { + if (structName.endsWith("**")) { + structName = `Box>`; } else { - structName = `PointerLike<${structName}>`; + structName = `Pointer<${stripPointerPostfix(structName)}>`; + } + } else { + if (structName.endsWith("**")) { + structName = `Box>`; + } else if (structName.endsWith("*")) { + structName = stripPointerPostfix(structName); + if (isReturnType) { + structName = `${structName}`; + } else { + structName = `PointerLike<${structName}>`; + } } } @@ -1489,7 +1474,13 @@ import { InitOptions, double, float, int, Pointer, PointerLike, Uint8, Uint16, U .join(", "); lines.push(`import { ${enumNames} } from "./enums.ts";`); - writeImportAllStructs(lines, structs, opaqueStructs); + // TODO: This is a hack as there is currently no way to attach metadata to opaqueStruct(s). + let opaqueStructsToImport = [...opaqueStructs]; + if (libraryName === "SDL2_image") { + opaqueStructsToImport = opaqueStructsToImport.filter(x => x.startsWith("IMG_")); + } + + writeImportAllStructs(lines, structs, opaqueStructsToImport); lines.push(""); @@ -1687,10 +1678,7 @@ import { InitOptions, double, float, int, Pointer, PointerLike, Uint8, Uint16, U resultStatement += "\t\tBigInt("; } else if (isFunctionParamString(func.result)) { resultStatement += "\t\tPlatform.fromPlatformString("; - } else if ( - isFunctionParamOpaqueStruct(opaqueStructs, func.result) || - isFunctionParamStruct(structs, func.result) - ) { + } else if (isFunctionParamStruct(structs, func.result)) { resultStatement += `\t\t${symbolReturnType}.of(Platform.fromPlatformPointer(`; } else if (isFunctionParamPointer(func.result)) { resultStatement += `\t\tPlatform.fromPlatformPointer(`; @@ -1744,10 +1732,9 @@ import { InitOptions, double, float, int, Pointer, PointerLike, Uint8, Uint16, U lines.push("\t) as bigint | number);"); } else if (symbolReturnType === "string") { lines.push(`\t) as PlatformPointer);`); - } else if ( - isFunctionParamOpaqueStruct(opaqueStructs, func.result) || - isFunctionParamStruct(structs, func.result) - ) { + } else if (isFunctionParamOpaqueStruct(opaqueStructs, func.result)) { + lines.push(`\t) as PlatformPointer<${originalReturnType}>);`); + } else if (isFunctionParamStruct(structs, func.result)) { lines.push(`\t) as PlatformPointer<${originalReturnType}>));`); } else if (isFunctionParamPointer(func.result)) { const nonNullAssertion = !func.result.nullable ? "!" : "";