Add gui controls

This commit is contained in:
Alexander Klingenbeck 2023-06-06 16:50:38 +02:00
parent ded70d470b
commit 2f537f649c
9 changed files with 295 additions and 211 deletions

View File

@ -93,8 +93,8 @@ export abstract class GenericQuickJsGenerator<T extends QuickJsGenerator> extend
// String // String
case "const char *": case "const char *":
//case "char *": //case "char *":
if(!supressDeclaration) this.statement(`${type} ${name} = JS_IsNull(${src}) ? NULL : (${type})JS_ToCString(ctx, ${src})`) if(!supressDeclaration) this.statement(`${type} ${name} = (JS_IsNull(${src}) || JS_IsUndefined(${src})) ? NULL : (${type})JS_ToCString(ctx, ${src})`)
else this.statement(`${name} = JS_IsNull(${src}) ? NULL : (${type})JS_ToCString(ctx, ${src})`) else this.statement(`${name} = (JS_IsNull(${src}) || JS_IsUndefined(${src})) ? NULL : (${type})JS_ToCString(ctx, ${src})`)
break; break;
case "double": case "double":
if(!supressDeclaration) this.statement(`${type} ${name}`) if(!supressDeclaration) this.statement(`${type} ${name}`)

View File

@ -48,7 +48,7 @@ export class TypeScriptDeclaration {
return "boolean" return "boolean"
case "const char *": case "const char *":
case "char *": case "char *":
return "string" return "string | undefined | null"
case "void *": case "void *":
case "const void *": case "const void *":
return "any" return "any"

View File

@ -334,7 +334,7 @@ declare var FilePathList: {
prototype: FilePathList; prototype: FilePathList;
} }
/** Initialize window and OpenGL context */ /** Initialize window and OpenGL context */
declare function initWindow(width: number, height: number, title: string): void; declare function initWindow(width: number, height: number, title: string | undefined | null): void;
/** Check if KEY_ESCAPE pressed or Close icon pressed */ /** Check if KEY_ESCAPE pressed or Close icon pressed */
declare function windowShouldClose(): boolean; declare function windowShouldClose(): boolean;
/** Close window and unload OpenGL context */ /** Close window and unload OpenGL context */
@ -370,7 +370,7 @@ declare function restoreWindow(): void;
/** Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) */ /** Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) */
declare function setWindowIcon(image: Image): void; declare function setWindowIcon(image: Image): void;
/** Set title for window (only PLATFORM_DESKTOP) */ /** Set title for window (only PLATFORM_DESKTOP) */
declare function setWindowTitle(title: string): void; declare function setWindowTitle(title: string | undefined | null): void;
/** Set window position on screen (only PLATFORM_DESKTOP) */ /** Set window position on screen (only PLATFORM_DESKTOP) */
declare function setWindowPosition(x: number, y: number): void; declare function setWindowPosition(x: number, y: number): void;
/** Set monitor for the current window (fullscreen mode) */ /** Set monitor for the current window (fullscreen mode) */
@ -410,11 +410,11 @@ declare function getWindowPosition(): Vector2;
/** Get window scale DPI factor */ /** Get window scale DPI factor */
declare function getWindowScaleDPI(): Vector2; declare function getWindowScaleDPI(): Vector2;
/** Get the human-readable, UTF-8 encoded name of the primary monitor */ /** Get the human-readable, UTF-8 encoded name of the primary monitor */
declare function getMonitorName(monitor: number): string; declare function getMonitorName(monitor: number): string | undefined | null;
/** Set clipboard text content */ /** Set clipboard text content */
declare function setClipboardText(text: string): void; declare function setClipboardText(text: string | undefined | null): void;
/** Get clipboard text content */ /** Get clipboard text content */
declare function getClipboardText(): string; declare function getClipboardText(): string | undefined | null;
/** Enable waiting for events on EndDrawing(), no automatic event polling */ /** Enable waiting for events on EndDrawing(), no automatic event polling */
declare function enableEventWaiting(): void; declare function enableEventWaiting(): void;
/** Disable waiting for events on EndDrawing(), automatic events polling */ /** Disable waiting for events on EndDrawing(), automatic events polling */
@ -462,15 +462,15 @@ declare function beginScissorMode(x: number, y: number, width: number, height: n
/** End scissor mode */ /** End scissor mode */
declare function endScissorMode(): void; declare function endScissorMode(): void;
/** Load shader from files and bind default locations */ /** Load shader from files and bind default locations */
declare function loadShader(vsFileName: string, fsFileName: string): Shader; declare function loadShader(vsFileName: string | undefined | null, fsFileName: string | undefined | null): Shader;
/** Load shader from code strings and bind default locations */ /** Load shader from code strings and bind default locations */
declare function loadShaderFromMemory(vsCode: string, fsCode: string): Shader; declare function loadShaderFromMemory(vsCode: string | undefined | null, fsCode: string | undefined | null): Shader;
/** Check if a shader is ready */ /** Check if a shader is ready */
declare function isShaderReady(shader: Shader): boolean; declare function isShaderReady(shader: Shader): boolean;
/** Get shader uniform location */ /** Get shader uniform location */
declare function getShaderLocation(shader: Shader, uniformName: string): number; declare function getShaderLocation(shader: Shader, uniformName: string | undefined | null): number;
/** Get shader attribute location */ /** Get shader attribute location */
declare function getShaderLocationAttrib(shader: Shader, attribName: string): number; declare function getShaderLocationAttrib(shader: Shader, attribName: string | undefined | null): number;
/** Set shader uniform value */ /** Set shader uniform value */
declare function setShaderValue(shader: Shader, locIndex: number, value: any, uniformType: number): void; declare function setShaderValue(shader: Shader, locIndex: number, value: any, uniformType: number): void;
/** Set shader uniform value (matrix 4x4) */ /** Set shader uniform value (matrix 4x4) */
@ -506,59 +506,59 @@ declare function getRandomValue(min: number, max: number): number;
/** Set the seed for the random number generator */ /** Set the seed for the random number generator */
declare function setRandomSeed(seed: number): void; declare function setRandomSeed(seed: number): void;
/** Takes a screenshot of current screen (filename extension defines format) */ /** Takes a screenshot of current screen (filename extension defines format) */
declare function takeScreenshot(fileName: string): void; declare function takeScreenshot(fileName: string | undefined | null): void;
/** Setup init configuration flags (view FLAGS) */ /** Setup init configuration flags (view FLAGS) */
declare function setConfigFlags(flags: number): void; declare function setConfigFlags(flags: number): void;
/** Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) */ /** Show trace log messages (LOG_DEBUG, LOG_INFO, LOG_WARNING, LOG_ERROR...) */
declare function traceLog(logLevel: number, text: string): void; declare function traceLog(logLevel: number, text: string | undefined | null): void;
/** Set the current threshold (minimum) log level */ /** Set the current threshold (minimum) log level */
declare function setTraceLogLevel(logLevel: number): void; declare function setTraceLogLevel(logLevel: number): void;
/** Open URL with default system browser (if available) */ /** Open URL with default system browser (if available) */
declare function openURL(url: string): void; declare function openURL(url: string | undefined | null): void;
/** Load file data as byte array (read) */ /** Load file data as byte array (read) */
declare function loadFileData(fileName: string): ArrayBuffer; declare function loadFileData(fileName: string | undefined | null): ArrayBuffer;
/** Save data to file from byte array (write), returns true on success */ /** Save data to file from byte array (write), returns true on success */
declare function saveFileData(fileName: string, data: any, bytesToWrite: number): boolean; declare function saveFileData(fileName: string | undefined | null, data: any, bytesToWrite: number): boolean;
/** Load text data from file (read), returns a '\0' terminated string */ /** Load text data from file (read), returns a '\0' terminated string */
declare function loadFileText(fileName: string): string; declare function loadFileText(fileName: string | undefined | null): string | undefined | null;
/** Save text data to file (write), string must be '\0' terminated, returns true on success */ /** Save text data to file (write), string must be '\0' terminated, returns true on success */
declare function saveFileText(fileName: string, text: string): boolean; declare function saveFileText(fileName: string | undefined | null, text: string | undefined | null): boolean;
/** Check if file exists */ /** Check if file exists */
declare function fileExists(fileName: string): boolean; declare function fileExists(fileName: string | undefined | null): boolean;
/** Check if a directory path exists */ /** Check if a directory path exists */
declare function directoryExists(dirPath: string): boolean; declare function directoryExists(dirPath: string | undefined | null): boolean;
/** Check file extension (including point: .png, .wav) */ /** Check file extension (including point: .png, .wav) */
declare function isFileExtension(fileName: string, ext: string): boolean; declare function isFileExtension(fileName: string | undefined | null, ext: string | undefined | null): boolean;
/** Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) */ /** Get file length in bytes (NOTE: GetFileSize() conflicts with windows.h) */
declare function getFileLength(fileName: string): number; declare function getFileLength(fileName: string | undefined | null): number;
/** Get pointer to extension for a filename string (includes dot: '.png') */ /** Get pointer to extension for a filename string (includes dot: '.png') */
declare function getFileExtension(fileName: string): string; declare function getFileExtension(fileName: string | undefined | null): string | undefined | null;
/** Get pointer to filename for a path string */ /** Get pointer to filename for a path string */
declare function getFileName(filePath: string): string; declare function getFileName(filePath: string | undefined | null): string | undefined | null;
/** Get filename string without extension (uses static string) */ /** Get filename string without extension (uses static string) */
declare function getFileNameWithoutExt(filePath: string): string; declare function getFileNameWithoutExt(filePath: string | undefined | null): string | undefined | null;
/** Get full path for a given fileName with path (uses static string) */ /** Get full path for a given fileName with path (uses static string) */
declare function getDirectoryPath(filePath: string): string; declare function getDirectoryPath(filePath: string | undefined | null): string | undefined | null;
/** Get previous directory path for a given path (uses static string) */ /** Get previous directory path for a given path (uses static string) */
declare function getPrevDirectoryPath(dirPath: string): string; declare function getPrevDirectoryPath(dirPath: string | undefined | null): string | undefined | null;
/** Get current working directory (uses static string) */ /** Get current working directory (uses static string) */
declare function getWorkingDirectory(): string; declare function getWorkingDirectory(): string | undefined | null;
/** Get the directory if the running application (uses static string) */ /** Get the directory if the running application (uses static string) */
declare function getApplicationDirectory(): string; declare function getApplicationDirectory(): string | undefined | null;
/** Change working directory, return true on success */ /** Change working directory, return true on success */
declare function changeDirectory(dir: string): boolean; declare function changeDirectory(dir: string | undefined | null): boolean;
/** Check if a given path is a file or a directory */ /** Check if a given path is a file or a directory */
declare function isPathFile(path: string): boolean; declare function isPathFile(path: string | undefined | null): boolean;
/** Load directory filepaths */ /** Load directory filepaths */
declare function loadDirectoryFiles(dirPath: string): string[]; declare function loadDirectoryFiles(dirPath: string | undefined | null): string[];
/** Load directory filepaths with extension filtering and recursive directory scan */ /** Load directory filepaths with extension filtering and recursive directory scan */
declare function loadDirectoryFilesEx(basePath: string, filter: string, scanSubdirs: boolean): string[]; declare function loadDirectoryFilesEx(basePath: string | undefined | null, filter: string | undefined | null, scanSubdirs: boolean): string[];
/** Check if a file has been dropped into window */ /** Check if a file has been dropped into window */
declare function isFileDropped(): boolean; declare function isFileDropped(): boolean;
/** Load dropped filepaths */ /** Load dropped filepaths */
declare function loadDroppedFiles(): string[]; declare function loadDroppedFiles(): string[];
/** Get file modification time (last write time) */ /** Get file modification time (last write time) */
declare function getFileModTime(fileName: string): number; declare function getFileModTime(fileName: string | undefined | null): number;
/** Check if a key has been pressed once */ /** Check if a key has been pressed once */
declare function isKeyPressed(key: number): boolean; declare function isKeyPressed(key: number): boolean;
/** Check if a key is being pressed */ /** Check if a key is being pressed */
@ -576,7 +576,7 @@ declare function getCharPressed(): number;
/** Check if a gamepad is available */ /** Check if a gamepad is available */
declare function isGamepadAvailable(gamepad: number): boolean; declare function isGamepadAvailable(gamepad: number): boolean;
/** Get gamepad internal name id */ /** Get gamepad internal name id */
declare function getGamepadName(gamepad: number): string; declare function getGamepadName(gamepad: number): string | undefined | null;
/** Check if a gamepad button has been pressed once */ /** Check if a gamepad button has been pressed once */
declare function isGamepadButtonPressed(gamepad: number, button: number): boolean; declare function isGamepadButtonPressed(gamepad: number, button: number): boolean;
/** Check if a gamepad button is being pressed */ /** Check if a gamepad button is being pressed */
@ -592,7 +592,7 @@ declare function getGamepadAxisCount(gamepad: number): number;
/** Get axis movement value for a gamepad axis */ /** Get axis movement value for a gamepad axis */
declare function getGamepadAxisMovement(gamepad: number, axis: number): number; declare function getGamepadAxisMovement(gamepad: number, axis: number): number;
/** Set internal gamepad mappings (SDL_GameControllerDB) */ /** Set internal gamepad mappings (SDL_GameControllerDB) */
declare function setGamepadMappings(mappings: string): number; declare function setGamepadMappings(mappings: string | undefined | null): number;
/** Check if a mouse button has been pressed once */ /** Check if a mouse button has been pressed once */
declare function isMouseButtonPressed(button: number): boolean; declare function isMouseButtonPressed(button: number): boolean;
/** Check if a mouse button is being pressed */ /** Check if a mouse button is being pressed */
@ -738,11 +738,11 @@ declare function checkCollisionPointLine(point: Vector2, p1: Vector2, p2: Vector
/** Get collision rectangle for two rectangles collision */ /** Get collision rectangle for two rectangles collision */
declare function getCollisionRec(rec1: Rectangle, rec2: Rectangle): Rectangle; declare function getCollisionRec(rec1: Rectangle, rec2: Rectangle): Rectangle;
/** Load image from file into CPU memory (RAM) */ /** Load image from file into CPU memory (RAM) */
declare function loadImage(fileName: string): Image; declare function loadImage(fileName: string | undefined | null): Image;
/** Load image from RAW file data */ /** Load image from RAW file data */
declare function loadImageRaw(fileName: string, width: number, height: number, format: number, headerSize: number): Image; declare function loadImageRaw(fileName: string | undefined | null, width: number, height: number, format: number, headerSize: number): Image;
/** Load image from memory buffer, fileType refers to extension: i.e. '.png' */ /** Load image from memory buffer, fileType refers to extension: i.e. '.png' */
declare function loadImageFromMemory(fileType: string, fileData: ArrayBuffer, dataSize: number): Image; declare function loadImageFromMemory(fileType: string | undefined | null, fileData: ArrayBuffer, dataSize: number): Image;
/** Load image from GPU texture data */ /** Load image from GPU texture data */
declare function loadImageFromTexture(texture: Texture): Image; declare function loadImageFromTexture(texture: Texture): Image;
/** Load image from screen buffer and (screenshot) */ /** Load image from screen buffer and (screenshot) */
@ -752,7 +752,7 @@ declare function isImageReady(image: Image): boolean;
/** Unload image from CPU memory (RAM) */ /** Unload image from CPU memory (RAM) */
declare function unloadImage(image: Image): void; declare function unloadImage(image: Image): void;
/** Export image data to file, returns true on success */ /** Export image data to file, returns true on success */
declare function exportImage(image: Image, fileName: string): boolean; declare function exportImage(image: Image, fileName: string | undefined | null): boolean;
/** Generate image: plain color */ /** Generate image: plain color */
declare function genImageColor(width: number, height: number, color: Color): Image; declare function genImageColor(width: number, height: number, color: Color): Image;
/** Generate image: vertical gradient */ /** Generate image: vertical gradient */
@ -770,15 +770,15 @@ declare function genImagePerlinNoise(width: number, height: number, offsetX: num
/** Generate image: cellular algorithm, bigger tileSize means bigger cells */ /** Generate image: cellular algorithm, bigger tileSize means bigger cells */
declare function genImageCellular(width: number, height: number, tileSize: number): Image; declare function genImageCellular(width: number, height: number, tileSize: number): Image;
/** Generate image: grayscale image from text data */ /** Generate image: grayscale image from text data */
declare function genImageText(width: number, height: number, text: string): Image; declare function genImageText(width: number, height: number, text: string | undefined | null): Image;
/** Create an image duplicate (useful for transformations) */ /** Create an image duplicate (useful for transformations) */
declare function imageCopy(image: Image): Image; declare function imageCopy(image: Image): Image;
/** Create an image from another image piece */ /** Create an image from another image piece */
declare function imageFromImage(image: Image, rec: Rectangle): Image; declare function imageFromImage(image: Image, rec: Rectangle): Image;
/** Create an image from text (default font) */ /** Create an image from text (default font) */
declare function imageText(text: string, fontSize: number, color: Color): Image; declare function imageText(text: string | undefined | null, fontSize: number, color: Color): Image;
/** Create an image from text (custom sprite font) */ /** Create an image from text (custom sprite font) */
declare function imageTextEx(font: Font, text: string, fontSize: number, spacing: number, tint: Color): Image; declare function imageTextEx(font: Font, text: string | undefined | null, fontSize: number, spacing: number, tint: Color): Image;
/** Convert image data to desired format */ /** Convert image data to desired format */
declare function imageFormat(image: Image, newFormat: number): void; declare function imageFormat(image: Image, newFormat: number): void;
/** Convert image to POT (power-of-two) */ /** Convert image to POT (power-of-two) */
@ -860,11 +860,11 @@ declare function imageDrawRectangleLines(dst: Image, rec: Rectangle, thick: numb
/** Draw a source image within a destination image (tint applied to source) */ /** Draw a source image within a destination image (tint applied to source) */
declare function imageDraw(dst: Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, tint: Color): void; declare function imageDraw(dst: Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, tint: Color): void;
/** Draw text (using default font) within an image (destination) */ /** Draw text (using default font) within an image (destination) */
declare function imageDrawText(dst: Image, text: string, posX: number, posY: number, fontSize: number, color: Color): void; declare function imageDrawText(dst: Image, text: string | undefined | null, posX: number, posY: number, fontSize: number, color: Color): void;
/** Draw text (custom sprite font) within an image (destination) */ /** Draw text (custom sprite font) within an image (destination) */
declare function imageDrawTextEx(dst: Image, font: Font, text: string, position: Vector2, fontSize: number, spacing: number, tint: Color): void; declare function imageDrawTextEx(dst: Image, font: Font, text: string | undefined | null, position: Vector2, fontSize: number, spacing: number, tint: Color): void;
/** Load texture from file into GPU memory (VRAM) */ /** Load texture from file into GPU memory (VRAM) */
declare function loadTexture(fileName: string): Texture; declare function loadTexture(fileName: string | undefined | null): Texture;
/** Load texture from image data */ /** Load texture from image data */
declare function loadTextureFromImage(image: Image): Texture; declare function loadTextureFromImage(image: Image): Texture;
/** Load cubemap from image, multiple image cubemap layouts supported */ /** Load cubemap from image, multiple image cubemap layouts supported */
@ -930,9 +930,9 @@ declare function getPixelDataSize(width: number, height: number, format: number)
/** Get the default Font */ /** Get the default Font */
declare function getFontDefault(): Font; declare function getFontDefault(): Font;
/** Load font from file into GPU memory (VRAM) */ /** Load font from file into GPU memory (VRAM) */
declare function loadFont(fileName: string): Font; declare function loadFont(fileName: string | undefined | null): Font;
/** Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set */ /** Load font from file with extended parameters, use NULL for fontChars and 0 for glyphCount to load the default character set */
declare function loadFontEx(fileName: string, fontSize: number): Font; declare function loadFontEx(fileName: string | undefined | null, fontSize: number): Font;
/** Load font from Image (XNA style) */ /** Load font from Image (XNA style) */
declare function loadFontFromImage(image: Image, key: Color, firstChar: number): Font; declare function loadFontFromImage(image: Image, key: Color, firstChar: number): Font;
/** Check if a font is ready */ /** Check if a font is ready */
@ -942,17 +942,17 @@ declare function unloadFont(font: Font): void;
/** Draw current FPS */ /** Draw current FPS */
declare function drawFPS(posX: number, posY: number): void; declare function drawFPS(posX: number, posY: number): void;
/** Draw text (using default font) */ /** Draw text (using default font) */
declare function drawText(text: string, posX: number, posY: number, fontSize: number, color: Color): void; declare function drawText(text: string | undefined | null, posX: number, posY: number, fontSize: number, color: Color): void;
/** Draw text using font and additional parameters */ /** Draw text using font and additional parameters */
declare function drawTextEx(font: Font, text: string, position: Vector2, fontSize: number, spacing: number, tint: Color): void; declare function drawTextEx(font: Font, text: string | undefined | null, position: Vector2, fontSize: number, spacing: number, tint: Color): void;
/** Draw text using Font and pro parameters (rotation) */ /** Draw text using Font and pro parameters (rotation) */
declare function drawTextPro(font: Font, text: string, position: Vector2, origin: Vector2, rotation: number, fontSize: number, spacing: number, tint: Color): void; declare function drawTextPro(font: Font, text: string | undefined | null, position: Vector2, origin: Vector2, rotation: number, fontSize: number, spacing: number, tint: Color): void;
/** Draw one character (codepoint) */ /** Draw one character (codepoint) */
declare function drawTextCodepoint(font: Font, codepoint: number, position: Vector2, fontSize: number, tint: Color): void; declare function drawTextCodepoint(font: Font, codepoint: number, position: Vector2, fontSize: number, tint: Color): void;
/** Measure string width for default font */ /** Measure string width for default font */
declare function measureText(text: string, fontSize: number): number; declare function measureText(text: string | undefined | null, fontSize: number): number;
/** Measure string size for Font */ /** Measure string size for Font */
declare function measureTextEx(font: Font, text: string, fontSize: number, spacing: number): Vector2; declare function measureTextEx(font: Font, text: string | undefined | null, fontSize: number, spacing: number): Vector2;
/** Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found */ /** Get glyph index position in font for a codepoint (unicode character), fallback to '?' if not found */
declare function getGlyphIndex(font: Font, codepoint: number): number; declare function getGlyphIndex(font: Font, codepoint: number): number;
/** Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found */ /** Get glyph rectangle in font atlas for a codepoint (unicode character), fallback to '?' if not found */
@ -998,7 +998,7 @@ declare function drawRay(ray: Ray, color: Color): void;
/** Draw a grid (centered at (0, 0, 0)) */ /** Draw a grid (centered at (0, 0, 0)) */
declare function drawGrid(slices: number, spacing: number): void; declare function drawGrid(slices: number, spacing: number): void;
/** Load model from files (meshes and materials) */ /** Load model from files (meshes and materials) */
declare function loadModel(fileName: string): Model; declare function loadModel(fileName: string | undefined | null): Model;
/** Load model from generated mesh (default material) */ /** Load model from generated mesh (default material) */
declare function loadModelFromMesh(mesh: Mesh): Model; declare function loadModelFromMesh(mesh: Mesh): Model;
/** Check if a model is ready */ /** Check if a model is ready */
@ -1034,7 +1034,7 @@ declare function drawMesh(mesh: Mesh, material: Material, transform: Matrix): vo
/** Draw multiple mesh instances with material and different transforms */ /** Draw multiple mesh instances with material and different transforms */
declare function drawMeshInstanced(mesh: Mesh, material: Material, transforms: Matrix, instances: number): void; declare function drawMeshInstanced(mesh: Mesh, material: Material, transforms: Matrix, instances: number): void;
/** Export mesh data to file, returns true on success */ /** Export mesh data to file, returns true on success */
declare function exportMesh(mesh: Mesh, fileName: string): boolean; declare function exportMesh(mesh: Mesh, fileName: string | undefined | null): boolean;
/** Compute mesh bounding box limits */ /** Compute mesh bounding box limits */
declare function getMeshBoundingBox(mesh: Mesh): BoundingBox; declare function getMeshBoundingBox(mesh: Mesh): BoundingBox;
/** Compute mesh tangents */ /** Compute mesh tangents */
@ -1096,13 +1096,13 @@ declare function isAudioDeviceReady(): boolean;
/** Set master volume (listener) */ /** Set master volume (listener) */
declare function setMasterVolume(volume: number): void; declare function setMasterVolume(volume: number): void;
/** Load wave data from file */ /** Load wave data from file */
declare function loadWave(fileName: string): Wave; declare function loadWave(fileName: string | undefined | null): Wave;
/** Load wave from memory buffer, fileType refers to extension: i.e. '.wav' */ /** Load wave from memory buffer, fileType refers to extension: i.e. '.wav' */
declare function loadWaveFromMemory(fileType: string, fileData: ArrayBuffer, dataSize: number): Wave; declare function loadWaveFromMemory(fileType: string | undefined | null, fileData: ArrayBuffer, dataSize: number): Wave;
/** Checks if wave data is ready */ /** Checks if wave data is ready */
declare function isWaveReady(wave: Wave): boolean; declare function isWaveReady(wave: Wave): boolean;
/** Load sound from file */ /** Load sound from file */
declare function loadSound(fileName: string): Sound; declare function loadSound(fileName: string | undefined | null): Sound;
/** Load sound from wave data */ /** Load sound from wave data */
declare function loadSoundFromWave(wave: Wave): Sound; declare function loadSoundFromWave(wave: Wave): Sound;
/** Checks if a sound is ready */ /** Checks if a sound is ready */
@ -1114,7 +1114,7 @@ declare function unloadWave(wave: Wave): void;
/** Unload sound */ /** Unload sound */
declare function unloadSound(sound: Sound): void; declare function unloadSound(sound: Sound): void;
/** Export wave data to file, returns true on success */ /** Export wave data to file, returns true on success */
declare function exportWave(wave: Wave, fileName: string): boolean; declare function exportWave(wave: Wave, fileName: string | undefined | null): boolean;
/** Play a sound */ /** Play a sound */
declare function playSound(sound: Sound): void; declare function playSound(sound: Sound): void;
/** Stop playing a sound */ /** Stop playing a sound */
@ -1138,7 +1138,7 @@ declare function waveCrop(wave: Wave, initSample: number, finalSample: number):
/** Convert wave data to desired format */ /** Convert wave data to desired format */
declare function waveFormat(wave: Wave, sampleRate: number, sampleSize: number, channels: number): void; declare function waveFormat(wave: Wave, sampleRate: number, sampleSize: number, channels: number): void;
/** Load music stream from file */ /** Load music stream from file */
declare function loadMusicStream(fileName: string): Music; declare function loadMusicStream(fileName: string | undefined | null): Music;
/** Checks if a music stream is ready */ /** Checks if a music stream is ready */
declare function isMusicReady(music: Music): boolean; declare function isMusicReady(music: Music): boolean;
/** Unload music stream */ /** Unload music stream */
@ -1455,65 +1455,65 @@ declare function guiSetStyle(control: number, property: number, value: number):
/** Get one style property */ /** Get one style property */
declare function guiGetStyle(control: number, property: number): number; declare function guiGetStyle(control: number, property: number): number;
/** Window Box control, shows a window that can be closed */ /** Window Box control, shows a window that can be closed */
declare function guiWindowBox(bounds: Rectangle, title: string): boolean; declare function guiWindowBox(bounds: Rectangle, title: string | undefined | null): boolean;
/** Group Box control with text name */ /** Group Box control with text name */
declare function guiGroupBox(bounds: Rectangle, text: string): void; declare function guiGroupBox(bounds: Rectangle, text: string | undefined | null): void;
/** Line separator control, could contain text */ /** Line separator control, could contain text */
declare function guiLine(bounds: Rectangle, text: string): void; declare function guiLine(bounds: Rectangle, text: string | undefined | null): void;
/** Panel control, useful to group controls */ /** Panel control, useful to group controls */
declare function guiPanel(bounds: Rectangle, text: string): void; declare function guiPanel(bounds: Rectangle, text: string | undefined | null): void;
/** Scroll Panel control */ /** Scroll Panel control */
declare function guiScrollPanel(bounds: Rectangle, text: string, content: Rectangle, scroll: Vector2): Rectangle; declare function guiScrollPanel(bounds: Rectangle, text: string | undefined | null, content: Rectangle, scroll: Vector2): Rectangle;
/** Label control, shows text */ /** Label control, shows text */
declare function guiLabel(bounds: Rectangle, text: string): void; declare function guiLabel(bounds: Rectangle, text: string | undefined | null): void;
/** Button control, returns true when clicked */ /** Button control, returns true when clicked */
declare function guiButton(bounds: Rectangle, text: string): boolean; declare function guiButton(bounds: Rectangle, text: string | undefined | null): boolean;
/** Label button control, show true when clicked */ /** Label button control, show true when clicked */
declare function guiLabelButton(bounds: Rectangle, text: string): boolean; declare function guiLabelButton(bounds: Rectangle, text: string | undefined | null): boolean;
/** Toggle Button control, returns true when active */ /** Toggle Button control, returns true when active */
declare function guiToggle(bounds: Rectangle, text: string, active: boolean): boolean; declare function guiToggle(bounds: Rectangle, text: string | undefined | null, active: boolean): boolean;
/** Toggle Group control, returns active toggle index */ /** Toggle Group control, returns active toggle index */
declare function guiToggleGroup(bounds: Rectangle, text: string, active: number): number; declare function guiToggleGroup(bounds: Rectangle, text: string | undefined | null, active: number): number;
/** Check Box control, returns true when active */ /** Check Box control, returns true when active */
declare function guiCheckBox(bounds: Rectangle, text: string, checked: boolean): boolean; declare function guiCheckBox(bounds: Rectangle, text: string | undefined | null, checked: boolean): boolean;
/** Combo Box control, returns selected item index */ /** Combo Box control, returns selected item index */
declare function guiComboBox(bounds: Rectangle, text: string, active: number): number; declare function guiComboBox(bounds: Rectangle, text: string | undefined | null, active: number): number;
/** Dropdown Box control, returns selected item */ /** Dropdown Box control, returns selected item */
declare function guiDropdownBox(bounds: Rectangle, text: string, active: { active: number }, editMode: boolean): boolean; declare function guiDropdownBox(bounds: Rectangle, text: string | undefined | null, active: { active: number }, editMode: boolean): boolean;
/** Spinner control, returns selected value */ /** Spinner control, returns selected value */
declare function guiSpinner(bounds: Rectangle, text: string, value: { value: number }, minValue: number, maxValue: number, editMode: boolean): boolean; declare function guiSpinner(bounds: Rectangle, text: string | undefined | null, value: { value: number }, minValue: number, maxValue: number, editMode: boolean): boolean;
/** Value Box control, updates input text with numbers */ /** Value Box control, updates input text with numbers */
declare function guiValueBox(bounds: Rectangle, text: string, value: { value: number }, minValue: number, maxValue: number, editMode: boolean): boolean; declare function guiValueBox(bounds: Rectangle, text: string | undefined | null, value: { value: number }, minValue: number, maxValue: number, editMode: boolean): boolean;
/** Text Box control, updates input text */ /** Text Box control, updates input text */
declare function guiTextBox(bounds: Rectangle, text: { text: string }, editMode: boolean): boolean; declare function guiTextBox(bounds: Rectangle, text: { text: string }, editMode: boolean): boolean;
/** Slider control, returns selected value */ /** Slider control, returns selected value */
declare function guiSlider(bounds: Rectangle, textLeft: string, textRight: string, value: number, minValue: number, maxValue: number): number; declare function guiSlider(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: number, minValue: number, maxValue: number): number;
/** Slider Bar control, returns selected value */ /** Slider Bar control, returns selected value */
declare function guiSliderBar(bounds: Rectangle, textLeft: string, textRight: string, value: number, minValue: number, maxValue: number): number; declare function guiSliderBar(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: number, minValue: number, maxValue: number): number;
/** Progress Bar control, shows current progress value */ /** Progress Bar control, shows current progress value */
declare function guiProgressBar(bounds: Rectangle, textLeft: string, textRight: string, value: number, minValue: number, maxValue: number): number; declare function guiProgressBar(bounds: Rectangle, textLeft: string | undefined | null, textRight: string | undefined | null, value: number, minValue: number, maxValue: number): number;
/** Status Bar control, shows info text */ /** Status Bar control, shows info text */
declare function guiStatusBar(bounds: Rectangle, text: string): void; declare function guiStatusBar(bounds: Rectangle, text: string | undefined | null): void;
/** Dummy control for placeholders */ /** Dummy control for placeholders */
declare function guiDummyRec(bounds: Rectangle, text: string): void; declare function guiDummyRec(bounds: Rectangle, text: string | undefined | null): void;
/** Grid control, returns mouse cell position */ /** Grid control, returns mouse cell position */
declare function guiGrid(bounds: Rectangle, text: string, spacing: number, subdivs: number): Vector2; declare function guiGrid(bounds: Rectangle, text: string | undefined | null, spacing: number, subdivs: number): Vector2;
/** List View control, returns selected list item index */ /** List View control, returns selected list item index */
declare function guiListView(bounds: Rectangle, text: string, scrollIndex: { scrollIndex: number }, active: number): number; declare function guiListView(bounds: Rectangle, text: string | undefined | null, scrollIndex: { scrollIndex: number }, active: number): number;
/** Message Box control, displays a message */ /** Message Box control, displays a message */
declare function guiMessageBox(bounds: Rectangle, title: string, message: string, buttons: string): number; declare function guiMessageBox(bounds: Rectangle, title: string | undefined | null, message: string | undefined | null, buttons: string | undefined | null): number;
/** Text Input Box control, ask for text, supports secret */ /** Text Input Box control, ask for text, supports secret */
declare function guiTextInputBox(bounds: Rectangle, title: string, message: string, buttons: string, text: { text: string }, secretViewActive: { secretViewActive: number }): number; declare function guiTextInputBox(bounds: Rectangle, title: string | undefined | null, message: string | undefined | null, buttons: string | undefined | null, text: { text: string }, secretViewActive: { secretViewActive: number }): number;
/** Color Picker control (multiple color controls) */ /** Color Picker control (multiple color controls) */
declare function guiColorPicker(bounds: Rectangle, text: string, color: Color): Color; declare function guiColorPicker(bounds: Rectangle, text: string | undefined | null, color: Color): Color;
/** Color Panel control */ /** Color Panel control */
declare function guiColorPanel(bounds: Rectangle, text: string, color: Color): Color; declare function guiColorPanel(bounds: Rectangle, text: string | undefined | null, color: Color): Color;
/** Color Bar Alpha control */ /** Color Bar Alpha control */
declare function guiColorBarAlpha(bounds: Rectangle, text: string, alpha: number): number; declare function guiColorBarAlpha(bounds: Rectangle, text: string | undefined | null, alpha: number): number;
/** Color Bar Hue control */ /** Color Bar Hue control */
declare function guiColorBarHue(bounds: Rectangle, text: string, value: number): number; declare function guiColorBarHue(bounds: Rectangle, text: string | undefined | null, value: number): number;
/** Load style file over global style variable (.rgs) */ /** Load style file over global style variable (.rgs) */
declare function guiLoadStyle(fileName: string): void; declare function guiLoadStyle(fileName: string | undefined | null): void;
/** Load style default over global style */ /** Load style default over global style */
declare function guiLoadStyleDefault(): void; declare function guiLoadStyleDefault(): void;
/** Enable gui tooltips (global state) */ /** Enable gui tooltips (global state) */
@ -1521,9 +1521,9 @@ declare function guiEnableTooltip(): void;
/** Disable gui tooltips (global state) */ /** Disable gui tooltips (global state) */
declare function guiDisableTooltip(): void; declare function guiDisableTooltip(): void;
/** Set tooltip string */ /** Set tooltip string */
declare function guiSetTooltip(tooltip: string): void; declare function guiSetTooltip(tooltip: string | undefined | null): void;
/** Get text with icon id prepended (if supported) */ /** Get text with icon id prepended (if supported) */
declare function guiIconText(iconId: number, text: string): string; declare function guiIconText(iconId: number, text: string | undefined | null): string | undefined | null;
/** Set default icon drawing size */ /** Set default icon drawing size */
declare function guiSetIconScale(scale: number): void; declare function guiSetIconScale(scale: number): void;
/** Draw icon using pixel size at specified position */ /** Draw icon using pixel size at specified position */

View File

@ -1,19 +1,23 @@
import { Behaviour, Builder, Entity, HasBoundingBox, HasMouseInteraction, combine, hasDefault, hasDefaultFn, makeEntity, which, withBoundingBox, withComponent, withMouseInteraction } from "./entity" import { Behaviour, Builder, Creator, Entity, HasBoundingBox, HasMouseInteraction, HasPosition, HasSize, combine, hasDefault, hasDefaultFn, makeEntity, which, withBoundingBox, withComponent, withMouseInteraction, withPosition, withSize } from "./entity"
import { entityAdd, runGame } from "./game" import { entityAdd, gameRun, gameSetClearColor } from "./game"
import { HasText, withText } from "./text" import { HasText, withText } from "./text"
const withGuiBounds = withComponent<HasBoundingBox>(x => hasDefaultFn(x, 'boundingBox', () => new Rectangle(10,10,100,20))) const withGuiSize = withComponent<HasSize>(x => hasDefaultFn(x, 'size', () => new Vector2(100,20)))
type Button = Entity & HasBoundingBox & HasMouseInteraction & HasText type UiControl = Entity & HasPosition & HasSize
const makeControl = combine(makeEntity, withPosition, withSize)
type Button = Entity & HasPosition & HasSize & HasMouseInteraction & HasText
const drawsButton: Behaviour<Button> = { const drawsButton: Behaviour<Button> = {
draw: b => { draw: x => {
b.isClicked = guiButton(b.boundingBox, b.text) x.isClicked = guiButton(new Rectangle(x.position.x,x.position.y,x.size.x, x.size.y), x.text)
if(b.isClicked && b.onClick) b.onClick() if(x.isClicked && x.onClick) x.onClick()
} }
} }
const makeButton: Builder<Button> = combine( const makeButton: Builder<Button> = combine(
makeEntity, makeEntity,
withGuiBounds, withPosition,
withSize,
withMouseInteraction, withMouseInteraction,
withComponent<HasText>(x => hasDefault(x, 'text', 'Button')), withComponent<HasText>(x => hasDefault(x, 'text', 'Button')),
which(drawsButton)) which(drawsButton))
@ -26,24 +30,84 @@ interface HasChangedEvent {
onChange?: () => void onChange?: () => void
} }
const withChangedEvent = withComponent<HasChangedEvent>() const withChangedEvent = withComponent<HasChangedEvent>()
type Textbox = Entity & HasBoundingBox & HasText & HasActive & HasChangedEvent type Textbox = Entity & HasPosition & HasSize & HasText & HasActive & HasChangedEvent
const drawsTextbox: Behaviour<Textbox> = { const drawsTextbox: Behaviour<Textbox> = {
draw: t => { draw: x => {
if(guiTextBox(t.boundingBox, t, t.active)){ if(guiTextBox(new Rectangle(x.position.x,x.position.y,x.size.x, x.size.y), x, x.active)){
t.active = !t.active x.active = !x.active
if(!t.active && t.onChange) t.onChange() if(!x.active && x.onChange) x.onChange()
} }
} }
} }
const makeTextbox = combine(makeEntity, const makeTextbox: Builder<Textbox> = combine(makeEntity,
withGuiBounds, withGuiBounds,
withComponent<HasText>(x => hasDefault(x, 'text', '')), withText,
withActive, withActive,
withChangedEvent, withChangedEvent,
which(drawsTextbox)) which(drawsTextbox))
type CheckBox = Entity & HasBoundingBox & HasText & HasActive & HasChangedEvent
const drawsCheckbox: Behaviour<CheckBox> = {
draw: c => {
const old = c.active
c.active = guiCheckBox(c.boundingBox, c.text, c.active)
if(old != c.active && c.onChange) c.onChange()
}
}
const makeCheckbox: Builder<CheckBox> = combine(makeEntity,
withGuiBounds,
withText,
withActive,
withChangedEvent,
which(drawsCheckbox))
type Label = Entity & HasBoundingBox & HasText
const drawsLabel: Behaviour<Label> = { draw: c => guiLabel(c.boundingBox, c.text) }
const makeLabel: Builder<Label> = combine(makeEntity, withGuiBounds, withText, which(drawsLabel))
type WindowBox = Entity & HasBoundingBox & HasText
const drawsWindowBox: Behaviour<WindowBox> = { draw: c => guiWindowBox(c.boundingBox, c.text) }
const builderWindowBox: Builder<WindowBox> = combine(makeEntity, withGuiBounds, withText, which(drawsWindowBox))
type GroupBox = Entity & HasBoundingBox & HasText
const drawsGroupBox: Behaviour<WindowBox> = { draw: c => guiGroupBox(c.boundingBox, c.text) }
const makeGroupBox: Builder<GroupBox> = combine(makeEntity, withGuiBounds, withText, which(drawsGroupBox))
type Line = Entity & HasBoundingBox & HasText
const drawsLine: Behaviour<Line> = { draw: c => guiLine(c.boundingBox, c.text) }
const makeLine: Builder<Line> = combine(makeEntity, withGuiBounds, withText, which(drawsLine))
type Panel = Entity & HasBoundingBox & HasText
const drawsPanel: Behaviour<Panel> = { draw: c => guiPanel(c.boundingBox, c.text) }
const makePanel: Builder<Panel> = combine(makeEntity, withGuiBounds, withText, which(drawsPanel))
interface HasScrollView {
contentArea: Rectangle,
scroll: Vector2,
viewArea: Rectangle
}
const withScrollView = withComponent<HasScrollView & HasBoundingBox>(x => {
hasDefaultFn(x, 'contentArea', () => new Rectangle(x.boundingBox!.x, x.boundingBox!.y, x.boundingBox!.width, x.boundingBox!.height))
hasDefaultFn(x, 'viewArea', () => new Rectangle(x.boundingBox!.x, x.boundingBox!.y, x.boundingBox!.width, x.boundingBox!.height))
hasDefaultFn(x, 'scroll', () => new Vector2(0,0))
})
type ScrollPanel = Entity & HasBoundingBox & Partial<HasText> & HasScrollView
const drawsScrollView: Behaviour<ScrollPanel> = {
draw: s => {
s.viewArea = guiScrollPanel(s.boundingBox, s.text, s.contentArea, s.scroll)
}
}
const makeScollPanel: Builder<ScrollPanel> = combine(makeEntity, withComponent<Partial<HasText>>(), withGuiBounds, withScrollView, )
interface HasGuiGlobalState {}
type GuiGlobalState = Entity & HasGuiGlobalState
const appliesGuiGlobalState: Behaviour<GuiGlobalState> = {
update: g => gameSetClearColor(getColor(guiGetStyle(DEFAULT, BACKGROUND_COLOR)))
}
const guiState: GuiGlobalState = combine(makeEntity,withComponent<HasGuiGlobalState>(), which(appliesGuiGlobalState))({})
runGame({ width: 800, height: 600, title: 'My Editor', flags: FLAG_WINDOW_RESIZABLE }, async (quit) => {
gameRun({ width: 800, height: 600, title: 'My Editor', flags: FLAG_WINDOW_RESIZABLE }, async (quit) => {
const but = makeButton({ const but = makeButton({
text: 'Click Me!', text: 'Click Me!',
onClick: () => but.boundingBox.x += 20 onClick: () => but.boundingBox.x += 20
@ -53,6 +117,18 @@ runGame({ width: 800, height: 600, title: 'My Editor', flags: FLAG_WINDOW_RESIZA
boundingBox: new Rectangle(10, 50, 100, 20), boundingBox: new Rectangle(10, 50, 100, 20),
onChange: () => but.text = tb.text onChange: () => but.text = tb.text
}) })
const cb = makeCheckbox({
boundingBox: new Rectangle(10, 75, 20, 20),
text: "Check Me!",
onChange: () => cb.text = "Checkbox is "+ (cb.active ? "checked" : "not checked")
})
const l = makeLabel({
boundingBox: new Rectangle(10, 100, 100, 20),
text: "This is a label"
})
entityAdd(guiState)
entityAdd(but) entityAdd(but)
entityAdd(tb) entityAdd(tb)
entityAdd(cb)
entityAdd(l)
}) })

View File

@ -51,6 +51,10 @@ export interface HasBoundingBox {
boundingBox: Rectangle boundingBox: Rectangle
} }
export interface HasSize {
size: Vector2
}
export interface HasBehaviour { export interface HasBehaviour {
behaviours: Behaviour<any>[] behaviours: Behaviour<any>[]
} }
@ -67,6 +71,7 @@ let ID = 0
export const withIdentity = withComponent<HasIdentity>(x => hasDefaultFn(x,'id', () => ID++)) export const withIdentity = withComponent<HasIdentity>(x => hasDefaultFn(x,'id', () => ID++))
export const withBehaviour = withComponent<HasBehaviour>(x => hasDefaultFn(x, 'behaviours', () => [])) export const withBehaviour = withComponent<HasBehaviour>(x => hasDefaultFn(x, 'behaviours', () => []))
export const withPosition = withComponent<HasPosition>(x => hasDefaultFn(x, 'position', () => new Vector2(0,0))) export const withPosition = withComponent<HasPosition>(x => hasDefaultFn(x, 'position', () => new Vector2(0,0)))
export const withSize = withComponent<HasSize>(x => hasDefaultFn(x, 'size', () => new Vector2(0,0)))
export const withColor = withComponent<HasColor>(x => hasDefaultFn(x, 'color', () => new Color(255,255,255,255))) export const withColor = withComponent<HasColor>(x => hasDefaultFn(x, 'color', () => new Color(255,255,255,255)))
export const withBoundingBox = withComponent<HasBoundingBox>(x => hasDefaultFn(x, 'boundingBox', () => new Rectangle(0,0,0,0))) export const withBoundingBox = withComponent<HasBoundingBox>(x => hasDefaultFn(x, 'boundingBox', () => new Rectangle(0,0,0,0)))

View File

@ -109,7 +109,10 @@ const withConfig = withComponent<WindowConfig>(x => {
hasDefault(x, 'flags', 0) hasDefault(x, 'flags', 0)
}) })
export const runGame = (options: Partial<WindowConfig>, startupCallback: (quit: () => void) => void | Promise<void>) => { let gameClearColor = BLACK
export const gameSetClearColor = (c: Color) => gameClearColor = c
export const gameRun = (options: Partial<WindowConfig>, startupCallback: (quit: () => void) => void | Promise<void>) => {
const config = withConfig(options) const config = withConfig(options)
setConfigFlags(config.flags) setConfigFlags(config.flags)
initWindow(config.width,config.height,config.title) initWindow(config.width,config.height,config.title)
@ -123,7 +126,7 @@ export const runGame = (options: Partial<WindowConfig>, startupCallback: (quit:
if(exception) throw exception if(exception) throw exception
entitiyList.forEach(e => e.behaviours.forEach(b => b.update ? b.update(e) : undefined)) entitiyList.forEach(e => e.behaviours.forEach(b => b.update ? b.update(e) : undefined))
beginDrawing() beginDrawing()
clearBackground(BLACK) clearBackground(gameClearColor)
drawText("Active promises: "+ promiseUpdateList.length, 10,10, 8, RAYWHITE) drawText("Active promises: "+ promiseUpdateList.length, 10,10, 8, RAYWHITE)
entitiyList.forEach(e => e.behaviours.forEach(b => b.draw ? b.draw(e) : undefined)) entitiyList.forEach(e => e.behaviours.forEach(b => b.draw ? b.draw(e) : undefined))
endDrawing() endDrawing()

View File

@ -1,11 +1,11 @@
import { Choice } from "inkjs/engine/Choice"; import { Choice } from "inkjs/engine/Choice";
import { fadeIn, fadeOut, move, wait, waitAnyClicked, waitClick } from "./timing"; import { fadeIn, fadeOut, move, wait, waitAnyClicked, waitClick } from "./timing";
import { Builder, combine, withComponent } from "./entity"; import { Builder, combine, withComponent } from "./entity";
import { entityAdd, entityRemove, runGame } from "./game"; import { entityAdd, entityRemove, gameRun } from "./game";
import { ClickableText, makeClickableText, makeParagraph } from "./text"; import { ClickableText, makeClickableText, makeParagraph } from "./text";
import { Compiler } from "inkjs"; import { Compiler } from "inkjs";
runGame({ width: 800, height: 400, title: "The Intercept" }, async (quit) => { gameRun({ width: 800, height: 400, title: "The Intercept" }, async (quit) => {
const source = loadFileText("resources/intercept.ink") const source = loadFileText("resources/intercept.ink")
const c = new Compiler(source) const c = new Compiler(source)
const story = c.Compile() const story = c.Compile()

View File

@ -422,9 +422,9 @@ class GenericQuickJsGenerator extends generation_1.GenericCodeGenerator {
case "const char *": case "const char *":
//case "char *": //case "char *":
if (!supressDeclaration) if (!supressDeclaration)
this.statement(`${type} ${name} = JS_IsNull(${src}) ? NULL : (${type})JS_ToCString(ctx, ${src})`); this.statement(`${type} ${name} = (JS_IsNull(${src}) || JS_IsUndefined(${src})) ? NULL : (${type})JS_ToCString(ctx, ${src})`);
else else
this.statement(`${name} = JS_IsNull(${src}) ? NULL : (${type})JS_ToCString(ctx, ${src})`); this.statement(`${name} = (JS_IsNull(${src}) || JS_IsUndefined(${src})) ? NULL : (${type})JS_ToCString(ctx, ${src})`);
break; break;
case "double": case "double":
if (!supressDeclaration) if (!supressDeclaration)
@ -807,7 +807,7 @@ class TypeScriptDeclaration {
return "boolean"; return "boolean";
case "const char *": case "const char *":
case "char *": case "char *":
return "string"; return "string | undefined | null";
case "void *": case "void *":
case "const void *": case "const void *":
return "any"; return "any";

View File

@ -2037,7 +2037,7 @@ static JSValue js_initWindow(JSContext * ctx, JSValueConst this_val, int argc, J
JS_ToInt32(ctx, &width, argv[0]); JS_ToInt32(ctx, &width, argv[0]);
int height; int height;
JS_ToInt32(ctx, &height, argv[1]); JS_ToInt32(ctx, &height, argv[1]);
const char * title = JS_IsNull(argv[2]) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); const char * title = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]);
InitWindow(width, height, title); InitWindow(width, height, title);
JS_FreeCString(ctx, title); JS_FreeCString(ctx, title);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -2147,7 +2147,7 @@ static JSValue js_setWindowIcon(JSContext * ctx, JSValueConst this_val, int argc
} }
static JSValue js_setWindowTitle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_setWindowTitle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * title = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * title = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
SetWindowTitle(title); SetWindowTitle(title);
JS_FreeCString(ctx, title); JS_FreeCString(ctx, title);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -2309,7 +2309,7 @@ static JSValue js_getMonitorName(JSContext * ctx, JSValueConst this_val, int arg
} }
static JSValue js_setClipboardText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_setClipboardText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * text = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * text = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
SetClipboardText(text); SetClipboardText(text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -2465,8 +2465,8 @@ static JSValue js_endScissorMode(JSContext * ctx, JSValueConst this_val, int arg
} }
static JSValue js_loadShader(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadShader(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * vsFileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * vsFileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * fsFileName = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * fsFileName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
Shader returnVal = LoadShader(vsFileName, fsFileName); Shader returnVal = LoadShader(vsFileName, fsFileName);
JS_FreeCString(ctx, vsFileName); JS_FreeCString(ctx, vsFileName);
JS_FreeCString(ctx, fsFileName); JS_FreeCString(ctx, fsFileName);
@ -2478,8 +2478,8 @@ static JSValue js_loadShader(JSContext * ctx, JSValueConst this_val, int argc, J
} }
static JSValue js_loadShaderFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadShaderFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * vsCode = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * vsCode = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * fsCode = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * fsCode = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
Shader returnVal = LoadShaderFromMemory(vsCode, fsCode); Shader returnVal = LoadShaderFromMemory(vsCode, fsCode);
JS_FreeCString(ctx, vsCode); JS_FreeCString(ctx, vsCode);
JS_FreeCString(ctx, fsCode); JS_FreeCString(ctx, fsCode);
@ -2503,7 +2503,7 @@ static JSValue js_getShaderLocation(JSContext * ctx, JSValueConst this_val, int
Shader* shader_ptr = (Shader*)JS_GetOpaque2(ctx, argv[0], js_Shader_class_id); Shader* shader_ptr = (Shader*)JS_GetOpaque2(ctx, argv[0], js_Shader_class_id);
if(shader_ptr == NULL) return JS_EXCEPTION; if(shader_ptr == NULL) return JS_EXCEPTION;
Shader shader = *shader_ptr; Shader shader = *shader_ptr;
const char * uniformName = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * uniformName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int returnVal = GetShaderLocation(shader, uniformName); int returnVal = GetShaderLocation(shader, uniformName);
JS_FreeCString(ctx, uniformName); JS_FreeCString(ctx, uniformName);
JSValue ret = JS_NewInt32(ctx, returnVal); JSValue ret = JS_NewInt32(ctx, returnVal);
@ -2514,7 +2514,7 @@ static JSValue js_getShaderLocationAttrib(JSContext * ctx, JSValueConst this_val
Shader* shader_ptr = (Shader*)JS_GetOpaque2(ctx, argv[0], js_Shader_class_id); Shader* shader_ptr = (Shader*)JS_GetOpaque2(ctx, argv[0], js_Shader_class_id);
if(shader_ptr == NULL) return JS_EXCEPTION; if(shader_ptr == NULL) return JS_EXCEPTION;
Shader shader = *shader_ptr; Shader shader = *shader_ptr;
const char * attribName = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * attribName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int returnVal = GetShaderLocationAttrib(shader, attribName); int returnVal = GetShaderLocationAttrib(shader, attribName);
JS_FreeCString(ctx, attribName); JS_FreeCString(ctx, attribName);
JSValue ret = JS_NewInt32(ctx, returnVal); JSValue ret = JS_NewInt32(ctx, returnVal);
@ -2758,7 +2758,7 @@ static JSValue js_setRandomSeed(JSContext * ctx, JSValueConst this_val, int argc
} }
static JSValue js_takeScreenshot(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_takeScreenshot(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
TakeScreenshot(fileName); TakeScreenshot(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -2774,7 +2774,7 @@ static JSValue js_setConfigFlags(JSContext * ctx, JSValueConst this_val, int arg
static JSValue js_traceLog(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_traceLog(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
int logLevel; int logLevel;
JS_ToInt32(ctx, &logLevel, argv[0]); JS_ToInt32(ctx, &logLevel, argv[0]);
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
TraceLog(logLevel, text); TraceLog(logLevel, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -2788,14 +2788,14 @@ static JSValue js_setTraceLogLevel(JSContext * ctx, JSValueConst this_val, int a
} }
static JSValue js_openURL(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_openURL(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * url = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * url = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
OpenURL(url); OpenURL(url);
JS_FreeCString(ctx, url); JS_FreeCString(ctx, url);
return JS_UNDEFINED; return JS_UNDEFINED;
} }
static JSValue js_loadFileData(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadFileData(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
unsigned int bytesRead; unsigned int bytesRead;
unsigned char * retVal = LoadFileData(fileName, &bytesRead); unsigned char * retVal = LoadFileData(fileName, &bytesRead);
JSValue buffer = JS_NewArrayBufferCopy(ctx, (const uint8_t*)retVal, bytesRead); JSValue buffer = JS_NewArrayBufferCopy(ctx, (const uint8_t*)retVal, bytesRead);
@ -2804,7 +2804,7 @@ static JSValue js_loadFileData(JSContext * ctx, JSValueConst this_val, int argc,
} }
static JSValue js_saveFileData(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_saveFileData(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
size_t data_size; size_t data_size;
void * data_js = (void *)JS_GetArrayBuffer(ctx, &data_size, argv[1]); void * data_js = (void *)JS_GetArrayBuffer(ctx, &data_size, argv[1]);
if(data_js == NULL) { if(data_js == NULL) {
@ -2822,7 +2822,7 @@ static JSValue js_saveFileData(JSContext * ctx, JSValueConst this_val, int argc,
} }
static JSValue js_loadFileText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadFileText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
char * returnVal = LoadFileText(fileName); char * returnVal = LoadFileText(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JSValue ret = JS_NewString(ctx, returnVal); JSValue ret = JS_NewString(ctx, returnVal);
@ -2831,8 +2831,8 @@ static JSValue js_loadFileText(JSContext * ctx, JSValueConst this_val, int argc,
} }
static JSValue js_saveFileText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_saveFileText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
char * text = JS_IsNull(argv[1]) ? NULL : (char *)JS_ToCString(ctx, argv[1]); char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (char *)JS_ToCString(ctx, argv[1]);
bool returnVal = SaveFileText(fileName, text); bool returnVal = SaveFileText(fileName, text);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
@ -2841,7 +2841,7 @@ static JSValue js_saveFileText(JSContext * ctx, JSValueConst this_val, int argc,
} }
static JSValue js_fileExists(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_fileExists(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
bool returnVal = FileExists(fileName); bool returnVal = FileExists(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -2849,7 +2849,7 @@ static JSValue js_fileExists(JSContext * ctx, JSValueConst this_val, int argc, J
} }
static JSValue js_directoryExists(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_directoryExists(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * dirPath = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * dirPath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
bool returnVal = DirectoryExists(dirPath); bool returnVal = DirectoryExists(dirPath);
JS_FreeCString(ctx, dirPath); JS_FreeCString(ctx, dirPath);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -2857,8 +2857,8 @@ static JSValue js_directoryExists(JSContext * ctx, JSValueConst this_val, int ar
} }
static JSValue js_isFileExtension(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_isFileExtension(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * ext = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * ext = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool returnVal = IsFileExtension(fileName, ext); bool returnVal = IsFileExtension(fileName, ext);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JS_FreeCString(ctx, ext); JS_FreeCString(ctx, ext);
@ -2867,7 +2867,7 @@ static JSValue js_isFileExtension(JSContext * ctx, JSValueConst this_val, int ar
} }
static JSValue js_getFileLength(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_getFileLength(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
int returnVal = GetFileLength(fileName); int returnVal = GetFileLength(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JSValue ret = JS_NewInt32(ctx, returnVal); JSValue ret = JS_NewInt32(ctx, returnVal);
@ -2875,7 +2875,7 @@ static JSValue js_getFileLength(JSContext * ctx, JSValueConst this_val, int argc
} }
static JSValue js_getFileExtension(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_getFileExtension(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * returnVal = GetFileExtension(fileName); const char * returnVal = GetFileExtension(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JSValue ret = JS_NewString(ctx, returnVal); JSValue ret = JS_NewString(ctx, returnVal);
@ -2883,7 +2883,7 @@ static JSValue js_getFileExtension(JSContext * ctx, JSValueConst this_val, int a
} }
static JSValue js_getFileName(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_getFileName(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * filePath = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * filePath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * returnVal = GetFileName(filePath); const char * returnVal = GetFileName(filePath);
JS_FreeCString(ctx, filePath); JS_FreeCString(ctx, filePath);
JSValue ret = JS_NewString(ctx, returnVal); JSValue ret = JS_NewString(ctx, returnVal);
@ -2891,7 +2891,7 @@ static JSValue js_getFileName(JSContext * ctx, JSValueConst this_val, int argc,
} }
static JSValue js_getFileNameWithoutExt(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_getFileNameWithoutExt(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * filePath = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * filePath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * returnVal = GetFileNameWithoutExt(filePath); const char * returnVal = GetFileNameWithoutExt(filePath);
JS_FreeCString(ctx, filePath); JS_FreeCString(ctx, filePath);
JSValue ret = JS_NewString(ctx, returnVal); JSValue ret = JS_NewString(ctx, returnVal);
@ -2899,7 +2899,7 @@ static JSValue js_getFileNameWithoutExt(JSContext * ctx, JSValueConst this_val,
} }
static JSValue js_getDirectoryPath(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_getDirectoryPath(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * filePath = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * filePath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * returnVal = GetDirectoryPath(filePath); const char * returnVal = GetDirectoryPath(filePath);
JS_FreeCString(ctx, filePath); JS_FreeCString(ctx, filePath);
JSValue ret = JS_NewString(ctx, returnVal); JSValue ret = JS_NewString(ctx, returnVal);
@ -2907,7 +2907,7 @@ static JSValue js_getDirectoryPath(JSContext * ctx, JSValueConst this_val, int a
} }
static JSValue js_getPrevDirectoryPath(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_getPrevDirectoryPath(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * dirPath = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * dirPath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * returnVal = GetPrevDirectoryPath(dirPath); const char * returnVal = GetPrevDirectoryPath(dirPath);
JS_FreeCString(ctx, dirPath); JS_FreeCString(ctx, dirPath);
JSValue ret = JS_NewString(ctx, returnVal); JSValue ret = JS_NewString(ctx, returnVal);
@ -2927,7 +2927,7 @@ static JSValue js_getApplicationDirectory(JSContext * ctx, JSValueConst this_val
} }
static JSValue js_changeDirectory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_changeDirectory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * dir = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * dir = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
bool returnVal = ChangeDirectory(dir); bool returnVal = ChangeDirectory(dir);
JS_FreeCString(ctx, dir); JS_FreeCString(ctx, dir);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -2935,7 +2935,7 @@ static JSValue js_changeDirectory(JSContext * ctx, JSValueConst this_val, int ar
} }
static JSValue js_isPathFile(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_isPathFile(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * path = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * path = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
bool returnVal = IsPathFile(path); bool returnVal = IsPathFile(path);
JS_FreeCString(ctx, path); JS_FreeCString(ctx, path);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -2943,7 +2943,7 @@ static JSValue js_isPathFile(JSContext * ctx, JSValueConst this_val, int argc, J
} }
static JSValue js_loadDirectoryFiles(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadDirectoryFiles(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * dirPath = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * dirPath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
FilePathList files = LoadDirectoryFiles(dirPath); FilePathList files = LoadDirectoryFiles(dirPath);
JSValue ret = JS_NewArray(ctx); JSValue ret = JS_NewArray(ctx);
for(int i; i < files.count; i++){ for(int i; i < files.count; i++){
@ -2955,8 +2955,8 @@ static JSValue js_loadDirectoryFiles(JSContext * ctx, JSValueConst this_val, int
} }
static JSValue js_loadDirectoryFilesEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadDirectoryFilesEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * basePath = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * basePath = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
const char * filter = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * filter = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool scanSubdirs = JS_ToBool(ctx, argv[2]); bool scanSubdirs = JS_ToBool(ctx, argv[2]);
FilePathList files = LoadDirectoryFilesEx(basePath, filter, scanSubdirs); FilePathList files = LoadDirectoryFilesEx(basePath, filter, scanSubdirs);
JSValue ret = JS_NewArray(ctx); JSValue ret = JS_NewArray(ctx);
@ -2986,7 +2986,7 @@ static JSValue js_loadDroppedFiles(JSContext * ctx, JSValueConst this_val, int a
} }
static JSValue js_getFileModTime(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_getFileModTime(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
long returnVal = GetFileModTime(fileName); long returnVal = GetFileModTime(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JSValue ret = JS_NewInt32(ctx, returnVal); JSValue ret = JS_NewInt32(ctx, returnVal);
@ -3125,7 +3125,7 @@ static JSValue js_getGamepadAxisMovement(JSContext * ctx, JSValueConst this_val,
} }
static JSValue js_setGamepadMappings(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_setGamepadMappings(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * mappings = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * mappings = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
int returnVal = SetGamepadMappings(mappings); int returnVal = SetGamepadMappings(mappings);
JS_FreeCString(ctx, mappings); JS_FreeCString(ctx, mappings);
JSValue ret = JS_NewInt32(ctx, returnVal); JSValue ret = JS_NewInt32(ctx, returnVal);
@ -4095,7 +4095,7 @@ static JSValue js_getCollisionRec(JSContext * ctx, JSValueConst this_val, int ar
} }
static JSValue js_loadImage(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadImage(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
Image returnVal = LoadImage(fileName); Image returnVal = LoadImage(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
Image* ret_ptr = (Image*)js_malloc(ctx, sizeof(Image)); Image* ret_ptr = (Image*)js_malloc(ctx, sizeof(Image));
@ -4106,7 +4106,7 @@ static JSValue js_loadImage(JSContext * ctx, JSValueConst this_val, int argc, JS
} }
static JSValue js_loadImageRaw(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadImageRaw(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
int width; int width;
JS_ToInt32(ctx, &width, argv[1]); JS_ToInt32(ctx, &width, argv[1]);
int height; int height;
@ -4125,7 +4125,7 @@ static JSValue js_loadImageRaw(JSContext * ctx, JSValueConst this_val, int argc,
} }
static JSValue js_loadImageFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadImageFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileType = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileType = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
size_t fileData_size; size_t fileData_size;
void * fileData_js = (void *)JS_GetArrayBuffer(ctx, &fileData_size, argv[1]); void * fileData_js = (void *)JS_GetArrayBuffer(ctx, &fileData_size, argv[1]);
if(fileData_js == NULL) { if(fileData_js == NULL) {
@ -4187,7 +4187,7 @@ static JSValue js_exportImage(JSContext * ctx, JSValueConst this_val, int argc,
Image* image_ptr = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); Image* image_ptr = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id);
if(image_ptr == NULL) return JS_EXCEPTION; if(image_ptr == NULL) return JS_EXCEPTION;
Image image = *image_ptr; Image image = *image_ptr;
const char * fileName = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * fileName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool returnVal = ExportImage(image, fileName); bool returnVal = ExportImage(image, fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -4349,7 +4349,7 @@ static JSValue js_genImageText(JSContext * ctx, JSValueConst this_val, int argc,
JS_ToInt32(ctx, &width, argv[0]); JS_ToInt32(ctx, &width, argv[0]);
int height; int height;
JS_ToInt32(ctx, &height, argv[1]); JS_ToInt32(ctx, &height, argv[1]);
const char * text = JS_IsNull(argv[2]) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); const char * text = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]);
Image returnVal = GenImageText(width, height, text); Image returnVal = GenImageText(width, height, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
Image* ret_ptr = (Image*)js_malloc(ctx, sizeof(Image)); Image* ret_ptr = (Image*)js_malloc(ctx, sizeof(Image));
@ -4387,7 +4387,7 @@ static JSValue js_imageFromImage(JSContext * ctx, JSValueConst this_val, int arg
} }
static JSValue js_imageText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_imageText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * text = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * text = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
int fontSize; int fontSize;
JS_ToInt32(ctx, &fontSize, argv[1]); JS_ToInt32(ctx, &fontSize, argv[1]);
Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id);
@ -4406,7 +4406,7 @@ static JSValue js_imageTextEx(JSContext * ctx, JSValueConst this_val, int argc,
Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id); Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id);
if(font_ptr == NULL) return JS_EXCEPTION; if(font_ptr == NULL) return JS_EXCEPTION;
Font font = *font_ptr; Font font = *font_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
double _double_fontSize; double _double_fontSize;
JS_ToFloat64(ctx, &_double_fontSize, argv[2]); JS_ToFloat64(ctx, &_double_fontSize, argv[2]);
float fontSize = (float)_double_fontSize; float fontSize = (float)_double_fontSize;
@ -4907,7 +4907,7 @@ static JSValue js_imageDraw(JSContext * ctx, JSValueConst this_val, int argc, JS
static JSValue js_imageDrawText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_imageDrawText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id); Image* dst = (Image*)JS_GetOpaque2(ctx, argv[0], js_Image_class_id);
if(dst == NULL) return JS_EXCEPTION; if(dst == NULL) return JS_EXCEPTION;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int posX; int posX;
JS_ToInt32(ctx, &posX, argv[2]); JS_ToInt32(ctx, &posX, argv[2]);
int posY; int posY;
@ -4928,7 +4928,7 @@ static JSValue js_imageDrawTextEx(JSContext * ctx, JSValueConst this_val, int ar
Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[1], js_Font_class_id); Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[1], js_Font_class_id);
if(font_ptr == NULL) return JS_EXCEPTION; if(font_ptr == NULL) return JS_EXCEPTION;
Font font = *font_ptr; Font font = *font_ptr;
const char * text = JS_IsNull(argv[2]) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); const char * text = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]);
Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id); Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[3], js_Vector2_class_id);
if(position_ptr == NULL) return JS_EXCEPTION; if(position_ptr == NULL) return JS_EXCEPTION;
Vector2 position = *position_ptr; Vector2 position = *position_ptr;
@ -4947,7 +4947,7 @@ static JSValue js_imageDrawTextEx(JSContext * ctx, JSValueConst this_val, int ar
} }
static JSValue js_loadTexture(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadTexture(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
Texture2D returnVal = LoadTexture(fileName); Texture2D returnVal = LoadTexture(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
Texture2D* ret_ptr = (Texture2D*)js_malloc(ctx, sizeof(Texture2D)); Texture2D* ret_ptr = (Texture2D*)js_malloc(ctx, sizeof(Texture2D));
@ -5393,7 +5393,7 @@ static JSValue js_getFontDefault(JSContext * ctx, JSValueConst this_val, int arg
} }
static JSValue js_loadFont(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadFont(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
Font returnVal = LoadFont(fileName); Font returnVal = LoadFont(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
Font* ret_ptr = (Font*)js_malloc(ctx, sizeof(Font)); Font* ret_ptr = (Font*)js_malloc(ctx, sizeof(Font));
@ -5404,7 +5404,7 @@ static JSValue js_loadFont(JSContext * ctx, JSValueConst this_val, int argc, JSV
} }
static JSValue js_loadFontEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadFontEx(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
int fontSize; int fontSize;
JS_ToInt32(ctx, &fontSize, argv[1]); JS_ToInt32(ctx, &fontSize, argv[1]);
Font returnVal = LoadFontEx(fileName, fontSize, NULL, 0); Font returnVal = LoadFontEx(fileName, fontSize, NULL, 0);
@ -5460,7 +5460,7 @@ static JSValue js_drawFPS(JSContext * ctx, JSValueConst this_val, int argc, JSVa
} }
static JSValue js_drawText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_drawText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * text = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * text = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
int posX; int posX;
JS_ToInt32(ctx, &posX, argv[1]); JS_ToInt32(ctx, &posX, argv[1]);
int posY; int posY;
@ -5479,7 +5479,7 @@ static JSValue js_drawTextEx(JSContext * ctx, JSValueConst this_val, int argc, J
Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id); Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id);
if(font_ptr == NULL) return JS_EXCEPTION; if(font_ptr == NULL) return JS_EXCEPTION;
Font font = *font_ptr; Font font = *font_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id);
if(position_ptr == NULL) return JS_EXCEPTION; if(position_ptr == NULL) return JS_EXCEPTION;
Vector2 position = *position_ptr; Vector2 position = *position_ptr;
@ -5501,7 +5501,7 @@ static JSValue js_drawTextPro(JSContext * ctx, JSValueConst this_val, int argc,
Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id); Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id);
if(font_ptr == NULL) return JS_EXCEPTION; if(font_ptr == NULL) return JS_EXCEPTION;
Font font = *font_ptr; Font font = *font_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id); Vector2* position_ptr = (Vector2*)JS_GetOpaque2(ctx, argv[2], js_Vector2_class_id);
if(position_ptr == NULL) return JS_EXCEPTION; if(position_ptr == NULL) return JS_EXCEPTION;
Vector2 position = *position_ptr; Vector2 position = *position_ptr;
@ -5545,7 +5545,7 @@ static JSValue js_drawTextCodepoint(JSContext * ctx, JSValueConst this_val, int
} }
static JSValue js_measureText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_measureText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * text = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * text = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
int fontSize; int fontSize;
JS_ToInt32(ctx, &fontSize, argv[1]); JS_ToInt32(ctx, &fontSize, argv[1]);
int returnVal = MeasureText(text, fontSize); int returnVal = MeasureText(text, fontSize);
@ -5558,7 +5558,7 @@ static JSValue js_measureTextEx(JSContext * ctx, JSValueConst this_val, int argc
Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id); Font* font_ptr = (Font*)JS_GetOpaque2(ctx, argv[0], js_Font_class_id);
if(font_ptr == NULL) return JS_EXCEPTION; if(font_ptr == NULL) return JS_EXCEPTION;
Font font = *font_ptr; Font font = *font_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
double _double_fontSize; double _double_fontSize;
JS_ToFloat64(ctx, &_double_fontSize, argv[2]); JS_ToFloat64(ctx, &_double_fontSize, argv[2]);
float fontSize = (float)_double_fontSize; float fontSize = (float)_double_fontSize;
@ -5945,7 +5945,7 @@ static JSValue js_drawGrid(JSContext * ctx, JSValueConst this_val, int argc, JSV
} }
static JSValue js_loadModel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadModel(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
Model returnVal = LoadModel(fileName); Model returnVal = LoadModel(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
Model* ret_ptr = (Model*)js_malloc(ctx, sizeof(Model)); Model* ret_ptr = (Model*)js_malloc(ctx, sizeof(Model));
@ -6233,7 +6233,7 @@ static JSValue js_exportMesh(JSContext * ctx, JSValueConst this_val, int argc, J
Mesh* mesh_ptr = (Mesh*)JS_GetOpaque2(ctx, argv[0], js_Mesh_class_id); Mesh* mesh_ptr = (Mesh*)JS_GetOpaque2(ctx, argv[0], js_Mesh_class_id);
if(mesh_ptr == NULL) return JS_EXCEPTION; if(mesh_ptr == NULL) return JS_EXCEPTION;
Mesh mesh = *mesh_ptr; Mesh mesh = *mesh_ptr;
const char * fileName = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * fileName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool returnVal = ExportMesh(mesh, fileName); bool returnVal = ExportMesh(mesh, fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -6659,7 +6659,7 @@ static JSValue js_setMasterVolume(JSContext * ctx, JSValueConst this_val, int ar
} }
static JSValue js_loadWave(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadWave(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
Wave returnVal = LoadWave(fileName); Wave returnVal = LoadWave(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
Wave* ret_ptr = (Wave*)js_malloc(ctx, sizeof(Wave)); Wave* ret_ptr = (Wave*)js_malloc(ctx, sizeof(Wave));
@ -6670,7 +6670,7 @@ static JSValue js_loadWave(JSContext * ctx, JSValueConst this_val, int argc, JSV
} }
static JSValue js_loadWaveFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadWaveFromMemory(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileType = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileType = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
size_t fileData_size; size_t fileData_size;
void * fileData_js = (void *)JS_GetArrayBuffer(ctx, &fileData_size, argv[1]); void * fileData_js = (void *)JS_GetArrayBuffer(ctx, &fileData_size, argv[1]);
if(fileData_js == NULL) { if(fileData_js == NULL) {
@ -6700,7 +6700,7 @@ static JSValue js_isWaveReady(JSContext * ctx, JSValueConst this_val, int argc,
} }
static JSValue js_loadSound(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadSound(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
Sound returnVal = LoadSound(fileName); Sound returnVal = LoadSound(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
Sound* ret_ptr = (Sound*)js_malloc(ctx, sizeof(Sound)); Sound* ret_ptr = (Sound*)js_malloc(ctx, sizeof(Sound));
@ -6769,7 +6769,7 @@ static JSValue js_exportWave(JSContext * ctx, JSValueConst this_val, int argc, J
Wave* wave_ptr = (Wave*)JS_GetOpaque2(ctx, argv[0], js_Wave_class_id); Wave* wave_ptr = (Wave*)JS_GetOpaque2(ctx, argv[0], js_Wave_class_id);
if(wave_ptr == NULL) return JS_EXCEPTION; if(wave_ptr == NULL) return JS_EXCEPTION;
Wave wave = *wave_ptr; Wave wave = *wave_ptr;
const char * fileName = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * fileName = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool returnVal = ExportWave(wave, fileName); bool returnVal = ExportWave(wave, fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -6887,7 +6887,7 @@ static JSValue js_waveFormat(JSContext * ctx, JSValueConst this_val, int argc, J
} }
static JSValue js_loadMusicStream(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_loadMusicStream(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
Music returnVal = LoadMusicStream(fileName); Music returnVal = LoadMusicStream(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
Music* ret_ptr = (Music*)js_malloc(ctx, sizeof(Music)); Music* ret_ptr = (Music*)js_malloc(ctx, sizeof(Music));
@ -8771,7 +8771,7 @@ static JSValue js_guiWindowBox(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * title = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool returnVal = GuiWindowBox(bounds, title); bool returnVal = GuiWindowBox(bounds, title);
JS_FreeCString(ctx, title); JS_FreeCString(ctx, title);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -8782,7 +8782,7 @@ static JSValue js_guiGroupBox(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
GuiGroupBox(bounds, text); GuiGroupBox(bounds, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -8792,7 +8792,7 @@ static JSValue js_guiLine(JSContext * ctx, JSValueConst this_val, int argc, JSVa
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
GuiLine(bounds, text); GuiLine(bounds, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -8802,7 +8802,7 @@ static JSValue js_guiPanel(JSContext * ctx, JSValueConst this_val, int argc, JSV
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
GuiPanel(bounds, text); GuiPanel(bounds, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -8812,7 +8812,7 @@ static JSValue js_guiScrollPanel(JSContext * ctx, JSValueConst this_val, int arg
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
Rectangle* content_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[2], js_Rectangle_class_id); Rectangle* content_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[2], js_Rectangle_class_id);
if(content_ptr == NULL) return JS_EXCEPTION; if(content_ptr == NULL) return JS_EXCEPTION;
Rectangle content = *content_ptr; Rectangle content = *content_ptr;
@ -8831,7 +8831,7 @@ static JSValue js_guiLabel(JSContext * ctx, JSValueConst this_val, int argc, JSV
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
GuiLabel(bounds, text); GuiLabel(bounds, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -8841,7 +8841,7 @@ static JSValue js_guiButton(JSContext * ctx, JSValueConst this_val, int argc, JS
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool returnVal = GuiButton(bounds, text); bool returnVal = GuiButton(bounds, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -8852,7 +8852,7 @@ static JSValue js_guiLabelButton(JSContext * ctx, JSValueConst this_val, int arg
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool returnVal = GuiLabelButton(bounds, text); bool returnVal = GuiLabelButton(bounds, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
JSValue ret = JS_NewBool(ctx, returnVal); JSValue ret = JS_NewBool(ctx, returnVal);
@ -8863,7 +8863,7 @@ static JSValue js_guiToggle(JSContext * ctx, JSValueConst this_val, int argc, JS
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool active = JS_ToBool(ctx, argv[2]); bool active = JS_ToBool(ctx, argv[2]);
bool returnVal = GuiToggle(bounds, text, active); bool returnVal = GuiToggle(bounds, text, active);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
@ -8875,7 +8875,7 @@ static JSValue js_guiToggleGroup(JSContext * ctx, JSValueConst this_val, int arg
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int active; int active;
JS_ToInt32(ctx, &active, argv[2]); JS_ToInt32(ctx, &active, argv[2]);
int returnVal = GuiToggleGroup(bounds, text, active); int returnVal = GuiToggleGroup(bounds, text, active);
@ -8888,7 +8888,7 @@ static JSValue js_guiCheckBox(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
bool checked = JS_ToBool(ctx, argv[2]); bool checked = JS_ToBool(ctx, argv[2]);
bool returnVal = GuiCheckBox(bounds, text, checked); bool returnVal = GuiCheckBox(bounds, text, checked);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
@ -8900,7 +8900,7 @@ static JSValue js_guiComboBox(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int active; int active;
JS_ToInt32(ctx, &active, argv[2]); JS_ToInt32(ctx, &active, argv[2]);
int returnVal = GuiComboBox(bounds, text, active); int returnVal = GuiComboBox(bounds, text, active);
@ -8913,7 +8913,7 @@ static JSValue js_guiDropdownBox(JSContext * ctx, JSValueConst this_val, int arg
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int * active = NULL; int * active = NULL;
int active_out; int active_out;
if(!JS_IsNull(argv[2])) { if(!JS_IsNull(argv[2])) {
@ -8935,7 +8935,7 @@ static JSValue js_guiSpinner(JSContext * ctx, JSValueConst this_val, int argc, J
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int * value = NULL; int * value = NULL;
int value_out; int value_out;
if(!JS_IsNull(argv[2])) { if(!JS_IsNull(argv[2])) {
@ -8961,7 +8961,7 @@ static JSValue js_guiValueBox(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int * value = NULL; int * value = NULL;
int value_out; int value_out;
if(!JS_IsNull(argv[2])) { if(!JS_IsNull(argv[2])) {
@ -9006,8 +9006,8 @@ static JSValue js_guiSlider(JSContext * ctx, JSValueConst this_val, int argc, JS
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * textLeft = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
const char * textRight = JS_IsNull(argv[2]) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]);
double _double_value; double _double_value;
JS_ToFloat64(ctx, &_double_value, argv[3]); JS_ToFloat64(ctx, &_double_value, argv[3]);
float value = (float)_double_value; float value = (float)_double_value;
@ -9028,8 +9028,8 @@ static JSValue js_guiSliderBar(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * textLeft = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
const char * textRight = JS_IsNull(argv[2]) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]);
double _double_value; double _double_value;
JS_ToFloat64(ctx, &_double_value, argv[3]); JS_ToFloat64(ctx, &_double_value, argv[3]);
float value = (float)_double_value; float value = (float)_double_value;
@ -9050,8 +9050,8 @@ static JSValue js_guiProgressBar(JSContext * ctx, JSValueConst this_val, int arg
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * textLeft = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * textLeft = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
const char * textRight = JS_IsNull(argv[2]) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); const char * textRight = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]);
double _double_value; double _double_value;
JS_ToFloat64(ctx, &_double_value, argv[3]); JS_ToFloat64(ctx, &_double_value, argv[3]);
float value = (float)_double_value; float value = (float)_double_value;
@ -9072,7 +9072,7 @@ static JSValue js_guiStatusBar(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
GuiStatusBar(bounds, text); GuiStatusBar(bounds, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -9082,7 +9082,7 @@ static JSValue js_guiDummyRec(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
GuiDummyRec(bounds, text); GuiDummyRec(bounds, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -9092,7 +9092,7 @@ static JSValue js_guiGrid(JSContext * ctx, JSValueConst this_val, int argc, JSVa
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
double _double_spacing; double _double_spacing;
JS_ToFloat64(ctx, &_double_spacing, argv[2]); JS_ToFloat64(ctx, &_double_spacing, argv[2]);
float spacing = (float)_double_spacing; float spacing = (float)_double_spacing;
@ -9111,7 +9111,7 @@ static JSValue js_guiListView(JSContext * ctx, JSValueConst this_val, int argc,
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
int * scrollIndex = NULL; int * scrollIndex = NULL;
int scrollIndex_out; int scrollIndex_out;
if(!JS_IsNull(argv[2])) { if(!JS_IsNull(argv[2])) {
@ -9134,9 +9134,9 @@ static JSValue js_guiMessageBox(JSContext * ctx, JSValueConst this_val, int argc
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * title = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
const char * message = JS_IsNull(argv[2]) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); const char * message = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]);
const char * buttons = JS_IsNull(argv[3]) ? NULL : (const char *)JS_ToCString(ctx, argv[3]); const char * buttons = (JS_IsNull(argv[3]) || JS_IsUndefined(argv[3])) ? NULL : (const char *)JS_ToCString(ctx, argv[3]);
int returnVal = GuiMessageBox(bounds, title, message, buttons); int returnVal = GuiMessageBox(bounds, title, message, buttons);
JS_FreeCString(ctx, title); JS_FreeCString(ctx, title);
JS_FreeCString(ctx, message); JS_FreeCString(ctx, message);
@ -9149,9 +9149,9 @@ static JSValue js_guiTextInputBox(JSContext * ctx, JSValueConst this_val, int ar
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * title = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * title = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
const char * message = JS_IsNull(argv[2]) ? NULL : (const char *)JS_ToCString(ctx, argv[2]); const char * message = (JS_IsNull(argv[2]) || JS_IsUndefined(argv[2])) ? NULL : (const char *)JS_ToCString(ctx, argv[2]);
const char * buttons = JS_IsNull(argv[3]) ? NULL : (const char *)JS_ToCString(ctx, argv[3]); const char * buttons = (JS_IsNull(argv[3]) || JS_IsUndefined(argv[3])) ? NULL : (const char *)JS_ToCString(ctx, argv[3]);
JSValue text_js = JS_GetPropertyStr(ctx, argv[4], "text"); JSValue text_js = JS_GetPropertyStr(ctx, argv[4], "text");
size_t text_len; size_t text_len;
const char * text_val = JS_ToCStringLen(ctx, &text_len, text_js); const char * text_val = JS_ToCStringLen(ctx, &text_len, text_js);
@ -9183,7 +9183,7 @@ static JSValue js_guiColorPicker(JSContext * ctx, JSValueConst this_val, int arg
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id);
if(color_ptr == NULL) return JS_EXCEPTION; if(color_ptr == NULL) return JS_EXCEPTION;
Color color = *color_ptr; Color color = *color_ptr;
@ -9200,7 +9200,7 @@ static JSValue js_guiColorPanel(JSContext * ctx, JSValueConst this_val, int argc
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id); Color* color_ptr = (Color*)JS_GetOpaque2(ctx, argv[2], js_Color_class_id);
if(color_ptr == NULL) return JS_EXCEPTION; if(color_ptr == NULL) return JS_EXCEPTION;
Color color = *color_ptr; Color color = *color_ptr;
@ -9217,7 +9217,7 @@ static JSValue js_guiColorBarAlpha(JSContext * ctx, JSValueConst this_val, int a
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
double _double_alpha; double _double_alpha;
JS_ToFloat64(ctx, &_double_alpha, argv[2]); JS_ToFloat64(ctx, &_double_alpha, argv[2]);
float alpha = (float)_double_alpha; float alpha = (float)_double_alpha;
@ -9231,7 +9231,7 @@ static JSValue js_guiColorBarHue(JSContext * ctx, JSValueConst this_val, int arg
Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id); Rectangle* bounds_ptr = (Rectangle*)JS_GetOpaque2(ctx, argv[0], js_Rectangle_class_id);
if(bounds_ptr == NULL) return JS_EXCEPTION; if(bounds_ptr == NULL) return JS_EXCEPTION;
Rectangle bounds = *bounds_ptr; Rectangle bounds = *bounds_ptr;
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
double _double_value; double _double_value;
JS_ToFloat64(ctx, &_double_value, argv[2]); JS_ToFloat64(ctx, &_double_value, argv[2]);
float value = (float)_double_value; float value = (float)_double_value;
@ -9242,7 +9242,7 @@ static JSValue js_guiColorBarHue(JSContext * ctx, JSValueConst this_val, int arg
} }
static JSValue js_guiLoadStyle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_guiLoadStyle(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * fileName = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * fileName = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
GuiLoadStyle(fileName); GuiLoadStyle(fileName);
JS_FreeCString(ctx, fileName); JS_FreeCString(ctx, fileName);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -9264,7 +9264,7 @@ static JSValue js_guiDisableTooltip(JSContext * ctx, JSValueConst this_val, int
} }
static JSValue js_guiSetTooltip(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_guiSetTooltip(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
const char * tooltip = JS_IsNull(argv[0]) ? NULL : (const char *)JS_ToCString(ctx, argv[0]); const char * tooltip = (JS_IsNull(argv[0]) || JS_IsUndefined(argv[0])) ? NULL : (const char *)JS_ToCString(ctx, argv[0]);
GuiSetTooltip(tooltip); GuiSetTooltip(tooltip);
JS_FreeCString(ctx, tooltip); JS_FreeCString(ctx, tooltip);
return JS_UNDEFINED; return JS_UNDEFINED;
@ -9273,7 +9273,7 @@ static JSValue js_guiSetTooltip(JSContext * ctx, JSValueConst this_val, int argc
static JSValue js_guiIconText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) { static JSValue js_guiIconText(JSContext * ctx, JSValueConst this_val, int argc, JSValueConst * argv) {
int iconId; int iconId;
JS_ToInt32(ctx, &iconId, argv[0]); JS_ToInt32(ctx, &iconId, argv[0]);
const char * text = JS_IsNull(argv[1]) ? NULL : (const char *)JS_ToCString(ctx, argv[1]); const char * text = (JS_IsNull(argv[1]) || JS_IsUndefined(argv[1])) ? NULL : (const char *)JS_ToCString(ctx, argv[1]);
const char * returnVal = GuiIconText(iconId, text); const char * returnVal = GuiIconText(iconId, text);
JS_FreeCString(ctx, text); JS_FreeCString(ctx, text);
JSValue ret = JS_NewString(ctx, returnVal); JSValue ret = JS_NewString(ctx, returnVal);