remove undefined; only use null now
This commit is contained in:
@@ -18,7 +18,7 @@ $_.portal(e => {
|
||||
send(waiting_client, e.actor)
|
||||
send(e, waiting_client.actor)
|
||||
|
||||
waiting_client = undefined
|
||||
waiting_client = null
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ var graphics = use('graphics')
|
||||
var color = use('color')
|
||||
|
||||
var sprite = {
|
||||
image: undefined,
|
||||
image: null,
|
||||
set color(x) { this._sprite.color = x; },
|
||||
get color() { return this._sprite.color; },
|
||||
anim_speed: 1,
|
||||
@@ -26,8 +26,8 @@ var sprite = {
|
||||
|
||||
this.del_anim?.();
|
||||
this.del_anim = () => {
|
||||
this.del_anim = undefined;
|
||||
advance = undefined;
|
||||
this.del_anim = null;
|
||||
advance = null;
|
||||
stop?.();
|
||||
};
|
||||
|
||||
@@ -102,11 +102,11 @@ var sprite = {
|
||||
},
|
||||
garbage: function() {
|
||||
this.del_anim?.();
|
||||
this.anim = undefined;
|
||||
this.anim = null;
|
||||
tree.delete(this._sprite)
|
||||
this.transform.parent = undefined
|
||||
this.transform.parent = null
|
||||
for (var t of this.transform.children())
|
||||
t.parent = undefined
|
||||
t.parent = null
|
||||
delete this.transform.sprite
|
||||
delete this._sprite
|
||||
// log.console("CLEARED SPRITE")
|
||||
@@ -216,7 +216,7 @@ sprite.to_queue = function(ysort = false)
|
||||
};
|
||||
var culled = sprite.tree.query(camrect)
|
||||
if (culled.length == 0) return [];
|
||||
var cmd = graphics.make_sprite_queue(culled, prosperon.camera, undefined, 1);
|
||||
var cmd = graphics.make_sprite_queue(culled, prosperon.camera, null, 1);
|
||||
return cmd;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,18 @@ var input = use('input')
|
||||
var lay_ctx = layout.make_context();
|
||||
|
||||
var clay_base = {
|
||||
font: undefined,
|
||||
background_image: undefined,
|
||||
font: null,
|
||||
background_image: null,
|
||||
slice: 0,
|
||||
font: 'smalle.16',
|
||||
font_size: undefined,
|
||||
font_size: null,
|
||||
color: [1,1,1,1],
|
||||
spacing:0,
|
||||
padding:0,
|
||||
margin:0,
|
||||
offset:[0,0],
|
||||
size:undefined,
|
||||
background_color: undefined
|
||||
size:null,
|
||||
background_color: null
|
||||
};
|
||||
|
||||
var root_item;
|
||||
@@ -216,8 +216,8 @@ clay.button = function button(str, action, config = {})
|
||||
config.action = action;
|
||||
}
|
||||
|
||||
var hovered = undefined;
|
||||
clay.newframe = function() { hovered = undefined; }
|
||||
var hovered = null;
|
||||
clay.newframe = function() { hovered = null; }
|
||||
|
||||
// mousepos given in hud coordinates
|
||||
clay.draw_commands = function draw_commands(cmds, pos = [0,0], mousepos = prosperon.camera.screen2hud(input.mouse.screenpos()))
|
||||
|
||||
@@ -109,7 +109,7 @@ input.keyboard = {};
|
||||
input.keyboard.down = function (code) {
|
||||
if (typeof code == "number") return downkeys[code];
|
||||
if (typeof code == "string") return downkeys[code.toUpperCase().charCodeAt()] || downkeys[code.toLowerCase().charCodeAt()];
|
||||
return undefined;
|
||||
return null;
|
||||
};
|
||||
|
||||
input.print_pawn_kbm = function (pawn) {
|
||||
@@ -180,7 +180,7 @@ input.tabcomplete = function tabcomplete(val, list) {
|
||||
return list[0];
|
||||
}
|
||||
|
||||
var ret = undefined;
|
||||
var ret = null;
|
||||
var i = val.length;
|
||||
while (!ret && list.length != 0) {
|
||||
var char = list[0][i];
|
||||
|
||||
@@ -66,5 +66,5 @@ this.hud = function() {
|
||||
draw.images(bunnyTex, bunnies)
|
||||
|
||||
var msg = 'FPS: ' + fpsAvg.toFixed(2) + ' Bunnies: ' + bunnies.length
|
||||
draw.text(msg, {x:0, y:0, width:config.width, height:40}, undefined, 0, color.white, 0)
|
||||
draw.text(msg, {x:0, y:0, width:config.width, height:40}, null, 0, color.white, 0)
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ MovementSystem.prototype.tryMove = function (piece, to) {
|
||||
if (piece.colour != this.turn) return false;
|
||||
|
||||
// normalise ‘to’ into our hybrid coord
|
||||
var dest = [to.x != undefined ? to.x : to[0],
|
||||
to.y != undefined ? to.y : to[1]];
|
||||
var dest = [to.x ?? t[0],
|
||||
to.y ?? to[1]];
|
||||
|
||||
if (!this.grid.inBounds(dest)) return false;
|
||||
if (!this.rules.canMove(piece, piece.coord, dest, this.grid)) return false;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* helper – robust coord access */
|
||||
function cx(c) { return (c.x != undefined) ? c.x : c[0]; }
|
||||
function cy(c) { return (c.y != undefined) ? c.y : c[1]; }
|
||||
function cx(c) { return c.x ?? c[0] }
|
||||
function cy(c) { return c.y ?? c[1] }
|
||||
|
||||
/* simple move-shape checks */
|
||||
var deltas = {
|
||||
|
||||
@@ -82,5 +82,5 @@ this.hud = function() {
|
||||
|
||||
// Simple score display
|
||||
var msg = score1 + " " + score2
|
||||
draw.text(msg, {x:0, y:10, width:config.width, height:40}, undefined, 0, color.white, 0)
|
||||
draw.text(msg, {x:0, y:10, width:config.width, height:40}, null, 0, color.white, 0)
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ this.hud = function() {
|
||||
|
||||
if (gameState == "gameover") {
|
||||
var msg = "GAME OVER! Press SPACE to restart."
|
||||
draw.text(msg, {x:0, y:config.height*0.5-10, width:config.width, height:20}, undefined, 0, color.white)
|
||||
draw.text(msg, {x:0, y:config.height*0.5-10, width:config.width, height:20}, null, 0, color.white)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ this.hud = function() {
|
||||
}
|
||||
|
||||
// Next piece window
|
||||
draw.text("Next", {x:70, y:5, width:50, height:10}, undefined, 0, color.white)
|
||||
draw.text("Next", {x:70, y:5, width:50, height:10}, null, 0, color.white)
|
||||
if (nextPiece) {
|
||||
for (var i=0; i<nextPiece.blocks.length; i++) {
|
||||
var nx = nextPiece.blocks[i][0]
|
||||
@@ -262,10 +262,10 @@ this.hud = function() {
|
||||
|
||||
// Score & Level
|
||||
var info = "Score: " + score + "\nLines: " + linesCleared + "\nLevel: " + level
|
||||
draw.text(info, {x:70, y:30, width:90, height:50}, undefined, 0, color.white)
|
||||
draw.text(info, {x:70, y:30, width:90, height:50}, null, 0, color.white)
|
||||
|
||||
if (gameOver) {
|
||||
draw.text("GAME OVER", {x:10, y:config.height*0.5-5, width:config.width-20, height:20}, undefined, 0, color.red)
|
||||
draw.text("GAME OVER", {x:10, y:config.height*0.5-5, width:config.width-20, height:20}, null, 0, color.red)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@ var cache = new Map()
|
||||
// Image constructor function
|
||||
graphics.Image = function(surfaceData) {
|
||||
// Initialize private properties
|
||||
this[CPU] = surfaceData || undefined;
|
||||
this[GPU] = undefined;
|
||||
this[CPU] = surfaceData || null;
|
||||
this[GPU] = null;
|
||||
this[LOADING] = false;
|
||||
this[LASTUSE] = time.number();
|
||||
this.rect = {x:0, y:0, width:surfaceData.width, height:surfaceData.height};
|
||||
@@ -89,11 +89,11 @@ Object.defineProperties(graphics.Image.prototype, {
|
||||
|
||||
// Add methods to prototype
|
||||
graphics.Image.prototype.unload_gpu = function() {
|
||||
this[GPU] = undefined
|
||||
this[GPU] = null
|
||||
}
|
||||
|
||||
graphics.Image.prototype.unload_cpu = function() {
|
||||
this[CPU] = undefined
|
||||
this[CPU] = null
|
||||
}
|
||||
|
||||
function calc_image_size(img) {
|
||||
@@ -219,7 +219,7 @@ graphics.is_image[cell.DOC] = `
|
||||
|
||||
graphics.texture_from_data = function(data)
|
||||
{
|
||||
if (!(data instanceof ArrayBuffer)) return undefined
|
||||
if (!(data instanceof ArrayBuffer)) return null
|
||||
|
||||
var image = graphics.make_texture(data);
|
||||
var img = make_handle(image)
|
||||
|
||||
@@ -32,7 +32,7 @@ if (render_menu) {
|
||||
if (debug.console)
|
||||
debug.console = imgui.window("console", _ => {
|
||||
imgui.text(log.transcript);
|
||||
replstr = imgui.textinput(undefined, replstr);
|
||||
replstr = imgui.textinput(null, replstr);
|
||||
imgui.button("submit", _ => {
|
||||
eval(replstr);
|
||||
replstr = "";
|
||||
@@ -242,14 +242,14 @@ imgui.imagebutton[cell.DOC] = `Create an ImageButton widget which displays a tex
|
||||
imgui.textinput[cell.DOC] = `Show a single-line text input widget.
|
||||
|
||||
:param label: The label text next to the input box.
|
||||
:param text: The current text. If undefined, the box starts empty.
|
||||
:param text: The current text. If null, the box starts empty.
|
||||
:return: The updated text string after user editing.
|
||||
`;
|
||||
|
||||
imgui.textbox[cell.DOC] = `Show a multi-line text input widget.
|
||||
|
||||
:param label: The label text next to the input box.
|
||||
:param text: The current multi-line text. If undefined, starts empty.
|
||||
:param text: The current multi-line text. If null, starts empty.
|
||||
:return: The updated text after user editing.
|
||||
`;
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ var camera = {
|
||||
ortho:true,
|
||||
anchor:[0.5,0.5],//{x:0.5,y:0.5},
|
||||
rotation:[0,0,0,1],
|
||||
surface: undefined
|
||||
surface: null
|
||||
}
|
||||
|
||||
var util = use('util')
|
||||
@@ -278,13 +278,13 @@ function translate_draw_commands(commands) {
|
||||
var parseq = use('parseq', $_.delay)
|
||||
|
||||
// Wrap `send(actor,msg,cb)` into a parseq “requestor”
|
||||
// • on success: cb(data) → value=data, reason=undefined
|
||||
// • on failure: cb(undefined,err)
|
||||
// • on success: cb(data) → value=data, reason=null
|
||||
// • on failure: cb(null,err)
|
||||
function rpc_req(actor, msg) {
|
||||
return (cb, _) => {
|
||||
send(actor, msg, data => {
|
||||
if (data.error)
|
||||
cb(undefined, data)
|
||||
cb(null, data)
|
||||
else
|
||||
cb(data)
|
||||
})
|
||||
|
||||
@@ -41,12 +41,12 @@ function isRecognizedExtension(ext) {
|
||||
}
|
||||
|
||||
function find_in_path(filename, exts = []) {
|
||||
if (typeof filename != 'string') return undefined
|
||||
if (typeof filename != 'string') return null
|
||||
|
||||
if (filename.includes('.')) {
|
||||
var candidate = filename // possibly need "/" ?
|
||||
if (io.exists(candidate) && !io.is_directory(candidate)) return candidate
|
||||
return undefined
|
||||
return null
|
||||
}
|
||||
|
||||
// Only check extensions if exts is provided and not empty
|
||||
@@ -60,7 +60,7 @@ function find_in_path(filename, exts = []) {
|
||||
var candidate = filename
|
||||
if (io.exists(candidate) && !io.is_directory(candidate)) return candidate
|
||||
}
|
||||
return undefined
|
||||
return null
|
||||
}
|
||||
|
||||
// Return a canonical path (the real directory plus the path)
|
||||
|
||||
@@ -16,8 +16,8 @@ function add_timer(obj, fn, seconds) {
|
||||
var stop = function () {
|
||||
if (!timer) return
|
||||
timers.delete(stop)
|
||||
timer.fn = undefined
|
||||
timer = undefined
|
||||
timer.fn = null
|
||||
timer = null
|
||||
}
|
||||
|
||||
function execute() {
|
||||
@@ -203,7 +203,7 @@ actor.spawn = function spawn(script, config, actor_context) {
|
||||
prog.prog_fn.call(underling, actor_dollar)
|
||||
} catch(e) { throw e; }
|
||||
|
||||
if (underling[DEAD]) return undefined;
|
||||
if (underling[DEAD]) return null;
|
||||
|
||||
if (typeof config == 'object') Object.assign(underling, config)
|
||||
|
||||
@@ -276,7 +276,7 @@ ex.all_objects = function (fn, startobj = world) {
|
||||
ex.all_objects[cell.DOC] = `
|
||||
:param fn: A callback function that receives each object. If it returns a truthy value, iteration stops and that value is returned.
|
||||
:param startobj: The root object at which iteration begins, default is the global "world".
|
||||
:return: The first truthy value returned by fn, or undefined if none.
|
||||
:return: The first truthy value returned by fn, or null if none.
|
||||
Iterate over each object (and its sub-objects) in the hierarchy, calling fn for each one.
|
||||
`
|
||||
|
||||
@@ -379,10 +379,10 @@ var script_fn = function script_fn(path, args) {
|
||||
// Create a context object with args
|
||||
var context = Object.create(parsed.module_ret)
|
||||
context.__args__ = args || []
|
||||
var mod_script = `(function setup_${module_name}_module(){ var self = this; var $ = this; var exports = {}; var module = {exports: exports}; var define = undefined; var arg = this.__args__; ${parsed.module}})`
|
||||
var mod_script = `(function setup_${module_name}_module(){ var self = this; var $ = this; var exports = {}; var module = {exports: exports}; var define = null; var arg = this.__args__; ${parsed.module}})`
|
||||
var module_fn = js.eval(file, mod_script)
|
||||
parsed.module_ret = module_fn.call(context)
|
||||
if (parsed.module_ret == undefined || parsed.module_ret == null)
|
||||
if (parsed.module_ret == null || parsed.module_ret == null)
|
||||
throw new Error(`Module ${module_name} must return a value`)
|
||||
parsed.module_fn = module_fn
|
||||
}
|
||||
|
||||
@@ -138,14 +138,14 @@ function get_pipeline_ubo_slot(pipeline, name) {
|
||||
if (ubo.name.endsWith(name))
|
||||
return i;
|
||||
}
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
|
||||
get_pipeline_ubo_slot[cell.DOC] = `Return the index of a uniform buffer block within the pipeline's vertex reflection data by name suffix.
|
||||
|
||||
:param pipeline: The pipeline whose vertex reflection is inspected.
|
||||
:param name: A string suffix to match against the uniform buffer block name.
|
||||
:return: The integer index of the matching UBO, or undefined if not found.
|
||||
:return: The integer index of the matching UBO, or null if not found.
|
||||
`
|
||||
|
||||
function transpose4x4(val) {
|
||||
@@ -505,11 +505,11 @@ function render_camera(cmds, camera) {
|
||||
bind_pipeline(pass,pipeline);
|
||||
|
||||
var camslot = get_pipeline_ubo_slot(pipeline, 'TransformBuffer');
|
||||
if (typeof camslot != 'undefined')
|
||||
if (camslot != null)
|
||||
cmds.camera(camera, camslot);
|
||||
|
||||
modelslot = get_pipeline_ubo_slot(pipeline, "model");
|
||||
if (typeof modelslot != 'undefined') {
|
||||
if (modelslot != null) {
|
||||
var ubo = ubo_obj_to_array(pipeline, 'model', sprite_model_ubo);
|
||||
cmds.push_vertex_uniform_data(modelslot, ubo);
|
||||
}
|
||||
@@ -537,7 +537,7 @@ function render_camera(cmds, camera) {
|
||||
|
||||
cmds.push_debug_group("hud")
|
||||
var camslot = get_pipeline_ubo_slot(pipeline, 'TransformBuffer');
|
||||
if (typeof camslot != 'undefined')
|
||||
if (camslot != null)
|
||||
cmds.hud(camera.size, camslot);
|
||||
|
||||
for (var group of hud_queue) {
|
||||
@@ -661,7 +661,7 @@ function mask(image, pos, scale, rotation = 0, ref = 1) {
|
||||
var pipe = stencil_writer(ref);
|
||||
render.use_shader('sprite.cg', pipe);
|
||||
var t = new transform;
|
||||
t.trs(pos, undefined, scale);
|
||||
t.trs(pos, null, scale);
|
||||
set_model(t);
|
||||
render.use_mat({
|
||||
diffuse:image.texture,
|
||||
|
||||
@@ -17,8 +17,8 @@ var default_window = {
|
||||
height: 480,
|
||||
|
||||
// Position - can be numbers or "centered"
|
||||
x: undefined, // SDL_WINDOWPOS_UNDEFINED by default
|
||||
y: undefined, // SDL_WINDOWPOS_UNDEFINED by default
|
||||
x: null, // SDL_WINDOWPOS_null by default
|
||||
y: null, // SDL_WINDOWPOS_null by default
|
||||
|
||||
// Window behavior flags
|
||||
resizable: true,
|
||||
@@ -52,7 +52,7 @@ var default_window = {
|
||||
metal: false, // Force Metal context (macOS)
|
||||
|
||||
// Advanced properties
|
||||
parent: undefined, // Parent window for tooltips/popups/modal
|
||||
parent: null, // Parent window for tooltips/popups/modal
|
||||
modal: false, // Modal to parent window (requires parent)
|
||||
externalGraphicsContext: false, // Use external graphics context
|
||||
|
||||
@@ -129,7 +129,7 @@ function handle_window(msg) {
|
||||
switch (msg.op) {
|
||||
case 'destroy':
|
||||
win.destroy();
|
||||
win = undefined
|
||||
win = null
|
||||
return {success: true};
|
||||
|
||||
case 'show':
|
||||
@@ -157,7 +157,7 @@ function handle_window(msg) {
|
||||
|
||||
case 'set':
|
||||
var prop = msg.data ? msg.data.property : null;
|
||||
var value = msg.data ? msg.data.value : undefined;
|
||||
var value = msg.data ? msg.data.value : null;
|
||||
if (!prop) return {error: "Missing property name"};
|
||||
|
||||
// Validate property is settable
|
||||
@@ -220,7 +220,7 @@ function handle_window(msg) {
|
||||
// Renderer operation functions
|
||||
var renderfuncs = {
|
||||
destroy: function(msg) {
|
||||
ren = undefined
|
||||
ren = null
|
||||
return {success: true};
|
||||
},
|
||||
|
||||
@@ -269,7 +269,7 @@ var renderfuncs = {
|
||||
}
|
||||
|
||||
// Special handling for render target
|
||||
if (prop == 'target' && value != null && value != undefined) {
|
||||
if (prop == 'target' && value != null && value != null) {
|
||||
var tex = resources.texture[value];
|
||||
if (!tex) return {error: "Invalid texture id"};
|
||||
value = tex;
|
||||
@@ -522,7 +522,7 @@ function handle_texture(msg) {
|
||||
|
||||
case 'set':
|
||||
var prop = msg.data ? msg.data.property : null;
|
||||
var value = msg.data ? msg.data.value : undefined;
|
||||
var value = msg.data ? msg.data.value : null;
|
||||
if (!prop) return {error: "Missing property name"};
|
||||
|
||||
// Validate property is settable
|
||||
@@ -616,12 +616,12 @@ function handle_mouse(msg) {
|
||||
|
||||
switch (msg.op) {
|
||||
case 'show':
|
||||
if (msg.data == undefined) return {error: "Missing show parameter"};
|
||||
if (msg.data == null) return {error: "Missing show parameter"};
|
||||
mouse.show(msg.data);
|
||||
return {success: true};
|
||||
|
||||
case 'capture':
|
||||
if (msg.data == undefined) return {error: "Missing capture parameter"};
|
||||
if (msg.data == null) return {error: "Missing capture parameter"};
|
||||
mouse.capture(msg.data);
|
||||
return {success: true};
|
||||
|
||||
@@ -679,7 +679,7 @@ function handle_mouse(msg) {
|
||||
return {data: cursor_id};
|
||||
|
||||
case 'create_system_cursor':
|
||||
if (msg.data == undefined) return {error: "Missing cursor type"};
|
||||
if (msg.data == null) return {error: "Missing cursor type"};
|
||||
var cursor = mouse.create_system_cursor(msg.data);
|
||||
var cursor_id = allocate_id();
|
||||
resources.cursor[cursor_id] = cursor;
|
||||
|
||||
@@ -34,7 +34,7 @@ audio.cry = function cry(file) {
|
||||
if (!voice) return;
|
||||
return function() {
|
||||
voice.stop();
|
||||
voice = undefined;
|
||||
voice = null;
|
||||
}
|
||||
};
|
||||
audio.cry[doc.sym] =
|
||||
|
||||
@@ -53,7 +53,7 @@ var camera = {
|
||||
fov:50,
|
||||
near_z: 0,
|
||||
far_z: 1000,
|
||||
surface: undefined,
|
||||
surface: null,
|
||||
viewport: {x:0,y:0,width:1,height:1},
|
||||
ortho:true,
|
||||
anchor:[0,0],
|
||||
|
||||
@@ -18,7 +18,7 @@ var camera = {
|
||||
fov:50,
|
||||
near_z: 0,
|
||||
far_z: 1000,
|
||||
surface: undefined,
|
||||
surface: null,
|
||||
viewport: {x:0,y:0,width:1,height:1},
|
||||
ortho:true,
|
||||
anchor:[0,0],
|
||||
|
||||
@@ -19,7 +19,7 @@ var camera = {
|
||||
fov:50,
|
||||
near_z: 0,
|
||||
far_z: 1000,
|
||||
surface: undefined,
|
||||
surface: null,
|
||||
viewport: {x:0,y:0,width:1,height:1},
|
||||
ortho:true,
|
||||
anchor:[0.5,0.5],
|
||||
@@ -31,7 +31,7 @@ var hudcam = {
|
||||
fov:50,
|
||||
near_z: 0,
|
||||
far_z: 1000,
|
||||
surface: undefined,
|
||||
surface: null,
|
||||
viewport: {x:0,y:0,width:1,height:1},
|
||||
ortho:true,
|
||||
anchor:[0,0],
|
||||
|
||||
@@ -14,12 +14,12 @@ tilemap.for = function (map, fn) {
|
||||
for (var x = 0; x < map.tiles.length; x++) {
|
||||
if (!map.tiles[x]) continue;
|
||||
for (var y = 0; y < map.tiles[x].length; y++) {
|
||||
if (map.tiles[x][y] != undefined) {
|
||||
if (map.tiles[x][y] != null) {
|
||||
var result = fn(map.tiles[x][y], {
|
||||
x: x + map.offset_x,
|
||||
y: y + map.offset_y
|
||||
});
|
||||
if (result != undefined) {
|
||||
if (result != null) {
|
||||
map.tiles[x][y] = result;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ tilemap.prototype =
|
||||
at(pos) {
|
||||
var x = pos.x - this.offset_x;
|
||||
var y = pos.y - this.offset_y;
|
||||
if (!this.tiles[x]) return undefined;
|
||||
if (!this.tiles[x]) return null;
|
||||
return this.tiles[x][y];
|
||||
},
|
||||
|
||||
@@ -51,7 +51,7 @@ tilemap.prototype =
|
||||
for (var i = 0; i < this.tiles.length; i++) {
|
||||
if (!this.tiles[i]) this.tiles[i] = [];
|
||||
var new_col = [];
|
||||
for (var j = 0; j < shift; j++) new_col[j] = undefined;
|
||||
for (var j = 0; j < shift; j++) new_col[j] = null;
|
||||
this.tiles[i] = new_col.concat(this.tiles[i]);
|
||||
}
|
||||
this.offset_y = pos.y;
|
||||
|
||||
@@ -128,10 +128,10 @@ var tween = function (from, to, time, fn, cb) {
|
||||
|
||||
function cleanup() {
|
||||
stop()
|
||||
fn = undefined
|
||||
stop = undefined
|
||||
cb = undefined
|
||||
update = undefined
|
||||
fn = null
|
||||
stop = null
|
||||
cb = null
|
||||
update = null
|
||||
}
|
||||
|
||||
var update = function tween_update(dt) {
|
||||
|
||||
@@ -177,7 +177,7 @@ Object.defineProperty(Array.prototype, "delete", {
|
||||
value: function(item) {
|
||||
var idx = this.indexOf(item);
|
||||
if (idx > -1) this.splice(idx,1);
|
||||
return undefined;
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ function parse_key(key) {
|
||||
function get_nested(obj, path) {
|
||||
var current = obj
|
||||
for (var segment of path) {
|
||||
if (!current || typeof current != 'object') return undefined
|
||||
if (!current || typeof current != 'object') return null
|
||||
current = current[segment]
|
||||
}
|
||||
return current
|
||||
@@ -137,7 +137,7 @@ switch (command) {
|
||||
var path = parse_key(key)
|
||||
var value = get_nested(config, path)
|
||||
|
||||
if (value == undefined) {
|
||||
if (value == null) {
|
||||
log.error("Key not found: " + key)
|
||||
} else if (value && typeof value == 'object' && !Array.isArray(value)) {
|
||||
// Print all nested values
|
||||
@@ -212,7 +212,7 @@ switch (command) {
|
||||
var path = parse_key(key)
|
||||
var value = get_nested(config.actors[actor_name], path)
|
||||
|
||||
if (value == undefined) {
|
||||
if (value == null) {
|
||||
log.error("Key not found for actor " + actor_name + ": " + key)
|
||||
} else {
|
||||
log.console('actors.' + actor_name + '.' + key + ' = ' + format_value(value))
|
||||
|
||||
@@ -66,24 +66,24 @@ Angles in degrees or radians must first be converted prior to making a quaternio
|
||||
`;
|
||||
|
||||
prosperon.c_types.transform[cell.DOC].parent = `Get or set the transform's parent. If set, this transform becomes a child of
|
||||
the parent (re-parenting). Must be another transform object or undefined.
|
||||
the parent (re-parenting). Must be another transform object or null.
|
||||
|
||||
:param value: (when setting) Another transform or undefined.
|
||||
:param value: (when setting) Another transform or null.
|
||||
:return: The current parent transform (when getting), or None (when setting).
|
||||
`;
|
||||
|
||||
prosperon.c_types.transform[cell.DOC].change_hook = `A user-supplied function that's called whenever the transform's local matrix changes.
|
||||
If undefined, no hook is called.
|
||||
If null, no hook is called.
|
||||
|
||||
:param value: (when setting) A function.
|
||||
:return: The current function or undefined.
|
||||
:return: The current function or null.
|
||||
`;
|
||||
|
||||
prosperon.c_types.transform[cell.DOC].trs = `Set the transform's position, rotation, and scale in one call.
|
||||
|
||||
:param pos: [x,y,z] for position, or undefined to keep existing.
|
||||
:param quat: [qx,qy,qz,qw] for rotation, or undefined.
|
||||
:param scale: [sx,sy,sz] for scale, or undefined.
|
||||
:param pos: [x,y,z] for position, or null to keep existing.
|
||||
:param quat: [qx,qy,qz,qw] for rotation, or null.
|
||||
:param scale: [sx,sy,sz] for scale, or null.
|
||||
:return: None
|
||||
`;
|
||||
|
||||
@@ -231,7 +231,7 @@ prosperon.c_types.datastream[cell.DOC].framerate = `Return the framerate (FPS) o
|
||||
prosperon.c_types.datastream[cell.DOC].callback = `A function to call whenever a new frame is decoded. If not set, no callback is invoked.
|
||||
|
||||
:param fn: (when setting) A function that receives (surface).
|
||||
:return: The existing function or undefined if none.
|
||||
:return: The existing function or null if none.
|
||||
`;
|
||||
|
||||
|
||||
@@ -325,10 +325,10 @@ prosperon.c_types.SDL_Camera[cell.DOC] = {}
|
||||
prosperon.c_types.SDL_Camera[cell.DOC][cell.DOC] = `A handle to a physical camera device. Freed when references drop or camera is closed.
|
||||
`;
|
||||
|
||||
prosperon.c_types.SDL_Camera[cell.DOC].frame = `Acquire the latest camera frame (as an SDL_Surface). Returns undefined if no
|
||||
prosperon.c_types.SDL_Camera[cell.DOC].frame = `Acquire the latest camera frame (as an SDL_Surface). Returns null if no
|
||||
new frame is available yet. Throws on error.
|
||||
|
||||
:return: SDL_Surface or undefined.
|
||||
:return: SDL_Surface or null.
|
||||
`;
|
||||
|
||||
prosperon.c_types.SDL_Camera[cell.DOC].release_frame = `Release a frame surface previously acquired via camera.frame(). Must be
|
||||
@@ -376,9 +376,9 @@ prosperon.c_types.SDL_Window[cell.DOC].keyboard_shown = `Return whether the on-s
|
||||
:return: True if shown, false otherwise.
|
||||
`;
|
||||
|
||||
prosperon.c_types.SDL_Window[cell.DOC].theme = `Currently returns undefined. Placeholder for retrieving OS window theme info.
|
||||
prosperon.c_types.SDL_Window[cell.DOC].theme = `Currently returns null. Placeholder for retrieving OS window theme info.
|
||||
|
||||
:return: undefined
|
||||
:return: null
|
||||
`;
|
||||
|
||||
prosperon.c_types.SDL_Window[cell.DOC].safe_area = `Return a rect describing any OS-specific "safe" region for UI, e.g. on iPhone with a notch.
|
||||
@@ -502,7 +502,7 @@ prosperon.c_types.SDL_Renderer[cell.DOC].tile = `Tile a texture repeatedly withi
|
||||
:return: None
|
||||
`;
|
||||
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].get_image = `Read back the rendered pixels into a new SDL_Surface. If rect is undefined, capture entire output.
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].get_image = `Read back the rendered pixels into a new SDL_Surface. If rect is null, capture entire output.
|
||||
|
||||
:param rect: Optional {x,y,w,h}.
|
||||
:return: An SDL_Surface with the requested region's pixels.
|
||||
@@ -518,7 +518,7 @@ prosperon.c_types.SDL_Renderer[cell.DOC].fasttext = `Draw debug text using an in
|
||||
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].geometry = `Render custom geometry from a mesh object {pos, uv, color, indices, count} with an optional texture.
|
||||
|
||||
:param texture: The SDL_Texture or undefined.
|
||||
:param texture: The SDL_Texture or null.
|
||||
:param meshObject: The geometry data with typed arrays.
|
||||
:return: None
|
||||
`;
|
||||
@@ -536,15 +536,15 @@ For example, (320, 240) can auto-scale up to the window resolution.
|
||||
:return: None
|
||||
`;
|
||||
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].viewport = `Set the clipping viewport for rendering. Pass undefined to use the full render target.
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].viewport = `Set the clipping viewport for rendering. Pass null to use the full render target.
|
||||
|
||||
:param rect: {x, y, w, h}, or undefined.
|
||||
:param rect: {x, y, w, h}, or null.
|
||||
:return: None
|
||||
`;
|
||||
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].clip = `Set or clear the clipping rectangle for drawing. Pass undefined to clear.
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].clip = `Set or clear the clipping rectangle for drawing. Pass null to clear.
|
||||
|
||||
:param rect: {x, y, w, h} or undefined.
|
||||
:param rect: {x, y, w, h} or null.
|
||||
:return: None
|
||||
`;
|
||||
|
||||
@@ -579,9 +579,9 @@ prosperon.c_types.SDL_Renderer[cell.DOC].screen2world = `Convert a screen coordi
|
||||
:return: [wx, wy] in world space
|
||||
`;
|
||||
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].target = `Set or clear the current render target texture. Pass undefined to reset to the default/window.
|
||||
prosperon.c_types.SDL_Renderer[cell.DOC].target = `Set or clear the current render target texture. Pass null to reset to the default/window.
|
||||
|
||||
:param texture: An SDL_Texture or undefined
|
||||
:param texture: An SDL_Texture or null
|
||||
:return: None
|
||||
`;
|
||||
|
||||
|
||||
@@ -375,10 +375,10 @@ $_.clock = function(fn) {
|
||||
$_.clock[cell.DOC] = "takes a function input value that will eventually be called with the current time in number form."
|
||||
|
||||
var underlings = new Set() // this is more like "all actors that are notified when we die"
|
||||
var overling = undefined
|
||||
var root = undefined
|
||||
var overling = null
|
||||
var root = null
|
||||
|
||||
var receive_fn = undefined
|
||||
var receive_fn = null
|
||||
var greeters = {} // Router functions for when messages are received for a specific actor
|
||||
|
||||
globalThis.is_actor = function is_actor(actor) {
|
||||
@@ -426,8 +426,8 @@ $_.connection[cell.DOC] = "The connection function takes a callback function, an
|
||||
var peers = {}
|
||||
var id_address = {}
|
||||
var peer_queue = new Map()
|
||||
var portal = undefined
|
||||
var portal_fn = undefined
|
||||
var portal = null
|
||||
var portal_fn = null
|
||||
|
||||
$_.portal = function(fn, port) {
|
||||
if (portal) throw new Error(`Already started a portal listening on ${portal.port}`)
|
||||
@@ -649,7 +649,7 @@ globalThis.send = function send(actor, message, reply) {
|
||||
replies[id] = reply
|
||||
$_.delay(_ => {
|
||||
if (replies[id]) {
|
||||
replies[id](undefined, "timeout")
|
||||
replies[id](null, "timeout")
|
||||
delete replies[id]
|
||||
}
|
||||
}, REPLYTIMEOUT)
|
||||
|
||||
@@ -8,7 +8,7 @@ This function enqueues an HTTP GET request for the specified URL. It supports bo
|
||||
:param options: Either a callback function or an object with optional properties:
|
||||
- 'callback': A function invoked upon request completion, receiving an object with 'data' (string or null) and 'error' (string or null) properties.
|
||||
- 'on_data': A function invoked for each chunk of streaming data, receiving a string chunk as its argument. If supplied, 'callback.data' will be null.
|
||||
:return: undefined
|
||||
:return: null
|
||||
:throws:
|
||||
- An error if the URL is not a string or is invalid.
|
||||
- An error if the options argument is neither a function nor an object.
|
||||
|
||||
@@ -72,11 +72,11 @@ Throw on error.
|
||||
:return: None
|
||||
`
|
||||
|
||||
io.mount[cell.DOC] = `Mount a directory or archive at the specified mount point. An undefined mount
|
||||
io.mount[cell.DOC] = `Mount a directory or archive at the specified mount point. An null mount
|
||||
point mounts to '/'. Throw on error.
|
||||
|
||||
:param archiveOrDir: The directory or archive to mount.
|
||||
:param mountPoint: The path at which to mount. If omitted or undefined, '/' is used.
|
||||
:param mountPoint: The path at which to mount. If omitted or null, '/' is used.
|
||||
:return: None
|
||||
`
|
||||
|
||||
@@ -145,10 +145,10 @@ operations. Throw on error.
|
||||
`
|
||||
|
||||
io.realdir[cell.DOC] = `Return the actual, real directory (on the host filesystem) that contains the given
|
||||
file path. Return undefined if not found.
|
||||
file path. Return null if not found.
|
||||
|
||||
:param path: The file path whose real directory is requested.
|
||||
:return: A string with the real directory path, or undefined.
|
||||
:return: A string with the real directory path, or null.
|
||||
`
|
||||
|
||||
io.searchpath[cell.DOC] = `Return an array of all directories in the current paths.
|
||||
|
||||
@@ -83,7 +83,7 @@ function encode_val(b, val)
|
||||
b.write_blob(TRUE_SYMBOL)
|
||||
else
|
||||
b.write_blob(FALSE_SYMBOL)
|
||||
} else if (type == 'undefined') {
|
||||
} else if (type == 'null') {
|
||||
b.write_blob(NULL_SYMBOL)
|
||||
} else if (type == 'object') {
|
||||
if (Array.isArray(val)) {
|
||||
@@ -118,7 +118,7 @@ function encode(val)
|
||||
|
||||
function decode(b)
|
||||
{
|
||||
return undefined
|
||||
return null
|
||||
}
|
||||
|
||||
return { INT, FP_HEADER, ARRAY, RECORD, BLOB, TEXT, NULL_SYMBOL, FALSE_SYMBOL, TRUE_SYMBOL, PRIVATE_SYMBOL, SYSTEM_SYMBOL, encode, decode }
|
||||
@@ -1,14 +1,14 @@
|
||||
var miniz = this
|
||||
|
||||
miniz.read[cell.DOC] = `Create a zip reader from the given ArrayBuffer containing an entire ZIP archive.
|
||||
Return undefined if the data is invalid.
|
||||
Return null if the data is invalid.
|
||||
|
||||
:param data: An ArrayBuffer with the entire ZIP file.
|
||||
:return: A 'zip reader' object with methods for reading from the archive (mod, exists, slurp).
|
||||
`
|
||||
|
||||
miniz.write[cell.DOC] = `Create a zip writer that writes to the specified file path. Overwrites the file if
|
||||
it already exists. Return undefined on error.
|
||||
it already exists. Return null on error.
|
||||
|
||||
:param path: The file path where the ZIP archive will be written.
|
||||
:return: A 'zip writer' object with methods for adding files to the archive (add_file).
|
||||
|
||||
@@ -31,10 +31,10 @@ This function serializes JavaScript values (such as numbers, strings, booleans,
|
||||
|
||||
nota.decode[cell.DOC] = `Decode a NOTA-encoded ArrayBuffer into a JavaScript value.
|
||||
|
||||
This function deserializes a NOTA-formatted ArrayBuffer into its corresponding JavaScript representation, such as a number, string, boolean, array, object, or ArrayBuffer. If the input is invalid or empty, it returns undefined.
|
||||
This function deserializes a NOTA-formatted ArrayBuffer into its corresponding JavaScript representation, such as a number, string, boolean, array, object, or ArrayBuffer. If the input is invalid or empty, it returns null.
|
||||
|
||||
:param buffer: An ArrayBuffer containing NOTA-encoded data to decode.
|
||||
:return: The decoded JavaScript value (e.g., number, string, boolean, array, object, or ArrayBuffer), or undefined if no argument is provided.
|
||||
:return: The decoded JavaScript value (e.g., number, string, boolean, array, object, or ArrayBuffer), or null if no argument is provided.
|
||||
`
|
||||
|
||||
return nota
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
Each factory returns a **requestor** function as described by the spec.
|
||||
*/
|
||||
|
||||
def delay = arg[0] // may be undefined
|
||||
def delay = arg[0] // may be null
|
||||
|
||||
// ———————————————————————————————————————— helpers
|
||||
|
||||
@@ -39,7 +39,7 @@ function check_callback (cb, factory) {
|
||||
}
|
||||
|
||||
function schedule (fn, seconds) {
|
||||
if (seconds == undefined || seconds <= 0) return fn()
|
||||
if (seconds == null || seconds <= 0) return fn()
|
||||
if (typeof delay == 'function') return delay(fn, seconds)
|
||||
throw make_reason('schedule', '@.delay capability required for timeouts.')
|
||||
}
|
||||
@@ -52,10 +52,10 @@ function run (factory, requestors, initial, action, time_limit, throttle = 0) {
|
||||
let timer_cancel
|
||||
|
||||
function cancel (reason = make_reason(factory, 'Cancel.')) {
|
||||
if (timer_cancel) timer_cancel(), timer_cancel = undefined
|
||||
if (timer_cancel) timer_cancel(), timer_cancel = null
|
||||
if (!cancel_list) return
|
||||
cancel_list.forEach(c => { try { if (typeof c == 'function') c(reason) } catch (_) {} })
|
||||
cancel_list = undefined
|
||||
cancel_list = null
|
||||
}
|
||||
|
||||
function start_requestor (value) {
|
||||
@@ -65,22 +65,22 @@ function run (factory, requestors, initial, action, time_limit, throttle = 0) {
|
||||
|
||||
try {
|
||||
cancel_list[idx] = req(function req_cb (val, reason) {
|
||||
if (!cancel_list || idx == undefined) return
|
||||
cancel_list[idx] = undefined
|
||||
if (!cancel_list || idx == null) return
|
||||
cancel_list[idx] = null
|
||||
action(val, reason, idx)
|
||||
idx = undefined
|
||||
idx = null
|
||||
if (factory == 'sequence') start_requestor(val)
|
||||
else if (throttle) start_requestor(initial)
|
||||
}, value)
|
||||
} catch (ex) {
|
||||
action(undefined, ex, idx)
|
||||
idx = undefined
|
||||
action(null, ex, idx)
|
||||
idx = null
|
||||
if (factory == 'sequence') start_requestor(value)
|
||||
else if (throttle) start_requestor(initial)
|
||||
}
|
||||
}
|
||||
|
||||
if (time_limit != undefined) {
|
||||
if (time_limit != null) {
|
||||
if (typeof time_limit != 'number' || time_limit < 0)
|
||||
throw make_reason(factory, 'Bad time limit.', time_limit)
|
||||
if (time_limit > 0) timer_cancel = schedule(() => cancel(make_reason(factory, 'Timeout.', time_limit)), time_limit)
|
||||
@@ -123,9 +123,9 @@ function par_all (collection, time_limit, throttle) {
|
||||
def results = new Array(list.length)
|
||||
|
||||
def cancel = run(factory, list, initial, (val, reason, idx) => {
|
||||
if (val == undefined) {
|
||||
if (val == null) {
|
||||
cancel(reason)
|
||||
return cb(undefined, reason)
|
||||
return cb(null, reason)
|
||||
}
|
||||
results[idx] = val
|
||||
if (--pending == 0) cb(_denormalize(names, results))
|
||||
@@ -148,12 +148,12 @@ function par_any (collection, time_limit, throttle) {
|
||||
|
||||
def cancel = run(factory, list, initial, (val, reason, idx) => {
|
||||
pending--
|
||||
if (val != undefined) successes[idx] = val
|
||||
if (successes.some(v => v != undefined)) {
|
||||
if (val != null) successes[idx] = val
|
||||
if (successes.some(v => v != null)) {
|
||||
if (!pending) cancel(make_reason(factory, 'Finished.'))
|
||||
return cb(_denormalize(names, successes.filter(v => v != undefined)))
|
||||
return cb(_denormalize(names, successes.filter(v => v != null)))
|
||||
}
|
||||
if (!pending) cb(undefined, make_reason(factory, 'No successes.'))
|
||||
if (!pending) cb(null, make_reason(factory, 'No successes.'))
|
||||
}, time_limit, throttle)
|
||||
|
||||
return cancel
|
||||
@@ -171,14 +171,14 @@ function race (list, time_limit, throttle) {
|
||||
let done = false
|
||||
def cancel = run(factory, list, initial, (val, reason, idx) => {
|
||||
if (done) return
|
||||
if (val != undefined) {
|
||||
if (val != null) {
|
||||
done = true
|
||||
cancel(make_reason(factory, 'Loser.', idx))
|
||||
cb(val)
|
||||
} else if (--list.length == 0) {
|
||||
done = true
|
||||
cancel(reason)
|
||||
cb(undefined, reason)
|
||||
cb(null, reason)
|
||||
}
|
||||
}, time_limit, throttle)
|
||||
return cancel
|
||||
@@ -203,11 +203,11 @@ function sequence (list, time_limit) {
|
||||
if (idx >= list.length) return cb(value)
|
||||
try {
|
||||
list[idx++](function seq_cb (val, reason) {
|
||||
if (val == undefined) return cb(undefined, reason)
|
||||
if (val == null) return cb(null, reason)
|
||||
next(val)
|
||||
}, value)
|
||||
} catch (ex) {
|
||||
cb(undefined, ex)
|
||||
cb(null, ex)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,8 +211,8 @@ function text() {
|
||||
if (to < 0) to += len;
|
||||
|
||||
// Default values
|
||||
if (from == undefined) from = 0;
|
||||
if (to == undefined) to = len;
|
||||
if (from == null) from = 0;
|
||||
if (to == null) to = len;
|
||||
|
||||
// Validate range
|
||||
if (from < 0 || from > to || to > len) return null;
|
||||
|
||||
@@ -124,6 +124,10 @@ function number(rec = now())
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* record → seconds-since-epoch */
|
||||
|
||||
log.console(typeof rec)
|
||||
log.console(rec)
|
||||
log.console(rec.minute)
|
||||
|
||||
var c = 0;
|
||||
var year = rec.year || 0;
|
||||
var hour = rec.hour || 0;
|
||||
|
||||
@@ -13,10 +13,10 @@ util.dainty_assign = function (target, source) {
|
||||
}
|
||||
|
||||
util.get = function (obj, path, defValue) {
|
||||
if (!path) return undefined
|
||||
if (!path) return null
|
||||
var pathArray = Array.isArray(path) ? path : path.match(/([^[.\]])+/g)
|
||||
var result = pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj)
|
||||
return result == undefined ? defValue : result
|
||||
return result == null ? defValue : result
|
||||
}
|
||||
|
||||
util.isEmpty = function(o) {
|
||||
@@ -36,7 +36,7 @@ util.access = function (obj, name) {
|
||||
var dig = name.split(".")
|
||||
for (var i of dig) {
|
||||
obj = obj[i]
|
||||
if (!obj) return undefined
|
||||
if (!obj) return null
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ This function serializes JavaScript values (such as numbers, strings, booleans,
|
||||
|
||||
wota.decode[cell.DOC] = `Decode a WOTA-encoded ArrayBuffer into a JavaScript value.
|
||||
|
||||
This function deserializes a WOTA-formatted ArrayBuffer into its corresponding JavaScript representation, such as a number, string, boolean, array, object, or ArrayBuffer. If the input is invalid or empty, it returns undefined.
|
||||
This function deserializes a WOTA-formatted ArrayBuffer into its corresponding JavaScript representation, such as a number, string, boolean, array, object, or ArrayBuffer. If the input is invalid or empty, it returns null.
|
||||
|
||||
:param buffer: An ArrayBuffer containing WOTA-encoded data to decode.
|
||||
:param reviver: An optional function that transforms the decoded values.
|
||||
:return: The decoded JavaScript value (e.g., number, string, boolean, array, object, or ArrayBuffer), or undefined if no argument is provided.
|
||||
:return: The decoded JavaScript value (e.g., number, string, boolean, array, object, or ArrayBuffer), or null if no argument is provided.
|
||||
`
|
||||
|
||||
return wota
|
||||
|
||||
@@ -378,7 +378,7 @@ void actor_unneeded(cell_rt *actor, JSValue fn, double seconds)
|
||||
JS_FreeValue(actor->context, actor->unneeded);
|
||||
|
||||
if (!JS_IsFunction(actor->context, fn)) {
|
||||
actor->unneeded = JS_UNDEFINED;
|
||||
actor->unneeded = JS_NULL;
|
||||
goto END;
|
||||
}
|
||||
|
||||
@@ -398,10 +398,10 @@ cell_rt *create_actor(void *wota)
|
||||
cell_rt *actor = calloc(sizeof(*actor), 1);
|
||||
actor->heap = mi_heap_new();
|
||||
actor->init_wota = wota;
|
||||
actor->idx_buffer = JS_UNDEFINED;
|
||||
actor->message_handle = JS_UNDEFINED;
|
||||
actor->unneeded = JS_UNDEFINED;
|
||||
actor->on_exception = JS_UNDEFINED;
|
||||
actor->idx_buffer = JS_NULL;
|
||||
actor->message_handle = JS_NULL;
|
||||
actor->unneeded = JS_NULL;
|
||||
actor->on_exception = JS_NULL;
|
||||
actor->actor_sym = JS_ATOM_NULL;
|
||||
|
||||
arrsetcap(actor->letters, 5);
|
||||
@@ -476,9 +476,9 @@ static Uint32 actor_remove_cb(cell_rt *actor, Uint32 id, Uint32 interval)
|
||||
{
|
||||
actor->disrupt = 1;
|
||||
|
||||
if (!JS_IsUndefined(actor->unneeded)) {
|
||||
if (!JS_IsNull(actor->unneeded)) {
|
||||
SDL_LockMutex(actor->mutex);
|
||||
JSValue ret = JS_Call(actor->context, actor->unneeded, JS_UNDEFINED, 0, NULL);
|
||||
JSValue ret = JS_Call(actor->context, actor->unneeded, JS_NULL, 0, NULL);
|
||||
uncaught_exception(actor->context, ret);
|
||||
SDL_UnlockMutex(actor->mutex);
|
||||
}
|
||||
@@ -574,11 +574,11 @@ void actor_turn(cell_rt *actor)
|
||||
size_t size = l.blob_data->length / 8; // Convert bits to bytes
|
||||
JSValue arg = js_new_blob_stoned_copy(actor->context, l.blob_data->data, size);
|
||||
blob_destroy(l.blob_data);
|
||||
result = JS_Call(actor->context, actor->message_handle, JS_UNDEFINED, 1, &arg);
|
||||
result = JS_Call(actor->context, actor->message_handle, JS_NULL, 1, &arg);
|
||||
uncaught_exception(actor->context, result);
|
||||
JS_FreeValue(actor->context, arg);
|
||||
} else if (l.type == LETTER_CALLBACK) {
|
||||
result = JS_Call(actor->context, l.callback, JS_UNDEFINED, 0, NULL);
|
||||
result = JS_Call(actor->context, l.callback, JS_NULL, 0, NULL);
|
||||
uncaught_exception(actor->context, result);
|
||||
JS_FreeValue(actor->context, l.callback);
|
||||
}
|
||||
@@ -627,7 +627,7 @@ JSValue js_actor_delay(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
JS_ToFloat64(js, &seconds, argv[1]);
|
||||
if (seconds <= 0) {
|
||||
actor_clock(actor, argv[0]);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
SDL_LockMutex(actor->msg_mutex);
|
||||
@@ -643,11 +643,11 @@ JSValue js_actor_removetimer(JSContext *js, JSValue self, int argc, JSValue *arg
|
||||
cell_rt *actor = JS_GetContextOpaque(js);
|
||||
uint32_t timer_id;
|
||||
JS_ToUint32(js, &timer_id, argv[0]);
|
||||
if (timer_id == -1) return JS_UNDEFINED;
|
||||
if (timer_id == -1) return JS_NULL;
|
||||
|
||||
SDL_RemoveTimer(timer_id);
|
||||
|
||||
JSValue cb = JS_UNDEFINED;
|
||||
JSValue cb = JS_NULL;
|
||||
|
||||
SDL_LockMutex(actor->msg_mutex);
|
||||
int id = hmgeti(actor->timers, timer_id);
|
||||
@@ -659,7 +659,7 @@ JSValue js_actor_removetimer(JSContext *js, JSValue self, int argc, JSValue *arg
|
||||
|
||||
JS_FreeValue(js,cb);
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Wrapper struct to keep the array pointer stable
|
||||
@@ -788,7 +788,7 @@ int uncaught_exception(JSContext *js, JSValue v)
|
||||
}
|
||||
|
||||
JSValue exp = JS_GetException(js);
|
||||
JSValue ret = JS_Call(js, rt->on_exception, JS_UNDEFINED, 1, &exp);
|
||||
JSValue ret = JS_Call(js, rt->on_exception, JS_NULL, 1, &exp);
|
||||
JS_FreeValue(js,ret);
|
||||
JS_FreeValue(js, exp);
|
||||
JS_FreeValue(js,v);
|
||||
|
||||
@@ -243,8 +243,8 @@ void free_gpu_buffer(JSRuntime *rt, void *opaque, void *ptr)
|
||||
JSValue make_gpu_buffer(JSContext *js, void *data, size_t size, int type, int elements, int copy, int index)
|
||||
{
|
||||
JSValue tstack[3];
|
||||
tstack[1] = JS_UNDEFINED;
|
||||
tstack[2] = JS_UNDEFINED;
|
||||
tstack[1] = JS_NULL;
|
||||
tstack[2] = JS_NULL;
|
||||
// TODO: always copying; implement "takeover"
|
||||
tstack[0] = js_new_blob_stoned_copy(js,data,size);//, make_gpu_buffer, NULL, 1);
|
||||
// JSValue ret = JS_NewTypedArray(js, 3, tstack, type);
|
||||
@@ -253,7 +253,7 @@ JSValue make_gpu_buffer(JSContext *js, void *data, size_t size, int type, int el
|
||||
// JS_SetPropertyStr(js,ret,"index", JS_NewBool(js,index));
|
||||
// JS_FreeValue(js,tstack[0]);
|
||||
// return ret;
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
void *get_gpu_buffer(JSContext *js, JSValue argv, size_t *stride, size_t *size)
|
||||
@@ -272,7 +272,7 @@ JSValue make_quad_indices_buffer(JSContext *js, int quads)
|
||||
{
|
||||
cell_rt *rt = JS_GetContextOpaque(js);
|
||||
int count = quads*6;
|
||||
if (!JS_IsUndefined(rt->idx_buffer) && rt->idx_count >= count)
|
||||
if (!JS_IsNull(rt->idx_buffer) && rt->idx_count >= count)
|
||||
return JS_DupValue(js,rt->idx_buffer);
|
||||
|
||||
int verts = quads*4;
|
||||
@@ -286,7 +286,7 @@ JSValue make_quad_indices_buffer(JSContext *js, int quads)
|
||||
indices[i+5] = v+1;
|
||||
}
|
||||
|
||||
if (!JS_IsUndefined(rt->idx_buffer))
|
||||
if (!JS_IsNull(rt->idx_buffer))
|
||||
JS_FreeValue(js,rt->idx_buffer);
|
||||
|
||||
// rt->idx_buffer = make_gpu_buffer(js,indices, sizeof(*indices)*count, JS_TYPED_ARRAY_UINT16, 1,0,1);
|
||||
@@ -380,10 +380,10 @@ double js2angle(JSContext *js,JSValue v) {
|
||||
typedef HMM_Vec4 colorf;
|
||||
|
||||
colorf js2color(JSContext *js,JSValue v) {
|
||||
if (JS_IsUndefined(v)) return (colorf){1,1,1,1};
|
||||
if (JS_IsNull(v)) return (colorf){1,1,1,1};
|
||||
JSValue c[4];
|
||||
for (int i = 0; i < 4; i++) c[i] = JS_GetPropertyUint32(js,v,i);
|
||||
float a = JS_IsUndefined(c[3]) ? 1.0 : js2number(js,c[3]);
|
||||
float a = JS_IsNull(c[3]) ? 1.0 : js2number(js,c[3]);
|
||||
colorf color = {
|
||||
.r = js2number(js,c[0]),
|
||||
.g = js2number(js,c[1]),
|
||||
@@ -532,7 +532,7 @@ JSValue vecarr2js(JSContext *js,HMM_Vec2 *points, int n) {
|
||||
}
|
||||
|
||||
rect js2rect(JSContext *js,JSValue v) {
|
||||
if (JS_IsUndefined(v)) return (rect){0,0,1,1};
|
||||
if (JS_IsNull(v)) return (rect){0,0,1,1};
|
||||
rect rect;
|
||||
JS_GETATOM(js,rect.x,v,x,number)
|
||||
JS_GETATOM(js,rect.y,v,y,number)
|
||||
@@ -550,7 +550,7 @@ rect js2rect(JSContext *js,JSValue v) {
|
||||
|
||||
irect js2irect(JSContext *js, JSValue v)
|
||||
{
|
||||
if (JS_IsUndefined(v)) return (irect){0,0,1,1};
|
||||
if (JS_IsNull(v)) return (irect){0,0,1,1};
|
||||
irect rect;
|
||||
JS_GETATOM(js,rect.x,v,x,number)
|
||||
JS_GETATOM(js,rect.y,v,y,number)
|
||||
@@ -694,7 +694,7 @@ JSC_CCALL(os_make_text_buffer,
|
||||
JSValue js_util_camera_globals(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
JSValue camera = argv[0];
|
||||
if(JS_IsUndefined(camera)) return JS_UNDEFINED;
|
||||
if(JS_IsNull(camera)) return JS_NULL;
|
||||
|
||||
HMM_Vec2 size; HMM_Vec3 pos; HMM_Quat rotation;
|
||||
double fov = 0; int ortho; double near_z = 0; double far_z = 0;
|
||||
@@ -815,10 +815,10 @@ JSC_CCALL(array_lerp,
|
||||
)
|
||||
|
||||
JSValue js_array_get_x(JSContext *js, JSValue self) { return JS_GetPropertyUint32(js,self,0); }
|
||||
JSValue js_array_set_x(JSContext *js, JSValue self, JSValue val) { JS_SetPropertyUint32(js,self,0,val); return JS_UNDEFINED; }
|
||||
JSValue js_array_set_x(JSContext *js, JSValue self, JSValue val) { JS_SetPropertyUint32(js,self,0,val); return JS_NULL; }
|
||||
|
||||
JSValue js_array_get_y(JSContext *js, JSValue self) { return JS_GetPropertyUint32(js,self,1); }
|
||||
JSValue js_array_set_y(JSContext *js, JSValue self, JSValue val) { JS_SetPropertyUint32(js,self,1,val); return JS_UNDEFINED; }
|
||||
JSValue js_array_set_y(JSContext *js, JSValue self, JSValue val) { JS_SetPropertyUint32(js,self,1,val); return JS_NULL; }
|
||||
|
||||
JSValue js_array_get_xy(JSContext *js, JSValue self)
|
||||
{
|
||||
@@ -832,7 +832,7 @@ JSValue js_array_set_xy(JSContext *js, JSValue self, JSValue v)
|
||||
{
|
||||
JS_SetPropertyUint32(js,self,0,JS_GetPropertyUint32(js,v,0));
|
||||
JS_SetPropertyUint32(js,self,1,JS_GetPropertyUint32(js,v,1));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Single-value accessors
|
||||
@@ -841,25 +841,25 @@ JSValue js_array_get_r(JSContext *js, JSValue self)
|
||||
{ return JS_GetPropertyUint32(js, self, 0); }
|
||||
|
||||
JSValue js_array_set_r(JSContext *js, JSValue self, JSValue val)
|
||||
{ JS_SetPropertyUint32(js, self, 0, val); return JS_UNDEFINED; }
|
||||
{ JS_SetPropertyUint32(js, self, 0, val); return JS_NULL; }
|
||||
|
||||
JSValue js_array_get_g(JSContext *js, JSValue self)
|
||||
{ return JS_GetPropertyUint32(js, self, 1); }
|
||||
|
||||
JSValue js_array_set_g(JSContext *js, JSValue self, JSValue val)
|
||||
{ JS_SetPropertyUint32(js, self, 1, val); return JS_UNDEFINED; }
|
||||
{ JS_SetPropertyUint32(js, self, 1, val); return JS_NULL; }
|
||||
|
||||
JSValue js_array_get_b(JSContext *js, JSValue self)
|
||||
{ return JS_GetPropertyUint32(js, self, 2); }
|
||||
|
||||
JSValue js_array_set_b(JSContext *js, JSValue self, JSValue val)
|
||||
{ JS_SetPropertyUint32(js, self, 2, val); return JS_UNDEFINED; }
|
||||
{ JS_SetPropertyUint32(js, self, 2, val); return JS_NULL; }
|
||||
|
||||
JSValue js_array_get_a(JSContext *js, JSValue self)
|
||||
{ return JS_GetPropertyUint32(js, self, 3); }
|
||||
|
||||
JSValue js_array_set_a(JSContext *js, JSValue self, JSValue val)
|
||||
{ JS_SetPropertyUint32(js, self, 3, val); return JS_UNDEFINED; }
|
||||
{ JS_SetPropertyUint32(js, self, 3, val); return JS_NULL; }
|
||||
|
||||
// Multi-value accessors
|
||||
|
||||
@@ -877,7 +877,7 @@ JSValue js_array_set_rgb(JSContext *js, JSValue self, JSValue val)
|
||||
JS_SetPropertyUint32(js, self, 0, JS_GetPropertyUint32(js, val, 0));
|
||||
JS_SetPropertyUint32(js, self, 1, JS_GetPropertyUint32(js, val, 1));
|
||||
JS_SetPropertyUint32(js, self, 2, JS_GetPropertyUint32(js, val, 2));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_array_get_rgba(JSContext *js, JSValue self)
|
||||
@@ -896,7 +896,7 @@ JSValue js_array_set_rgba(JSContext *js, JSValue self, JSValue val)
|
||||
JS_SetPropertyUint32(js, self, 1, JS_GetPropertyUint32(js, val, 1));
|
||||
JS_SetPropertyUint32(js, self, 2, JS_GetPropertyUint32(js, val, 2));
|
||||
JS_SetPropertyUint32(js, self, 3, JS_GetPropertyUint32(js, val, 3));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_array_funcs[] = {
|
||||
@@ -1218,7 +1218,7 @@ JSValue make_color_buffer(JSContext *js, colorf c, int verts)
|
||||
}
|
||||
|
||||
JSC_CCALL(os_make_line_prim,
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
/*
|
||||
JSValue prim = JS_NewObject(js);
|
||||
HMM_Vec2 *v = js2cpvec2arr(js,argv[0]);
|
||||
@@ -1262,7 +1262,7 @@ JSC_CCALL(os_make_line_prim,
|
||||
)
|
||||
|
||||
static void render_frame(plm_t *mpeg, plm_frame_t *frame, datastream *ds) {
|
||||
if (JS_IsUndefined(ds->callback)) return;
|
||||
if (JS_IsNull(ds->callback)) return;
|
||||
uint8_t *rgb = malloc(frame->height*frame->width*4);
|
||||
memset(rgb,255,frame->height*frame->width*4);
|
||||
plm_frame_to_rgba(frame, rgb, frame->width*4);
|
||||
@@ -1278,7 +1278,7 @@ static void render_frame(plm_t *mpeg, plm_frame_t *frame, datastream *ds) {
|
||||
JSValue s[1];
|
||||
s[0] = surfData;
|
||||
JSValue cb = JS_DupValue(ds->js,ds->callback);
|
||||
JSValue ret = JS_Call(ds->js, cb, JS_UNDEFINED, 1, s);
|
||||
JSValue ret = JS_Call(ds->js, cb, JS_NULL, 1, s);
|
||||
JS_FreeValue(ds->js,cb);
|
||||
free(rgb);
|
||||
uncaught_exception(ds->js,ret);
|
||||
@@ -1290,7 +1290,7 @@ JSC_CCALL(os_make_video,
|
||||
datastream *ds = ds_openvideo(data, len);
|
||||
if (!ds) return JS_ThrowReferenceError(js, "Video file was not valid.");
|
||||
ds->js = js;
|
||||
ds->callback = JS_UNDEFINED;
|
||||
ds->callback = JS_NULL;
|
||||
plm_set_video_decode_callback(ds->plm, render_frame, ds);
|
||||
return datastream2js(js,ds);
|
||||
)
|
||||
@@ -1314,7 +1314,7 @@ JSC_CCALL(os_rectpack,
|
||||
int packed = stbrp_pack_rects(ctx, rects, num);
|
||||
|
||||
if (!packed) {
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
ret = JS_NewArray(js);
|
||||
@@ -1339,7 +1339,7 @@ JSC_CCALL(os_insertion_sort,
|
||||
while (j >= 0) {
|
||||
JSValue arr_j = JS_GetPropertyUint32(js, arr, j);
|
||||
|
||||
JSValue ret = JS_Call(js, cmp, JS_UNDEFINED, 2, (JSValue[]){ arr_j, key });
|
||||
JSValue ret = JS_Call(js, cmp, JS_NULL, 2, (JSValue[]){ arr_j, key });
|
||||
if (JS_IsException(ret)) {
|
||||
JS_FreeValue(js,arr_j);
|
||||
JS_FreeValue(js,key);
|
||||
@@ -1367,13 +1367,13 @@ JSC_CCALL(os_power_state,
|
||||
SDL_PowerState state = SDL_GetPowerInfo(NULL, NULL);
|
||||
switch(state) {
|
||||
case SDL_POWERSTATE_ERROR: return JS_ThrowTypeError(js, "Error determining power status");
|
||||
case SDL_POWERSTATE_UNKNOWN: return JS_UNDEFINED;
|
||||
case SDL_POWERSTATE_UNKNOWN: return JS_NULL;
|
||||
case SDL_POWERSTATE_ON_BATTERY: return JS_NewString(js, "on battery");
|
||||
case SDL_POWERSTATE_NO_BATTERY: return JS_NewString(js, "no battery");
|
||||
case SDL_POWERSTATE_CHARGING: return JS_NewString(js, "charging");
|
||||
case SDL_POWERSTATE_CHARGED: return JS_NewString(js, "charged");
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(os_cull_sprites,
|
||||
|
||||
@@ -20,7 +20,7 @@ cell_rt *js2actor(JSContext *js, JSValue v)
|
||||
cell_rt *crt = JS_GetContextOpaque(js);
|
||||
JSValue actor_data = JS_GetProperty(js, v, crt->actor_sym);
|
||||
|
||||
if (JS_IsUndefined(actor_data)) {
|
||||
if (JS_IsNull(actor_data)) {
|
||||
JS_FreeValue(js, actor_data);
|
||||
return NULL;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ cell_rt *js2actor(JSContext *js, JSValue v)
|
||||
JSValue id_val = JS_GetPropertyStr(js, actor_data, "id");
|
||||
JS_FreeValue(js, actor_data);
|
||||
|
||||
if (JS_IsUndefined(id_val)) {
|
||||
if (JS_IsNull(id_val)) {
|
||||
JS_FreeValue(js, id_val);
|
||||
return NULL;
|
||||
}
|
||||
@@ -78,7 +78,7 @@ JSC_CCALL(os_createactor,
|
||||
if (rt->disrupt)
|
||||
return JS_ThrowInternalError(js, "Can't start a new actor while disrupting.");
|
||||
|
||||
void *startup = value2wota(js, argv[0], JS_UNDEFINED, NULL);
|
||||
void *startup = value2wota(js, argv[0], JS_NULL, NULL);
|
||||
create_actor(startup);
|
||||
)
|
||||
|
||||
@@ -98,7 +98,7 @@ JSC_CCALL(os_mailbox_push,
|
||||
JS_FreeCString(js,id);
|
||||
|
||||
/* JSValue sys = JS_GetPropertyStr(js, argv[1], "__SYSTEM__");
|
||||
if (!JS_IsUndefined(sys)) {
|
||||
if (!JS_IsNull(sys)) {
|
||||
const char *k = JS_ToCString(js,sys);
|
||||
int stop = 0;
|
||||
if (strcmp(k, "stop") == 0) {
|
||||
@@ -108,7 +108,7 @@ JSC_CCALL(os_mailbox_push,
|
||||
JS_FreeValue(js,sys);
|
||||
JS_FreeCString(js,k);
|
||||
|
||||
if (stop) return JS_UNDEFINED;
|
||||
if (stop) return JS_NULL;
|
||||
}
|
||||
*/
|
||||
size_t size;
|
||||
|
||||
@@ -60,7 +60,7 @@ static JSValue js_blob_constructor(JSContext *ctx, JSValueConst new_target,
|
||||
|
||||
size_t bits_written = 0;
|
||||
while (bits_written < length_bits) {
|
||||
JSValue randval = JS_Call(ctx, argv[1], JS_UNDEFINED, 0, NULL);
|
||||
JSValue randval = JS_Call(ctx, argv[1], JS_NULL, 0, NULL);
|
||||
if (JS_IsException(randval)) {
|
||||
blob_destroy(bd);
|
||||
return JS_EXCEPTION;
|
||||
@@ -151,7 +151,7 @@ static JSValue js_blob_write_bit(JSContext *ctx, JSValueConst this_val,
|
||||
if (blob_write_bit(bd, bit_val) < 0) {
|
||||
return JS_ThrowTypeError(ctx, "write_bit: cannot write (maybe stone or OOM)");
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// blob.write_blob(second_blob)
|
||||
@@ -173,7 +173,7 @@ static JSValue js_blob_write_blob(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_ThrowTypeError(ctx, "write_blob: cannot write to stone blob or OOM");
|
||||
}
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// blob.write_dec64(number)
|
||||
@@ -194,7 +194,7 @@ static JSValue js_blob_write_number(JSContext *ctx, JSValueConst this_val,
|
||||
if (blob_write_dec64(bd, d) < 0)
|
||||
return JS_ThrowTypeError(ctx, "write_dec64: cannot write to stone blob or OOM");
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// blob.write_fit(value, len)
|
||||
@@ -217,7 +217,7 @@ static JSValue js_blob_write_fit(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_ThrowTypeError(ctx, "write_fit: value doesn't fit in specified bits, stone blob, or OOM");
|
||||
}
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// blob.write_kim(fit)
|
||||
@@ -239,7 +239,7 @@ static JSValue js_blob_write_text(JSContext *ctx, JSValueConst this_val,
|
||||
}
|
||||
|
||||
JS_FreeCString(ctx,str);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// blob.write_pad(block_size)
|
||||
@@ -258,7 +258,7 @@ static JSValue js_blob_write_pad(JSContext *ctx, JSValueConst this_val,
|
||||
if (blob_write_pad(bd, block_size) < 0)
|
||||
return JS_ThrowTypeError(ctx, "write_pad: cannot write (stone blob, OOM, or invalid block size)");
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// blob.read_logical(from)
|
||||
@@ -439,7 +439,7 @@ static JSValue js_blob_stone(JSContext *ctx, JSValueConst this_val,
|
||||
if (!bd->is_stone) {
|
||||
blob_make_stone(bd);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_blob_stonep(JSContext *ctx, JSValueConst this_val,
|
||||
|
||||
@@ -73,7 +73,7 @@ JSValue js_dmon_watch(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
return JS_ThrowReferenceError(js, "Already watching a directory.");
|
||||
|
||||
watched = dmon_watch(".", watch_cb, DMON_WATCHFLAGS_RECURSIVE, NULL);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_dmon_unwatch(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
@@ -83,7 +83,7 @@ JSValue js_dmon_unwatch(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
|
||||
dmon_unwatch(watched);
|
||||
watched.id = 0;
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_dmon_poll(JSContext *js, JSValueConst this_val, int argc, JSValueConst *argv) {
|
||||
@@ -110,9 +110,9 @@ JSValue js_dmon_poll(JSContext *js, JSValueConst this_val, int argc, JSValueCons
|
||||
JS_SetPropertyStr(js, jsevent, "root", JS_NewString(js, event.rootdir));
|
||||
JS_SetPropertyStr(js, jsevent, "file", JS_NewString(js, event.filepath));
|
||||
JS_SetPropertyStr(js, jsevent, "old", JS_NewString(js, event.oldfilepath));
|
||||
JS_Call(js, argv[0], JS_UNDEFINED, 1, &jsevent);
|
||||
JS_Call(js, argv[0], JS_NULL, 1, &jsevent);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_dmon_funcs[] = {
|
||||
|
||||
@@ -34,13 +34,13 @@ static void js_enet_peer_finalizer(JSRuntime *rt, JSValue val)
|
||||
static JSValue js_enet_initialize(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
if (enet_initialize() != 0) return JS_ThrowInternalError(ctx, "Error initializing ENet");
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_deinitialize(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
enet_deinitialize();
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_host_create(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
@@ -163,12 +163,12 @@ static JSValue js_enet_host_service(JSContext *ctx, JSValueConst this_val, int a
|
||||
break;
|
||||
}
|
||||
|
||||
uncaught_exception(ctx, JS_Call(ctx, callback, JS_UNDEFINED, 1, &event_obj));
|
||||
uncaught_exception(ctx, JS_Call(ctx, callback, JS_NULL, 1, &event_obj));
|
||||
JS_FreeValue(ctx, event_obj);
|
||||
}
|
||||
|
||||
JS_FreeValue(ctx, callback);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
/* Host connect: client -> connect to server */
|
||||
@@ -201,7 +201,7 @@ static JSValue js_enet_host_flush(JSContext *ctx, JSValueConst this_val, int arg
|
||||
ENetHost *host = JS_GetOpaque(this_val, enet_host_id);
|
||||
if (!host) return JS_EXCEPTION;
|
||||
enet_host_flush(host);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
/* Broadcast a string or ArrayBuffer */
|
||||
@@ -231,7 +231,7 @@ static JSValue js_enet_host_broadcast(JSContext *ctx, JSValueConst this_val, int
|
||||
if (!packet) return JS_ThrowInternalError(ctx, "Failed to create ENet packet");
|
||||
|
||||
enet_host_broadcast(host, 0, packet);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_host_get_port(JSContext *js, JSValueConst self, int argc, JSValueConst *argv)
|
||||
@@ -264,7 +264,7 @@ static JSValue js_enet_peer_disconnect(JSContext *ctx, JSValueConst this_val, in
|
||||
ENetPeer *peer = JS_GetOpaque(this_val, enet_peer_class_id);
|
||||
if (!peer) return JS_EXCEPTION;
|
||||
enet_peer_disconnect(peer, 0);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
/* Peer send must only accept string or ArrayBuffer */
|
||||
@@ -294,7 +294,7 @@ static JSValue js_enet_peer_send(JSContext *ctx, JSValueConst this_val, int argc
|
||||
if (!packet) return JS_ThrowInternalError(ctx, "Failed to create ENet packet");
|
||||
|
||||
if (enet_peer_send(peer, 0, packet) < 0) return JS_ThrowInternalError(ctx, "Unable to send packet");
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_peer_disconnect_now(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
@@ -302,7 +302,7 @@ static JSValue js_enet_peer_disconnect_now(JSContext *ctx, JSValueConst this_val
|
||||
ENetPeer *peer = JS_GetOpaque(this_val, enet_peer_class_id);
|
||||
if (!peer) return JS_EXCEPTION;
|
||||
enet_peer_disconnect_now(peer, 0);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_peer_disconnect_later(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
@@ -310,7 +310,7 @@ static JSValue js_enet_peer_disconnect_later(JSContext *ctx, JSValueConst this_v
|
||||
ENetPeer *peer = JS_GetOpaque(this_val, enet_peer_class_id);
|
||||
if (!peer) return JS_EXCEPTION;
|
||||
enet_peer_disconnect_later(peer, 0);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_peer_reset(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
@@ -318,7 +318,7 @@ static JSValue js_enet_peer_reset(JSContext *ctx, JSValueConst this_val, int arg
|
||||
ENetPeer *peer = JS_GetOpaque(this_val, enet_peer_class_id);
|
||||
if (!peer) return JS_EXCEPTION;
|
||||
enet_peer_reset(peer);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_peer_ping(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
@@ -326,7 +326,7 @@ static JSValue js_enet_peer_ping(JSContext *ctx, JSValueConst this_val, int argc
|
||||
ENetPeer *peer = JS_GetOpaque(this_val, enet_peer_class_id);
|
||||
if (!peer) return JS_EXCEPTION;
|
||||
enet_peer_ping(peer);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_peer_throttle_configure(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
@@ -339,7 +339,7 @@ static JSValue js_enet_peer_throttle_configure(JSContext *ctx, JSValueConst this
|
||||
return JS_ThrowTypeError(ctx, "Expected 3 int arguments: interval, acceleration, deceleration");
|
||||
|
||||
enet_peer_throttle_configure(peer, interval, acceleration, deceleration);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_enet_peer_timeout(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
@@ -352,7 +352,7 @@ static JSValue js_enet_peer_timeout(JSContext *ctx, JSValueConst this_val, int a
|
||||
return JS_ThrowTypeError(ctx, "Expected 3 integer arguments: timeout_limit, timeout_min, timeout_max");
|
||||
|
||||
enet_peer_timeout(peer, timeout_limit, timeout_min, timeout_max);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
/* Class definitions */
|
||||
@@ -372,7 +372,7 @@ JSValue js_enet_resolve_hostname(JSContext *js, JSValue self, int argc, JSValue
|
||||
// TODO: implement
|
||||
const char *hostname = JS_ToCString(js, argv[0]);
|
||||
JS_FreeCString(js, hostname);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
/* Function lists */
|
||||
|
||||
@@ -147,7 +147,7 @@ JSC_CCALL(fd_fsync,
|
||||
if (fsync(fd) != 0)
|
||||
return JS_ThrowReferenceError(js, "fsync failed: %s", strerror(errno));
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(fd_close,
|
||||
@@ -157,7 +157,7 @@ JSC_CCALL(fd_close,
|
||||
if (close(fd) != 0)
|
||||
return JS_ThrowReferenceError(js, "close failed: %s", strerror(errno));
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(fd_fstat,
|
||||
|
||||
@@ -445,10 +445,10 @@ static BufferCheckResult get_or_extend_buffer(
|
||||
int copy,
|
||||
int index
|
||||
) {
|
||||
BufferCheckResult res = { JS_UNDEFINED, NULL, 0, 0 };
|
||||
if (!JS_IsUndefined(old_mesh)) {
|
||||
BufferCheckResult res = { JS_NULL, NULL, 0, 0 };
|
||||
if (!JS_IsNull(old_mesh)) {
|
||||
JSValue old_buf = JS_GetPropertyStr(js, old_mesh, prop);
|
||||
if (!JS_IsUndefined(old_buf)) {
|
||||
if (!JS_IsNull(old_buf)) {
|
||||
size_t old_size;
|
||||
void *data = get_gpu_buffer(js, old_buf, NULL, &old_size);
|
||||
if (data && old_size >= needed_size) {
|
||||
@@ -520,7 +520,7 @@ JSC_CCALL(gpu_make_sprite_mesh,
|
||||
}
|
||||
|
||||
// Check old mesh
|
||||
JSValue old_mesh = JS_UNDEFINED;
|
||||
JSValue old_mesh = JS_NULL;
|
||||
if (argc > 1)
|
||||
old_mesh = argv[1];
|
||||
|
||||
@@ -577,9 +577,9 @@ JSC_CCALL(gpu_make_sprite_mesh,
|
||||
free(colordata);
|
||||
|
||||
// Free old buffer values if they were fetched
|
||||
if (!JS_IsUndefined(pos_chk.val)) JS_FreeValue(js, pos_chk.val);
|
||||
if (!JS_IsUndefined(uv_chk.val)) JS_FreeValue(js, uv_chk.val);
|
||||
if (!JS_IsUndefined(color_chk.val)) JS_FreeValue(js, color_chk.val);
|
||||
if (!JS_IsNull(pos_chk.val)) JS_FreeValue(js, pos_chk.val);
|
||||
if (!JS_IsNull(uv_chk.val)) JS_FreeValue(js, uv_chk.val);
|
||||
if (!JS_IsNull(color_chk.val)) JS_FreeValue(js, color_chk.val);
|
||||
|
||||
return ret;
|
||||
)
|
||||
@@ -685,11 +685,11 @@ JSC_CCALL(gpu_make_sprite_queue,
|
||||
|
||||
rect uv;
|
||||
rect uv_px;
|
||||
JSValue cur_img = JS_UNDEFINED;
|
||||
JSValue cur_img = JS_NULL;
|
||||
|
||||
for (size_t i = 0; i < quads; i++) {
|
||||
sprite *s = &sprites[i];
|
||||
if (JS_IsUndefined(cur_img) || !JS_StrictEq(js, s->image, cur_img)) {
|
||||
if (JS_IsNull(cur_img) || !JS_StrictEq(js, s->image, cur_img)) {
|
||||
cur_img = s->image;
|
||||
JS_GETATOM(js, uv, cur_img, rect, rect)
|
||||
JS_GETATOM(js, uv_px, cur_img, rect_px, rect)
|
||||
@@ -732,7 +732,7 @@ JSC_CCALL(gpu_make_sprite_queue,
|
||||
int first_index = 0;
|
||||
int count = 0;
|
||||
int n = 0;
|
||||
JSValue img = JS_UNDEFINED;
|
||||
JSValue img = JS_NULL;
|
||||
|
||||
for (int i = 0; i < quads; i++) {
|
||||
if (!JS_SameValue(js, sprites[i].image, img)) {
|
||||
@@ -832,7 +832,7 @@ JSC_CCALL(geometry_tilemap_to_data,
|
||||
int col_len = JS_ArrayLength(js, col);
|
||||
for (int y = 0; y < col_len; y++) {
|
||||
JSValue tile = JS_GetPropertyUint32(js, col, y);
|
||||
if (!JS_IsUndefined(tile) && !JS_IsNull(tile)) {
|
||||
if (!JS_IsNull(tile) && !JS_IsNull(tile)) {
|
||||
tile_count++;
|
||||
}
|
||||
JS_FreeValue(js, tile);
|
||||
@@ -865,7 +865,7 @@ JSC_CCALL(geometry_tilemap_to_data,
|
||||
int col_len = JS_ArrayLength(js, col);
|
||||
for (int y = 0; y < col_len; y++) {
|
||||
JSValue tile = JS_GetPropertyUint32(js, col, y);
|
||||
if (!JS_IsUndefined(tile) && !JS_IsNull(tile)) {
|
||||
if (!JS_IsNull(tile) && !JS_IsNull(tile)) {
|
||||
// Calculate world position
|
||||
float world_x = (x + offset_x) * size_x;
|
||||
float world_y = (y + offset_y) * size_y;
|
||||
@@ -895,7 +895,7 @@ JSC_CCALL(geometry_tilemap_to_data,
|
||||
SDL_FColor default_color = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
if (JS_IsObject(tile)) {
|
||||
JSValue color_val = JS_GetPropertyStr(js, tile, "color");
|
||||
if (!JS_IsUndefined(color_val)) {
|
||||
if (!JS_IsNull(color_val)) {
|
||||
HMM_Vec4 color = js2color(js, color_val);
|
||||
default_color.r = color.r;
|
||||
default_color.g = color.g;
|
||||
|
||||
@@ -106,38 +106,38 @@ JSC_CCALL(imgui_window,
|
||||
const char *str = JS_ToCString(js,argv[0]);
|
||||
bool active = true;
|
||||
ImGui::Begin(str, &active);
|
||||
JS_Call(js, argv[1], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[1], JS_NULL, 0, NULL);
|
||||
ImGui::End();
|
||||
JS_FreeCString(js,str);
|
||||
return JS_NewBool(js,active);
|
||||
)
|
||||
JSC_SCALL(imgui_menu,
|
||||
if (ImGui::BeginMenu(str)) {
|
||||
JS_Call(js, argv[1], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[1], JS_NULL, 0, NULL);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_menubar,
|
||||
if (ImGui::BeginMenuBar()) {
|
||||
JS_Call(js, argv[0], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[0], JS_NULL, 0, NULL);
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_mainmenubar,
|
||||
if (ImGui::BeginMainMenuBar()) {
|
||||
JS_Call(js, argv[0], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[0], JS_NULL, 0, NULL);
|
||||
ImGui::EndMainMenuBar();
|
||||
}
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_menuitem,
|
||||
const char *name = JS_ToCString(js,argv[0]);
|
||||
const char *keyfn = JS_IsUndefined(argv[1]) ? NULL : JS_ToCString(js,argv[1]);
|
||||
bool on = JS_IsUndefined(argv[3]) ? false : JS_ToBool(js,argv[3]);
|
||||
const char *keyfn = JS_IsNull(argv[1]) ? NULL : JS_ToCString(js,argv[1]);
|
||||
bool on = JS_IsNull(argv[3]) ? false : JS_ToBool(js,argv[3]);
|
||||
if (ImGui::MenuItem(JS_ToBool(js,argv[0]) ? name : "##empty" ,keyfn, &on))
|
||||
JS_Call(js, argv[2], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[2], JS_NULL, 0, NULL);
|
||||
|
||||
if (!JS_IsNull(argv[0])) JS_FreeCString(js,name);
|
||||
if (keyfn) JS_FreeCString(js,keyfn);
|
||||
@@ -147,7 +147,7 @@ JSC_CCALL(imgui_menuitem,
|
||||
|
||||
JSC_SCALL(imgui_plot,
|
||||
if (ImPlot::BeginPlot(str)) {
|
||||
JS_Call(js, argv[1], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[1], JS_NULL, 0, NULL);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
)
|
||||
@@ -173,7 +173,7 @@ void fill_plotdata(JSContext *js, JSValue v, JSValue last)
|
||||
else {
|
||||
// Fill it with the x axis being the array index
|
||||
for (int i = 0; i < JS_ArrayLength(js, v); i++) {
|
||||
if (JS_IsUndefined(js_getpropidx(v,i))) continue;
|
||||
if (JS_IsNull(js_getpropidx(v,i))) continue;
|
||||
ImVec2 c;
|
||||
c.x = i;
|
||||
c.y = js2number(js, js_getpropidx(v,i));
|
||||
@@ -181,7 +181,7 @@ void fill_plotdata(JSContext *js, JSValue v, JSValue last)
|
||||
}
|
||||
}
|
||||
|
||||
if (!JS_IsUndefined(last)) {
|
||||
if (!JS_IsNull(last)) {
|
||||
int frame = js2number(js, last);
|
||||
ImVec2 c = js2vec2(js,last);
|
||||
c.y = arrlast(plotdata).y;
|
||||
@@ -195,7 +195,7 @@ PLOT_FN(stairplot, PlotStairs,,ImPlotStairsFlags_Shaded)
|
||||
PLOT_FN(digitalplot, PlotDigital,,0)
|
||||
|
||||
JSC_SCALL(imgui_barplot,
|
||||
fill_plotdata(js, argv[1], JS_UNDEFINED);
|
||||
fill_plotdata(js, argv[1], JS_NULL);
|
||||
ImPlot::PlotBars(str, &plotdata[0].x, &plotdata[0].y, JS_ArrayLength(js, argv[1]), js2number(js, argv[2]), 0, 0, sizeof(ImVec2));
|
||||
)
|
||||
|
||||
@@ -243,7 +243,7 @@ JSC_CCALL(imgui_fitaxis,
|
||||
|
||||
JSC_SSCALL(imgui_textinput,
|
||||
char buffer[512];
|
||||
if (JS_IsUndefined(argv[1]))
|
||||
if (JS_IsNull(argv[1]))
|
||||
buffer[0] = 0;
|
||||
else
|
||||
strncpy(buffer, str2, sizeof(buffer)-1);
|
||||
@@ -257,7 +257,7 @@ JSC_SSCALL(imgui_textinput,
|
||||
|
||||
JSC_SSCALL(imgui_textbox,
|
||||
char buffer[512];
|
||||
if (JS_IsUndefined(argv[1]))
|
||||
if (JS_IsNull(argv[1]))
|
||||
buffer[0] = 0;
|
||||
else
|
||||
strncpy(buffer, str2, sizeof(buffer)-1);
|
||||
@@ -273,12 +273,12 @@ JSC_SCALL(imgui_text, ImGui::Text("%s", str) )
|
||||
|
||||
JSC_SCALL(imgui_button,
|
||||
if (ImGui::Button(str))
|
||||
JS_Call(js, argv[1], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[1], JS_NULL, 0, NULL);
|
||||
)
|
||||
|
||||
JSC_SCALL(imgui_slider,
|
||||
/* float low = JS_IsUndefined(argv[2]) ? 0.0 : js2number(js, argv[2]);
|
||||
float high = JS_IsUndefined(argv[3]) ? 1.0 : js2number(js, argv[3]);
|
||||
/* float low = JS_IsNull(argv[2]) ? 0.0 : js2number(js, argv[2]);
|
||||
float high = JS_IsNull(argv[3]) ? 1.0 : js2number(js, argv[3]);
|
||||
|
||||
if (JS_IsArray(js, argv[1])) {
|
||||
int n = JS_ArrayLength(js, argv[1]);
|
||||
@@ -306,8 +306,8 @@ JSC_SCALL(imgui_slider,
|
||||
)
|
||||
|
||||
JSC_SCALL(imgui_intslider,
|
||||
int low = JS_IsUndefined(argv[2]) ? 0.0 : js2number(js, argv[2]);
|
||||
int high = JS_IsUndefined(argv[3]) ? 1.0 : js2number(js, argv[3]);
|
||||
int low = JS_IsNull(argv[2]) ? 0.0 : js2number(js, argv[2]);
|
||||
int high = JS_IsNull(argv[3]) ? 1.0 : js2number(js, argv[3]);
|
||||
|
||||
JSValue arr = JS_NewTypedArray(js, 1, &argv[1], JS_TYPED_ARRAY_INT32);
|
||||
size_t len;
|
||||
@@ -353,7 +353,7 @@ JSC_CCALL(imgui_image,
|
||||
JSC_SCALL(imgui_imagebutton,
|
||||
SDL_GPUTexture *tex = js2SDL_GPUTexture(js,argv[1]);
|
||||
if (ImGui::ImageButton(str, (ImTextureID)tex, ImVec2(100, 100)))
|
||||
JS_Call(js, argv[2], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[2], JS_NULL, 0, NULL);
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_sameline, ImGui::SameLine(js2number(js, argv[0])) )
|
||||
@@ -364,21 +364,21 @@ JSC_SCALL(imgui_radio, ret = JS_NewBool(js,ImGui::RadioButton(str, JS_ToBool(js,
|
||||
|
||||
JSC_SCALL(imgui_tree,
|
||||
if (ImGui::TreeNode(str)) {
|
||||
JS_Call(js, argv[1],JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1],JS_NULL, 0,NULL);
|
||||
ImGui::TreePop();
|
||||
}
|
||||
)
|
||||
|
||||
JSC_SCALL(imgui_tabbar,
|
||||
if (ImGui::BeginTabBar(str)) {
|
||||
JS_Call(js, argv[1],JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1],JS_NULL, 0,NULL);
|
||||
ImGui::EndTabBar();
|
||||
}
|
||||
)
|
||||
|
||||
JSC_SCALL(imgui_tab,
|
||||
if (ImGui::BeginTabItem(str)) {
|
||||
JS_Call(js, argv[1],JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1],JS_NULL, 0,NULL);
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
)
|
||||
@@ -407,7 +407,7 @@ JSC_SCALL(imgui_open_popup,
|
||||
|
||||
JSC_SCALL(imgui_popup,
|
||||
if (ImGui::BeginPopup(str)) {
|
||||
JS_Call(js, argv[1],JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1],JS_NULL, 0,NULL);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
)
|
||||
@@ -418,14 +418,14 @@ JSC_CCALL(imgui_close_popup,
|
||||
|
||||
JSC_SCALL(imgui_modal,
|
||||
if (ImGui::BeginPopupModal(str)) {
|
||||
JS_Call(js, argv[1],JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1],JS_NULL, 0,NULL);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
)
|
||||
|
||||
JSC_SCALL(imgui_context,
|
||||
if (ImGui::BeginPopupContextItem(str)) {
|
||||
JS_Call(js, argv[1],JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1],JS_NULL, 0,NULL);
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
)
|
||||
@@ -433,11 +433,11 @@ JSC_SCALL(imgui_context,
|
||||
JSC_SCALL(imgui_table,
|
||||
int flags = ImGuiTableFlags_Resizable | ImGuiTableFlags_SizingFixedFit | ImGuiTableFlags_SizingStretchProp;
|
||||
bool sort = false;
|
||||
if (!JS_IsUndefined(argv[3])) sort = true;
|
||||
if (!JS_IsNull(argv[3])) sort = true;
|
||||
|
||||
if (sort) flags |= ImGuiTableFlags_Sortable;
|
||||
if (ImGui::BeginTable(str, js2number(js, argv[1]), flags)) {
|
||||
JS_Call(js, argv[2], JS_UNDEFINED, 0, NULL);
|
||||
JS_Call(js, argv[2], JS_NULL, 0, NULL);
|
||||
|
||||
if (sort) {
|
||||
ImGuiTableSortSpecs* sort_specs = ImGui::TableGetSortSpecs();
|
||||
@@ -448,7 +448,7 @@ JSC_SCALL(imgui_table,
|
||||
JSValue send[2];
|
||||
send[0] = JS_NewInt32(js,spec->ColumnIndex);
|
||||
send[1] = JS_NewBool(js,spec->SortDirection == ImGuiSortDirection_Ascending);
|
||||
JS_Call(js, argv[3], JS_UNDEFINED, 2, send);
|
||||
JS_Call(js, argv[3], JS_NULL, 2, send);
|
||||
JS_FreeValue(js, send[0]);
|
||||
JS_FreeValue(js, send[1]);
|
||||
}
|
||||
@@ -470,7 +470,7 @@ JSC_SCALL(imgui_dnd,
|
||||
if (ImGui::BeginDragDropSource(ImGuiDragDropFlags_None)) {
|
||||
double n = js2number(js, argv[1]);
|
||||
ImGui::SetDragDropPayload(str, &n, sizeof(n));
|
||||
// JS_Call(js, argv[2], JS_UNDEFINED, 2, send);
|
||||
// JS_Call(js, argv[2], JS_NULL, 2, send);
|
||||
ImGui::EndDragDropSource();
|
||||
}
|
||||
)
|
||||
@@ -479,7 +479,7 @@ JSC_SCALL(imgui_dndtarget,
|
||||
if (ImGui::BeginDragDropTarget()) {
|
||||
if (const ImGuiPayload *payload = ImGui::AcceptDragDropPayload(str)) {
|
||||
JSValue n = JS_NewFloat64(js,*(double*)payload->Data);
|
||||
JS_Call(js, argv[1], JS_UNDEFINED, 1, &n);
|
||||
JS_Call(js, argv[1], JS_NULL, 1, &n);
|
||||
}
|
||||
ImGui::EndDragDropTarget();
|
||||
}
|
||||
@@ -500,7 +500,7 @@ JSC_SCALL(imgui_color,
|
||||
|
||||
JSC_CCALL(imgui_startnode,
|
||||
ImNodes::BeginNodeEditor();
|
||||
JS_Call(js, argv[0], JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[0], JS_NULL, 0,NULL);
|
||||
ImNodes::EndNodeEditor();
|
||||
int start_attr;
|
||||
int end_attr;
|
||||
@@ -509,7 +509,7 @@ JSC_CCALL(imgui_startnode,
|
||||
JSValue ab[2];
|
||||
ab[0] = JS_NewInt32(js,start_attr);
|
||||
ab[1] = JS_NewInt32(js,end_attr);
|
||||
JS_Call(js,argv[1], JS_UNDEFINED, 2, ab);
|
||||
JS_Call(js,argv[1], JS_NULL, 2, ab);
|
||||
|
||||
for (int i = 0; i < 2; i++) JS_FreeValue(js, ab[i]);
|
||||
}
|
||||
@@ -518,7 +518,7 @@ JSC_CCALL(imgui_startnode,
|
||||
if (ImNodes::IsNodeHovered(&node_id))
|
||||
{
|
||||
JSValue a = JS_NewInt32(js,node_id);
|
||||
JS_Call(js, argv[2], JS_UNDEFINED, 1,&a);
|
||||
JS_Call(js, argv[2], JS_NULL, 1,&a);
|
||||
JS_FreeValue(js,a);
|
||||
}
|
||||
|
||||
@@ -526,26 +526,26 @@ JSC_CCALL(imgui_startnode,
|
||||
if (ImNodes::IsLinkHovered(&link_id))
|
||||
{
|
||||
JSValue a = JS_NewInt32(js,link_id);
|
||||
JS_Call(js, argv[3], JS_UNDEFINED, 1,&a);
|
||||
JS_Call(js, argv[3], JS_NULL, 1,&a);
|
||||
JS_FreeValue(js,a);
|
||||
}
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_node,
|
||||
ImNodes::BeginNode(js2number(js, argv[0]));
|
||||
JS_Call(js, argv[1], JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1], JS_NULL, 0,NULL);
|
||||
ImNodes::EndNode();
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_nodein,
|
||||
ImNodes::BeginInputAttribute(js2number(js, argv[0]));
|
||||
JS_Call(js, argv[1], JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1], JS_NULL, 0,NULL);
|
||||
ImNodes::EndInputAttribute();
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_nodeout,
|
||||
ImNodes::BeginOutputAttribute(js2number(js, argv[0]));
|
||||
JS_Call(js, argv[1], JS_UNDEFINED, 0,NULL);
|
||||
JS_Call(js, argv[1], JS_NULL, 0,NULL);
|
||||
ImNodes::EndOutputAttribute();
|
||||
)
|
||||
|
||||
@@ -681,7 +681,7 @@ static JSValue axis_fmts[10];
|
||||
void jsformatter(double value, char *buff, int size, JSValue *fmt)
|
||||
{
|
||||
/* JSValue v = JS_NewFloat64(js,value);
|
||||
const char *str = JS_ToCString(js, JS_Call(js,*fmt, JS_UNDEFINED, 1, &v));
|
||||
const char *str = JS_ToCString(js, JS_Call(js,*fmt, JS_NULL, 1, &v));
|
||||
strncpy(buff,str, size);
|
||||
JS_FreeCString(js, str);*/
|
||||
}
|
||||
@@ -689,9 +689,9 @@ void jsformatter(double value, char *buff, int size, JSValue *fmt)
|
||||
JSC_CCALL(imgui_axisfmt,
|
||||
int y = num_to_yaxis(js2number(js, argv[0]));
|
||||
|
||||
if (!JS_IsUndefined(axis_fmts[y])) {
|
||||
if (!JS_IsNull(axis_fmts[y])) {
|
||||
JS_FreeValue(js, axis_fmts[y]);
|
||||
axis_fmts[y] = JS_UNDEFINED;
|
||||
axis_fmts[y] = JS_NULL;
|
||||
}
|
||||
|
||||
axis_fmts[y] = JS_DupValue(js,argv[1]);
|
||||
|
||||
@@ -159,14 +159,14 @@ JSC_SCALL(io_slurpwrite,
|
||||
JSC_CCALL(io_mount,
|
||||
const char *src = JS_ToCString(js, argv[0]);
|
||||
const char *mountpoint;
|
||||
if (JS_IsUndefined(argv[1]))
|
||||
if (JS_IsNull(argv[1]))
|
||||
mountpoint = NULL;
|
||||
else
|
||||
mountpoint = JS_ToCString(js, argv[1]);
|
||||
|
||||
int prepend = 0;
|
||||
|
||||
if (argc > 2 && !JS_IsUndefined(argv[2]))
|
||||
if (argc > 2 && !JS_IsNull(argv[2]))
|
||||
prepend = JS_ToBool(js, argv[2]);
|
||||
|
||||
if (!PHYSFS_mount(src, mountpoint, prepend))
|
||||
@@ -274,7 +274,7 @@ JSC_CCALL(io_globfs,
|
||||
data.globs = globs;
|
||||
|
||||
const char *path = NULL;
|
||||
if (!JS_IsUndefined(argv[1])) path = JS_ToCString(js,argv[1]);
|
||||
if (!JS_IsNull(argv[1])) path = JS_ToCString(js,argv[1]);
|
||||
PHYSFS_enumerate(path, globfs_cb, &data);
|
||||
|
||||
for (int i = 0; i < globs_len; i++)
|
||||
@@ -297,7 +297,7 @@ JSC_SCALL(io_enumerate,
|
||||
data.globs = NULL; /* not used here */
|
||||
data.recurse = 0;
|
||||
|
||||
if (!JS_IsUndefined(argv[1])) /* parse second arg if provided */
|
||||
if (!JS_IsNull(argv[1])) /* parse second arg if provided */
|
||||
data.recurse = JS_ToBool(js, argv[1]);
|
||||
|
||||
/* Enumerate the directory given by 'str'. */
|
||||
@@ -322,7 +322,7 @@ JSC_SCALL(io_open,
|
||||
JSC_SCALL(io_realdir,
|
||||
const char *real = PHYSFS_getRealDir(str);
|
||||
if (!real)
|
||||
ret = JS_UNDEFINED;
|
||||
ret = JS_NULL;
|
||||
else
|
||||
ret = JS_NewString(js,real);
|
||||
)
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
|
||||
#define JS_SETSIG JSContext *js, JSValue self, JSValue val
|
||||
#define JSC_CCALL(NAME, ...) static JSValue js_##NAME (JSContext *js, JSValue self, int argc, JSValue *argv) { \
|
||||
JSValue ret = JS_UNDEFINED; \
|
||||
JSValue ret = JS_NULL; \
|
||||
__VA_ARGS__ ;\
|
||||
return ret; \
|
||||
}
|
||||
|
||||
#define JSC_CCALL_EXTERN(NAME, ...) JSValue js_##NAME (JSContext *js, JSValue self, int argc, JSValue *argv) { \
|
||||
JSValue ret = JS_UNDEFINED; \
|
||||
JSValue ret = JS_NULL; \
|
||||
__VA_ARGS__ ;\
|
||||
return ret; \
|
||||
}
|
||||
@@ -25,8 +25,8 @@
|
||||
#define JSC_SSCALL(NAME, ...) JSC_CCALL(NAME, \
|
||||
const char *str = NULL; \
|
||||
const char *str2 = NULL; \
|
||||
if (!JS_IsUndefined(argv[0])) str = JS_ToCString(js,argv[0]); \
|
||||
if (!JS_IsUndefined(argv[1])) str2 = JS_ToCString(js,argv[1]); \
|
||||
if (!JS_IsNull(argv[0])) str = JS_ToCString(js,argv[0]); \
|
||||
if (!JS_IsNull(argv[1])) str2 = JS_ToCString(js,argv[1]); \
|
||||
__VA_ARGS__ ; \
|
||||
JS_FreeCString(js,str2); \
|
||||
JS_FreeCString(js,str); \
|
||||
@@ -41,21 +41,21 @@
|
||||
#define CGETSET_ADD(ID, ENTRY) MIST_CGETSET_DEF(#ENTRY, js_##ID##_get_##ENTRY, js_##ID##_set_##ENTRY)
|
||||
#define CGETSET_ADD_HID(ID, ENTRY) MIST_CGETSET_BASE(#ENTRY, js_##ID##_get_##ENTRY, js_##ID##_set_##ENTRY, JS_PROP_CONFIGURABLE)
|
||||
|
||||
#define JSC_DCALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(); return JS_UNDEFINED; }
|
||||
#define JSC_DCALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(); return JS_NULL; }
|
||||
|
||||
#define JSC_1CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0])); return JS_UNDEFINED; }
|
||||
#define JSC_2CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1])); return JS_UNDEFINED; }
|
||||
#define JSC_3CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2])); return JS_UNDEFINED; }
|
||||
#define JSC_4CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2]), js2number(js,argv[3])); return JS_UNDEFINED; }
|
||||
#define JSC_5CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2]), js2number(js,argv[3]), js2number(js,argv[4])); return JS_UNDEFINED; }
|
||||
#define JSC_6CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2]), js2number(js,argv[3]), js2number(js,argv[4]), js2number(js,argv[5])); return JS_UNDEFINED; }
|
||||
#define JSC_7CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2]), js2number(js,argv[3]), js2number(js,argv[4]), js2number(js,argv[5]), js2number(js,argv[6])); return JS_UNDEFINED; }
|
||||
#define JSC_1CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0])); return JS_NULL; }
|
||||
#define JSC_2CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1])); return JS_NULL; }
|
||||
#define JSC_3CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2])); return JS_NULL; }
|
||||
#define JSC_4CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2]), js2number(js,argv[3])); return JS_NULL; }
|
||||
#define JSC_5CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2]), js2number(js,argv[3]), js2number(js,argv[4])); return JS_NULL; }
|
||||
#define JSC_6CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2]), js2number(js,argv[3]), js2number(js,argv[4]), js2number(js,argv[5])); return JS_NULL; }
|
||||
#define JSC_7CALL(FN) JSValue js_##FN (JSContext *js, JSValue self, int argc, JSValue *argv) { FN(js2number(js,argv[0]), js2number(js,argv[1]), js2number(js,argv[2]), js2number(js,argv[3]), js2number(js,argv[4]), js2number(js,argv[5]), js2number(js,argv[6])); return JS_NULL; }
|
||||
|
||||
#define GETSETPAIR(ID, ENTRY, TYPE, FN) \
|
||||
JSValue js_##ID##_set_##ENTRY (JS_SETSIG) { \
|
||||
js2##ID (js, self)->ENTRY = js2##TYPE (js,val); \
|
||||
{FN;} \
|
||||
return JS_UNDEFINED; \
|
||||
return JS_NULL; \
|
||||
} \
|
||||
\
|
||||
JSValue js_##ID##_get_##ENTRY (JSContext *js, JSValue self) { \
|
||||
@@ -67,9 +67,9 @@ JSValue js_##ID##_get_##ENTRY (JSContext *js, JSValue self) { \
|
||||
#define JSC_GETSET_CALLBACK(ID, ENTRY) \
|
||||
JSValue js_##ID##_set_##ENTRY (JS_SETSIG) { \
|
||||
JSValue fn = js2##ID (js, self)->ENTRY; \
|
||||
if (!JS_IsUndefined(fn)) JS_FreeValue(js, fn); \
|
||||
if (!JS_IsNull(fn)) JS_FreeValue(js, fn); \
|
||||
js2##ID (js, self)->ENTRY = JS_DupValue(js, val); \
|
||||
return JS_UNDEFINED; \
|
||||
return JS_NULL; \
|
||||
}\
|
||||
JSValue js_##ID##_get_##ENTRY (JSContext *js, JSValue self) { return JS_DupValue(js, js2##ID (js, self)->ENTRY); } \
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ static int gcd(int a, int b) {
|
||||
JSC_CCALL(math_rotate,
|
||||
HMM_Vec2 vec = js2vec2(js,argv[0]);
|
||||
double angle = js2angle(js, argv[1]);
|
||||
HMM_Vec2 pivot = JS_IsUndefined(argv[2]) ? v2zero : js2vec2(js,argv[2]);
|
||||
HMM_Vec2 pivot = JS_IsNull(argv[2]) ? v2zero : js2vec2(js,argv[2]);
|
||||
vec = HMM_SubV2(vec,pivot);
|
||||
|
||||
float r = HMM_LenV2(vec);
|
||||
@@ -254,7 +254,7 @@ JSC_CCALL(math_project,
|
||||
if (!a || !b) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// We'll work up to the smaller length
|
||||
@@ -262,7 +262,7 @@ JSC_CCALL(math_project,
|
||||
if (len == 0) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Compute dot products: a·b and b·b
|
||||
@@ -299,14 +299,14 @@ JSC_CCALL(math_midpoint,
|
||||
if (!a || !b) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
size_t len = (alen < blen) ? alen : blen;
|
||||
if (len == 0) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
float *m = (float*)malloc(sizeof(float) * len);
|
||||
@@ -334,14 +334,14 @@ JSC_CCALL(math_reflect,
|
||||
if (!a || !b) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
size_t len = (alen < blen) ? alen : blen;
|
||||
if (len == 0) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Reflect vector a across normal b
|
||||
@@ -378,14 +378,14 @@ JSC_CCALL(math_direction,
|
||||
if (!a || !b) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
size_t len = (alen < blen) ? alen : blen;
|
||||
if (len == 0) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Direction vector from a to b (normalized)
|
||||
@@ -421,7 +421,7 @@ JSC_CCALL(math_angle,
|
||||
|
||||
if (!v || len < 2) {
|
||||
free(v);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Return angle in radians for 2D vector
|
||||
@@ -438,14 +438,14 @@ JSC_CCALL(math_distance,
|
||||
if (!a || !b) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
size_t len = (alen < blen) ? alen : blen;
|
||||
if (len == 0) {
|
||||
free(a);
|
||||
free(b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
float distSq = 0.0f;
|
||||
|
||||
@@ -210,7 +210,7 @@ JSValue js_writer_add_file(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
if (!success)
|
||||
return JS_ThrowInternalError(js, "Failed to add memory to zip");
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ static int nota_stack_has(NotaEncodeContext *enc, JSValueConst val)
|
||||
}
|
||||
|
||||
static JSValue apply_replacer(NotaEncodeContext *enc, JSValueConst holder, JSValueConst key, JSValueConst val) {
|
||||
if (JS_IsUndefined(enc->replacer)) return JS_DupValue(enc->ctx, val);
|
||||
if (JS_IsNull(enc->replacer)) return JS_DupValue(enc->ctx, val);
|
||||
|
||||
JSValue args[2] = { JS_DupValue(enc->ctx, key), JS_DupValue(enc->ctx, val) };
|
||||
JSValue result = JS_Call(enc->ctx, enc->replacer, holder, 2, args);
|
||||
@@ -103,17 +103,17 @@ char *js_do_nota_decode(JSContext *js, JSValue *tmp, char *nota, JSValue holder,
|
||||
nota = nota_read_sym(&b, nota);
|
||||
if (b == NOTA_PRIVATE) {
|
||||
JSValue inner;
|
||||
nota = js_do_nota_decode(js, &inner, nota, holder, JS_UNDEFINED, reviver);
|
||||
nota = js_do_nota_decode(js, &inner, nota, holder, JS_NULL, reviver);
|
||||
JSValue obj = JS_NewObject(js);
|
||||
cell_rt *crt = JS_GetContextOpaque(js);
|
||||
JS_SetProperty(js, obj, crt->actor_sym, inner);
|
||||
*tmp = obj;
|
||||
} else {
|
||||
switch(b) {
|
||||
case NOTA_NULL: *tmp = JS_UNDEFINED; break;
|
||||
case NOTA_NULL: *tmp = JS_NULL; break;
|
||||
case NOTA_FALSE: *tmp = JS_NewBool(js, 0); break;
|
||||
case NOTA_TRUE: *tmp = JS_NewBool(js, 1); break;
|
||||
default: *tmp = JS_UNDEFINED; break;
|
||||
default: *tmp = JS_NULL; break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -124,7 +124,7 @@ char *js_do_nota_decode(JSContext *js, JSValue *tmp, char *nota, JSValue holder,
|
||||
break;
|
||||
}
|
||||
|
||||
if (!JS_IsUndefined(reviver)) {
|
||||
if (!JS_IsNull(reviver)) {
|
||||
JSValue args[2] = { JS_DupValue(js, key), JS_DupValue(js, *tmp) };
|
||||
JSValue revived = JS_Call(js, reviver, holder, 2, args);
|
||||
JS_FreeValue(js, args[0]);
|
||||
@@ -170,7 +170,6 @@ static void nota_encode_value(NotaEncodeContext *enc, JSValueConst val, JSValueC
|
||||
else nota_write_sym(&enc->nb, NOTA_FALSE);
|
||||
break;
|
||||
case JS_TAG_NULL:
|
||||
case JS_TAG_UNDEFINED:
|
||||
nota_write_sym(&enc->nb, NOTA_NULL);
|
||||
break;
|
||||
case JS_TAG_OBJECT: {
|
||||
@@ -202,9 +201,9 @@ static void nota_encode_value(NotaEncodeContext *enc, JSValueConst val, JSValueC
|
||||
|
||||
cell_rt *crt = JS_GetContextOpaque(ctx);
|
||||
JSValue adata = JS_GetProperty(ctx, replaced, crt->actor_sym);
|
||||
if (!JS_IsUndefined(adata)) {
|
||||
if (!JS_IsNull(adata)) {
|
||||
nota_write_sym(&enc->nb, NOTA_PRIVATE);
|
||||
nota_encode_value(enc, adata, replaced, JS_UNDEFINED);
|
||||
nota_encode_value(enc, adata, replaced, JS_NULL);
|
||||
JS_FreeValue(ctx, adata);
|
||||
break;
|
||||
}
|
||||
@@ -275,10 +274,10 @@ void *value2nota(JSContext *ctx, JSValue v) {
|
||||
enc->ctx = ctx;
|
||||
enc->visitedStack = JS_NewArray(ctx);
|
||||
enc->cycle = 0;
|
||||
enc->replacer = JS_UNDEFINED;
|
||||
enc->replacer = JS_NULL;
|
||||
|
||||
nota_buffer_init(&enc->nb, 128);
|
||||
nota_encode_value(enc, v, JS_UNDEFINED, JS_NewString(ctx, ""));
|
||||
nota_encode_value(enc, v, JS_NULL, JS_NewString(ctx, ""));
|
||||
|
||||
if (enc->cycle) {
|
||||
JS_FreeValue(ctx, enc->visitedStack);
|
||||
@@ -294,10 +293,10 @@ void *value2nota(JSContext *ctx, JSValue v) {
|
||||
}
|
||||
|
||||
JSValue nota2value(JSContext *js, void *nota) {
|
||||
if (!nota) return JS_UNDEFINED;
|
||||
if (!nota) return JS_NULL;
|
||||
JSValue ret;
|
||||
JSValue holder = JS_NewObject(js);
|
||||
js_do_nota_decode(js, &ret, nota, holder, JS_NewString(js, ""), JS_UNDEFINED);
|
||||
js_do_nota_decode(js, &ret, nota, holder, JS_NewString(js, ""), JS_NULL);
|
||||
JS_FreeValue(js, holder);
|
||||
return ret;
|
||||
}
|
||||
@@ -309,10 +308,10 @@ static JSValue js_nota_encode(JSContext *ctx, JSValueConst this_val, int argc, J
|
||||
enc->ctx = ctx;
|
||||
enc->visitedStack = JS_NewArray(ctx);
|
||||
enc->cycle = 0;
|
||||
enc->replacer = (argc > 1 && JS_IsFunction(ctx, argv[1])) ? argv[1] : JS_UNDEFINED;
|
||||
enc->replacer = (argc > 1 && JS_IsFunction(ctx, argv[1])) ? argv[1] : JS_NULL;
|
||||
|
||||
nota_buffer_init(&enc->nb, 128);
|
||||
nota_encode_value(enc, argv[0], JS_UNDEFINED, JS_NewString(ctx, ""));
|
||||
nota_encode_value(enc, argv[0], JS_NULL, JS_NewString(ctx, ""));
|
||||
|
||||
if (enc->cycle) {
|
||||
JS_FreeValue(ctx, enc->visitedStack);
|
||||
@@ -330,13 +329,13 @@ static JSValue js_nota_encode(JSContext *ctx, JSValueConst this_val, int argc, J
|
||||
}
|
||||
|
||||
static JSValue js_nota_decode(JSContext *js, JSValueConst self, int argc, JSValueConst *argv) {
|
||||
if (argc < 1) return JS_UNDEFINED;
|
||||
if (argc < 1) return JS_NULL;
|
||||
|
||||
size_t len;
|
||||
unsigned char *nota = js_get_blob_data(js, &len, argv[0]);
|
||||
if (!nota) return JS_UNDEFINED;
|
||||
if (!nota) return JS_NULL;
|
||||
|
||||
JSValue reviver = (argc > 1 && JS_IsFunction(js, argv[1])) ? argv[1] : JS_UNDEFINED;
|
||||
JSValue reviver = (argc > 1 && JS_IsFunction(js, argv[1])) ? argv[1] : JS_NULL;
|
||||
JSValue ret;
|
||||
JSValue holder = JS_NewObject(js);
|
||||
js_do_nota_decode(js, &ret, (char*)nota, holder, JS_NewString(js, ""), reviver);
|
||||
|
||||
@@ -533,7 +533,7 @@ static JSValue js_array_slice(JSContext *js, JSValueConst self, int argc, JSValu
|
||||
int32_t end = arr->size;
|
||||
|
||||
// Parse start argument
|
||||
if (argc >= 1 && !JS_IsUndefined(argv[0])) {
|
||||
if (argc >= 1 && !JS_IsNull(argv[0])) {
|
||||
if (JS_ToInt32(js, &start, argv[0]))
|
||||
return JS_EXCEPTION;
|
||||
|
||||
@@ -547,7 +547,7 @@ static JSValue js_array_slice(JSContext *js, JSValueConst self, int argc, JSValu
|
||||
}
|
||||
|
||||
// Parse end argument
|
||||
if (argc >= 2 && !JS_IsUndefined(argv[1])) {
|
||||
if (argc >= 2 && !JS_IsNull(argv[1])) {
|
||||
if (JS_ToInt32(js, &end, argv[1]))
|
||||
return JS_EXCEPTION;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ JSC_CCALL(os_totalmem, return number2js(js, SDL_GetSystemRAM()))
|
||||
JSC_CCALL(os_platform, return JS_NewString(js,SDL_GetPlatform()))
|
||||
|
||||
static JSValue js_os_hostname(JSContext *js, JSValue self, int argc, JSValue *argv) {
|
||||
JSValue ret = JS_UNDEFINED;
|
||||
JSValue ret = JS_NULL;
|
||||
#ifdef _WIN32
|
||||
TCHAR buffer[256] = TEXT("");
|
||||
DWORD size = sizeof(buffer) / sizeof(TCHAR);
|
||||
@@ -71,7 +71,7 @@ static JSValue js_os_hostname(JSContext *js, JSValue self, int argc, JSValue *ar
|
||||
}
|
||||
|
||||
static JSValue js_os_arch(JSContext *js, JSValue self, int argc, JSValue *argv) {
|
||||
JSValue ret = JS_UNDEFINED;
|
||||
JSValue ret = JS_NULL;
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
return JS_NewString(js,"x64");
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
@@ -99,7 +99,7 @@ static JSValue js_os_arch(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
}
|
||||
|
||||
static JSValue js_os_freemem(JSContext *js, JSValue self, int argc, JSValue *argv) {
|
||||
JSValue ret = JS_UNDEFINED;
|
||||
JSValue ret = JS_NULL;
|
||||
#ifdef _WIN32
|
||||
MEMORYSTATUSEX statex;
|
||||
statex.dwLength = sizeof(statex);
|
||||
@@ -126,7 +126,7 @@ static JSValue js_os_freemem(JSContext *js, JSValue self, int argc, JSValue *arg
|
||||
}
|
||||
|
||||
static JSValue js_os_version(JSContext *js, JSValue self, int argc, JSValue *argv) {
|
||||
JSValue ret = JS_UNDEFINED;
|
||||
JSValue ret = JS_NULL;
|
||||
#ifdef _WIN32
|
||||
typedef LONG (WINAPI *RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
|
||||
HMODULE h = GetModuleHandleA("ntdll.dll");
|
||||
@@ -200,7 +200,7 @@ JS_SetPropertyStr(js, OBJ, #FIELD, TYPE##2js(js,STRUCT.FIELD));\
|
||||
#define JSJMEMRET(FIELD) JSOBJ_ADD_FIELD(ret, jsmem, FIELD, number)
|
||||
|
||||
JSC_CCALL(os_mallinfo,
|
||||
ret = JS_UNDEFINED;
|
||||
ret = JS_NULL;
|
||||
/*struct mallinfo jsmem = mallinfo();
|
||||
ret = JS_NewObject(js);
|
||||
JSJMEMRET(arena);
|
||||
@@ -216,7 +216,7 @@ JSC_CCALL(os_mallinfo,
|
||||
)
|
||||
|
||||
static JSValue js_os_rusage(JSContext *js, JSValue self, int argc, JSValue *argv) {
|
||||
JSValue ret = JS_UNDEFINED;
|
||||
JSValue ret = JS_NULL;
|
||||
ret = JS_NewObject(js);
|
||||
|
||||
#ifndef _WIN32
|
||||
@@ -244,12 +244,12 @@ static JSValue js_os_rusage(JSContext *js, JSValue self, int argc, JSValue *argv
|
||||
#ifdef TRACY_ENABLE
|
||||
#include <tracy/TracyC.h>
|
||||
JSC_CCALL(os_frame,
|
||||
if (!tracy_profiling_enabled) return JS_UNDEFINED;
|
||||
if (!tracy_profiling_enabled) return JS_NULL;
|
||||
TracyCFrameMark
|
||||
)
|
||||
|
||||
JSC_CCALL(os_trace_img,
|
||||
if (!tracy_profiling_enabled) return JS_UNDEFINED;
|
||||
if (!tracy_profiling_enabled) return JS_NULL;
|
||||
size_t len;
|
||||
double width, height;
|
||||
JS_ToFloat64(js,&width,argv[1]);
|
||||
@@ -258,7 +258,7 @@ JSC_CCALL(os_trace_img,
|
||||
)
|
||||
|
||||
JSC_CCALL(os_trace_message,
|
||||
if (!tracy_profiling_enabled) return JS_UNDEFINED;
|
||||
if (!tracy_profiling_enabled) return JS_NULL;
|
||||
size_t len;
|
||||
const char *str = JS_ToCStringLen(js, &len, argv[0]);
|
||||
TracyCMessage(str,len);
|
||||
|
||||
@@ -24,11 +24,11 @@ static JSValue js_qr_encode(JSContext *js, JSValueConst this_val, int argc, JSVa
|
||||
int use_byte_mode = 0;
|
||||
|
||||
// Handle options object (argv[1])
|
||||
if (argc > 1 && !JS_IsUndefined(argv[1]) && JS_IsObject(argv[1])) {
|
||||
if (argc > 1 && !JS_IsNull(argv[1]) && JS_IsObject(argv[1])) {
|
||||
JSValue opt = argv[1];
|
||||
|
||||
JSValue m = JS_GetPropertyStr(js, opt, "mode");
|
||||
if (!JS_IsUndefined(m)) {
|
||||
if (!JS_IsNull(m)) {
|
||||
const char *smode = JS_ToCString(js, m);
|
||||
if (!smode) { JS_FreeValue(js, m); return JS_EXCEPTION; }
|
||||
if (!strcasecmp(smode, "byte") || !strcasecmp(smode, "binary"))
|
||||
@@ -45,7 +45,7 @@ static JSValue js_qr_encode(JSContext *js, JSValueConst this_val, int argc, JSVa
|
||||
|
||||
// Version (1-40)
|
||||
JSValue v = JS_GetPropertyStr(js, opt, "version");
|
||||
if (!JS_IsUndefined(v)) {
|
||||
if (!JS_IsNull(v)) {
|
||||
int32_t ver;
|
||||
if (JS_ToInt32(js, &ver, v) || ver < 0 || ver > 40) {
|
||||
JS_FreeValue(js, v);
|
||||
@@ -57,7 +57,7 @@ static JSValue js_qr_encode(JSContext *js, JSValueConst this_val, int argc, JSVa
|
||||
|
||||
// Error correction level ("l", "m", "q", "h")
|
||||
JSValue l = JS_GetPropertyStr(js, opt, "level");
|
||||
if (!JS_IsUndefined(l)) {
|
||||
if (!JS_IsNull(l)) {
|
||||
const char *level = JS_ToCString(js, l);
|
||||
if (!level) {
|
||||
JS_FreeValue(js, l);
|
||||
@@ -78,7 +78,7 @@ static JSValue js_qr_encode(JSContext *js, JSValueConst this_val, int argc, JSVa
|
||||
|
||||
// Case sensitivity (true/false)
|
||||
JSValue ci = JS_GetPropertyStr(js, opt, "caseinsensitive");
|
||||
if (!JS_IsUndefined(ci)) {
|
||||
if (!JS_IsNull(ci)) {
|
||||
int bool_val;
|
||||
if (JS_ToBool(js, ci)) {
|
||||
bool_val = 0; // qrencode: 0 = case-insensitive
|
||||
@@ -239,7 +239,7 @@ static JSValue js_qr_rgba(JSContext *js, JSValueConst self, int argc, JSValueCon
|
||||
if (argc > 2) JS_ToUint32(js, &off, argv[2]);
|
||||
|
||||
JSValue js_w = JS_GetPropertyStr(js, mods, "width");
|
||||
if (JS_IsUndefined(js_w)) {
|
||||
if (JS_IsNull(js_w)) {
|
||||
JS_FreeValue(js, js_w);
|
||||
return JS_ThrowTypeError(js, "mods.width missing");
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ JSC_CCALL(SDL_Renderer_draw_color,
|
||||
|
||||
JSC_CCALL(SDL_Renderer_rect,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[1])) {
|
||||
if (!JS_IsNull(argv[1])) {
|
||||
colorf color = js2color(js,argv[1]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ JSC_CCALL(SDL_Renderer_rect,
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
SDL_RenderRects(r,rects,len);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
rect rect = js2rect(js,argv[0]);
|
||||
@@ -85,7 +85,7 @@ JSC_CCALL(renderer_load_texture,
|
||||
|
||||
JSC_CCALL(SDL_Renderer_fillrect,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[1])) {
|
||||
if (!JS_IsNull(argv[1])) {
|
||||
colorf color = js2color(js,argv[1]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
@@ -112,12 +112,12 @@ JSC_CCALL(renderer_texture,
|
||||
SDL_Texture *tex = js2SDL_Texture(js,argv[0]);
|
||||
rect dst = transform_rect(js2rect(js,argv[1]), &cam_mat);
|
||||
|
||||
if (!JS_IsUndefined(argv[3])) {
|
||||
if (!JS_IsNull(argv[3])) {
|
||||
colorf color = js2color(js,argv[3]);
|
||||
SDL_SetTextureColorModFloat(tex, color.r, color.g, color.b);
|
||||
SDL_SetTextureAlphaModFloat(tex,color.a);
|
||||
}
|
||||
if (JS_IsUndefined(argv[2]))
|
||||
if (JS_IsNull(argv[2]))
|
||||
SDL_RenderTexture(renderer,tex,NULL,&dst);
|
||||
else {
|
||||
|
||||
@@ -137,7 +137,7 @@ JSC_CCALL(renderer_tile,
|
||||
if (!dst.h) dst.h = tex->h;
|
||||
float scale = js2number(js,argv[3]);
|
||||
if (!scale) scale = 1;
|
||||
if (JS_IsUndefined(argv[2]))
|
||||
if (JS_IsNull(argv[2]))
|
||||
SDL_RenderTextureTiled(renderer,tex,NULL,scale, &dst);
|
||||
else {
|
||||
rect src = js2rect(js,argv[2]);
|
||||
@@ -154,15 +154,15 @@ JSC_CCALL(renderer_slice9,
|
||||
dst = transform_rect(js2rect(js,argv[1]), &cam_mat);
|
||||
|
||||
SDL_RenderTexture9Grid(renderer, tex,
|
||||
JS_IsUndefined(argv[3]) ? NULL : &src,
|
||||
JS_IsNull(argv[3]) ? NULL : &src,
|
||||
bounds.l, bounds.r, bounds.t, bounds.b, 0.0,
|
||||
JS_IsUndefined(argv[1]) ? NULL : &dst);
|
||||
JS_IsNull(argv[1]) ? NULL : &dst);
|
||||
)
|
||||
|
||||
JSC_CCALL(renderer_get_image,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
SDL_Surface *surf = NULL;
|
||||
if (!JS_IsUndefined(argv[0])) {
|
||||
if (!JS_IsNull(argv[0])) {
|
||||
rect rect = js2rect(js,argv[0]);
|
||||
surf = SDL_RenderReadPixels(r,&rect);
|
||||
} else
|
||||
@@ -173,7 +173,7 @@ JSC_CCALL(renderer_get_image,
|
||||
|
||||
JSC_SCALL(renderer_fasttext,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[2])) {
|
||||
if (!JS_IsNull(argv[2])) {
|
||||
colorf color = js2color(js,argv[2]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
@@ -185,7 +185,7 @@ JSC_SCALL(renderer_fasttext,
|
||||
|
||||
JSC_CCALL(renderer_line,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[1])) {
|
||||
if (!JS_IsNull(argv[1])) {
|
||||
colorf color = js2color(js,argv[1]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
@@ -205,7 +205,7 @@ JSC_CCALL(renderer_line,
|
||||
|
||||
JSC_CCALL(renderer_point,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (!JS_IsUndefined(argv[1])) {
|
||||
if (!JS_IsNull(argv[1])) {
|
||||
colorf color = js2color(js,argv[1]);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
}
|
||||
@@ -220,7 +220,7 @@ JSC_CCALL(renderer_point,
|
||||
JS_FreeValue(js,val);
|
||||
}
|
||||
SDL_RenderPoints(r, points, len);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
HMM_Vec2 point = transform_point(r, js2vec2(js,argv[0]), &cam_mat);
|
||||
@@ -297,7 +297,7 @@ JSC_CCALL(renderer_logical_size,
|
||||
|
||||
JSC_CCALL(renderer_viewport,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (JS_IsUndefined(argv[0]))
|
||||
if (JS_IsNull(argv[0]))
|
||||
SDL_SetRenderViewport(r,NULL);
|
||||
else {
|
||||
rect view = js2rect(js,argv[0]);
|
||||
@@ -319,7 +319,7 @@ JSC_CCALL(renderer_get_viewport,
|
||||
|
||||
JSC_CCALL(renderer_clip,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (JS_IsUndefined(argv[0]))
|
||||
if (JS_IsNull(argv[0]))
|
||||
SDL_SetRenderClipRect(r,NULL);
|
||||
else {
|
||||
rect view = js2rect(js,argv[0]);
|
||||
@@ -376,7 +376,7 @@ JSC_CCALL(renderer_screen2world,
|
||||
|
||||
JSC_CCALL(renderer_target,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (JS_IsUndefined(argv[0]))
|
||||
if (JS_IsNull(argv[0]))
|
||||
SDL_SetRenderTarget(r, NULL);
|
||||
else {
|
||||
SDL_Texture *tex = js2SDL_Texture(js,argv[0]);
|
||||
@@ -408,12 +408,12 @@ JSC_CCALL(renderer_make_sprite_mesh,
|
||||
HMM_Vec4 color;
|
||||
|
||||
rect src;
|
||||
if (JS_IsUndefined(jssrc))
|
||||
if (JS_IsNull(jssrc))
|
||||
src = (rect){.x = 0, .y = 0, .w = 1, .h = 1};
|
||||
else
|
||||
src = js2rect(js,jssrc);
|
||||
|
||||
if (JS_IsUndefined(jscolor))
|
||||
if (JS_IsNull(jscolor))
|
||||
color = (HMM_Vec4){1,1,1,1};
|
||||
else
|
||||
color = js2vec4(js,jscolor);
|
||||
|
||||
@@ -105,7 +105,7 @@ struct rtree_each
|
||||
|
||||
int rtree_foreach(const NUMTYPE *min, const NUMTYPE *max, const JSValue *value, struct rtree_each *each)
|
||||
{
|
||||
JSValue ret = JS_Call(each->js, each->fn, JS_UNDEFINED, 0, NULL);
|
||||
JSValue ret = JS_Call(each->js, each->fn, JS_NULL, 0, NULL);
|
||||
uncaught_exception(each->js, ret);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ static SDL_CameraSpec js2cameraspec(JSContext *js, JSValue obj) {
|
||||
JSValue v;
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "format");
|
||||
if (!JS_IsUndefined(v)) {
|
||||
if (!JS_IsNull(v)) {
|
||||
const char *s = JS_ToCString(js, v);
|
||||
spec.format = str2pixelformat(s);
|
||||
JS_FreeCString(js, s);
|
||||
@@ -191,23 +191,23 @@ static SDL_CameraSpec js2cameraspec(JSContext *js, JSValue obj) {
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "colorspace");
|
||||
if (!JS_IsUndefined(v)) JS_ToInt32(js, &spec.colorspace, v);
|
||||
if (!JS_IsNull(v)) JS_ToInt32(js, &spec.colorspace, v);
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "width");
|
||||
if (!JS_IsUndefined(v)) JS_ToInt32(js, &spec.width, v);
|
||||
if (!JS_IsNull(v)) JS_ToInt32(js, &spec.width, v);
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "height");
|
||||
if (!JS_IsUndefined(v)) JS_ToInt32(js, &spec.height, v);
|
||||
if (!JS_IsNull(v)) JS_ToInt32(js, &spec.height, v);
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "framerate_numerator");
|
||||
if (!JS_IsUndefined(v)) JS_ToInt32(js, &spec.framerate_numerator, v);
|
||||
if (!JS_IsNull(v)) JS_ToInt32(js, &spec.framerate_numerator, v);
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "framerate_denominator");
|
||||
if (!JS_IsUndefined(v)) JS_ToInt32(js, &spec.framerate_denominator, v);
|
||||
if (!JS_IsNull(v)) JS_ToInt32(js, &spec.framerate_denominator, v);
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
return spec;
|
||||
@@ -229,7 +229,7 @@ JSC_CCALL(camera_open,
|
||||
SDL_CameraSpec spec;
|
||||
|
||||
// Check if a format spec was provided
|
||||
if (argc > 1 && !JS_IsUndefined(argv[1])) {
|
||||
if (argc > 1 && !JS_IsNull(argv[1])) {
|
||||
spec = js2cameraspec(js, argv[1]);
|
||||
spec_ptr = &spec;
|
||||
}
|
||||
@@ -300,7 +300,7 @@ JSC_CCALL(camera_capture,
|
||||
const char *msg = SDL_GetError();
|
||||
if (msg[0] != 0)
|
||||
return JS_ThrowReferenceError(js,"Could not get camera frame: %s", SDL_GetError());
|
||||
else return JS_UNDEFINED;
|
||||
else return JS_NULL;
|
||||
}
|
||||
|
||||
// Create a copy of the surface
|
||||
@@ -330,7 +330,7 @@ JSC_CCALL(camera_get_driver,
|
||||
if (!cam) return JS_ThrowReferenceError(js,"Self was not a camera: %s", SDL_GetError());
|
||||
|
||||
const char *driver = SDL_GetCurrentCameraDriver();
|
||||
if (!driver) return JS_UNDEFINED;
|
||||
if (!driver) return JS_NULL;
|
||||
|
||||
return JS_NewString(js, driver);
|
||||
)
|
||||
@@ -415,7 +415,7 @@ static SDL_AudioSpec js2audiospec(JSContext *js, JSValue obj)
|
||||
JSValue v;
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "format");
|
||||
if (!JS_IsUndefined(v)) {
|
||||
if (!JS_IsNull(v)) {
|
||||
const char *s = JS_ToCString(js, v);
|
||||
format_str_to_enum(s, &spec.format);
|
||||
JS_FreeCString(js, s);
|
||||
@@ -423,11 +423,11 @@ static SDL_AudioSpec js2audiospec(JSContext *js, JSValue obj)
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "channels");
|
||||
if (!JS_IsUndefined(v)) JS_ToInt32(js, &spec.channels, v);
|
||||
if (!JS_IsNull(v)) JS_ToInt32(js, &spec.channels, v);
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
v = JS_GetPropertyStr(js, obj, "samplerate");
|
||||
if (!JS_IsUndefined(v)) JS_ToInt32(js, &spec.freq, v);
|
||||
if (!JS_IsNull(v)) JS_ToInt32(js, &spec.freq, v);
|
||||
JS_FreeValue(js, v);
|
||||
|
||||
return spec;
|
||||
@@ -461,7 +461,7 @@ JSC_CCALL(sdl_audio_open_stream,
|
||||
|
||||
SDL_AudioStream *st;
|
||||
|
||||
if (JS_IsUndefined(argv[1]))
|
||||
if (JS_IsNull(argv[1]))
|
||||
st = SDL_OpenAudioDeviceStream(devid, NULL, NULL, NULL);
|
||||
else {
|
||||
SDL_AudioSpec want = js2audiospec(js, argv[1]);
|
||||
@@ -496,11 +496,11 @@ JSC_CCALL(sdl_audiostream_set_format,
|
||||
const SDL_AudioSpec *src_ptr=NULL,*dst_ptr=NULL;
|
||||
SDL_AudioSpec src={0},dst={0};
|
||||
|
||||
if(argc>0&&!JS_IsUndefined(argv[0])){
|
||||
if(argc>0&&!JS_IsNull(argv[0])){
|
||||
src=js2audiospec(js,argv[0]);
|
||||
src_ptr=&src;
|
||||
}
|
||||
if(argc>1&&!JS_IsUndefined(argv[1])){
|
||||
if(argc>1&&!JS_IsNull(argv[1])){
|
||||
dst=js2audiospec(js,argv[1]);
|
||||
dst_ptr=&dst;
|
||||
}
|
||||
@@ -508,7 +508,7 @@ JSC_CCALL(sdl_audiostream_set_format,
|
||||
if(!SDL_SetAudioStreamFormat(as,src_ptr,dst_ptr))
|
||||
return JS_ThrowInternalError(js,"%s",SDL_GetError());
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(sdl_audiostream_resume,
|
||||
@@ -516,21 +516,21 @@ JSC_CCALL(sdl_audiostream_resume,
|
||||
if (!SDL_ResumeAudioStreamDevice(as))
|
||||
return JS_ThrowInternalError(js,"%s",SDL_GetError());
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(sdl_audiostream_clear,
|
||||
SDL_AudioStream *as=js2SDL_AudioStream(js,self);
|
||||
if (!SDL_ClearAudioStream(as))
|
||||
return JS_ThrowInternalError(js,"%s",SDL_GetError());
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(sdl_audiostream_flush,
|
||||
SDL_AudioStream *as=js2SDL_AudioStream(js,self);
|
||||
if(!SDL_FlushAudioStream(as))
|
||||
return JS_ThrowInternalError(js,"%s",SDL_GetError());
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(sdl_audiostream_available,
|
||||
@@ -557,7 +557,7 @@ JSC_CCALL(sdl_audiostream_put,
|
||||
|
||||
if (!SDL_PutAudioStreamData(as,buf,len))
|
||||
return JS_ThrowInternalError(js, "%s", SDL_GetError());
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(sdl_audiostream_get,
|
||||
@@ -587,7 +587,7 @@ JSC_CCALL(sdl_audiostream_set_gain,
|
||||
SDL_AudioStream *as=js2SDL_AudioStream(js,self);
|
||||
double g; JS_ToFloat64(js,&g,argv[0]);
|
||||
SDL_SetAudioStreamGain(as,(float)g);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(sdl_audiostream_get_freq_ratio,
|
||||
@@ -599,7 +599,7 @@ JSC_CCALL(sdl_audiostream_set_freq_ratio,
|
||||
SDL_AudioStream *as=js2SDL_AudioStream(js,self);
|
||||
double r; JS_ToFloat64(js,&r,argv[0]);
|
||||
SDL_SetAudioStreamFrequencyRatio(as,(float)r);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
/* ---------- JS export list -------------------------------------------- */
|
||||
|
||||
@@ -70,7 +70,7 @@ SDL_GPUSampleCount js2SDL_GPUSampleCount(JSContext *js, JSValue v)
|
||||
|
||||
#define JS2ENUM(NAME, RETS, VALS) \
|
||||
int js2##NAME(JSContext *js, JSValue v) { \
|
||||
if (JS_IsUndefined(v)) return 0; \
|
||||
if (JS_IsNull(v)) return 0; \
|
||||
const char *str = JS_ToCString(js, v); \
|
||||
int *rets = (RETS); \
|
||||
const char **vals = (VALS); \
|
||||
@@ -728,19 +728,19 @@ SDL_GPUStencilOpState js2SDL_GPUStencilOpState(JSContext *js, JSValue v)
|
||||
memset(&state, 0, sizeof(state));
|
||||
|
||||
JSValue compare_val = JS_GetPropertyStr(js, v, "compare");
|
||||
if(!JS_IsUndefined(compare_val)) state.compare_op = js2SDL_GPUCompareOp(js, compare_val);
|
||||
if(!JS_IsNull(compare_val)) state.compare_op = js2SDL_GPUCompareOp(js, compare_val);
|
||||
JS_FreeValue(js, compare_val);
|
||||
|
||||
JSValue fail_val = JS_GetPropertyStr(js, v, "fail");
|
||||
if(!JS_IsUndefined(fail_val)) state.fail_op = js2SDL_GPUStencilOp(js, fail_val);
|
||||
if(!JS_IsNull(fail_val)) state.fail_op = js2SDL_GPUStencilOp(js, fail_val);
|
||||
JS_FreeValue(js, fail_val);
|
||||
|
||||
JSValue depth_fail_val = JS_GetPropertyStr(js, v, "depth_fail");
|
||||
if(!JS_IsUndefined(depth_fail_val)) state.depth_fail_op = js2SDL_GPUStencilOp(js, depth_fail_val);
|
||||
if(!JS_IsNull(depth_fail_val)) state.depth_fail_op = js2SDL_GPUStencilOp(js, depth_fail_val);
|
||||
JS_FreeValue(js, depth_fail_val);
|
||||
|
||||
JSValue pass_val = JS_GetPropertyStr(js, v, "pass");
|
||||
if(!JS_IsUndefined(pass_val)) state.pass_op = js2SDL_GPUStencilOp(js, pass_val);
|
||||
if(!JS_IsNull(pass_val)) state.pass_op = js2SDL_GPUStencilOp(js, pass_val);
|
||||
JS_FreeValue(js, pass_val);
|
||||
|
||||
return state;
|
||||
@@ -798,8 +798,8 @@ JSC_CCALL(cmd_acquire_swapchain,
|
||||
Uint32 w,h;
|
||||
SDL_GPUTexture *texture;
|
||||
SDL_AcquireGPUSwapchainTexture(cmds,global_window, &texture, &w, &h);
|
||||
if (!texture) return JS_UNDEFINED;
|
||||
JSValue swap = JS_UNDEFINED;
|
||||
if (!texture) return JS_NULL;
|
||||
JSValue swap = JS_NULL;
|
||||
|
||||
JSValue *js_swapchains = ((cell_rt*)JS_GetContextOpaque(js))->js_swapchains;
|
||||
|
||||
@@ -810,7 +810,7 @@ JSC_CCALL(cmd_acquire_swapchain,
|
||||
}
|
||||
}
|
||||
|
||||
if (JS_IsUndefined(swap)) {
|
||||
if (JS_IsNull(swap)) {
|
||||
swap = SDL_GPUTexture2js(js,texture);
|
||||
arrput(js_swapchains,swap);
|
||||
}
|
||||
@@ -1580,7 +1580,7 @@ JSC_CCALL(gpu_upload,
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
JSValue js_buf = JS_GetPropertyUint32(js, js_buffers, i);
|
||||
|
||||
if (JS_IsUndefined(js_buf))
|
||||
if (JS_IsNull(js_buf))
|
||||
continue;
|
||||
|
||||
gpu_buffer_unpack(js, gpu, js_buf, &items[i].size, &items[i].data, &items[i].gpu_buffer);
|
||||
@@ -1883,7 +1883,7 @@ JSC_CCALL(cmd_render_pass,
|
||||
|
||||
// Optional depth_stencil
|
||||
JSValue depthval = JS_GetPropertyStr(js, passObj, "depth_stencil");
|
||||
if (!JS_IsUndefined(depthval)) {
|
||||
if (!JS_IsNull(depthval)) {
|
||||
has_depth = 1;
|
||||
JS_GETPROP(js, depthtar.texture, depthval, texture, SDL_GPUTexture)
|
||||
JS_GETPROP(js, depthtar.load_op, depthval, load, SDL_GPULoadOp)
|
||||
@@ -2243,7 +2243,7 @@ SDL_GPUSampleCount js2SDL_GPUSampleCount(JSContext *js, JSValue v)
|
||||
// Enum conversion macro and definitions
|
||||
#define JS2ENUM(NAME, RETS, VALS) \
|
||||
int js2##NAME(JSContext *js, JSValue v) { \
|
||||
if (JS_IsUndefined(v)) return 0; \
|
||||
if (JS_IsNull(v)) return 0; \
|
||||
const char *str = JS_ToCString(js, v); \
|
||||
int *rets = (RETS); \
|
||||
const char **vals = (VALS); \
|
||||
@@ -2431,5 +2431,5 @@ JSValue js_sdl_gpu_use(JSContext *js)
|
||||
{
|
||||
// GPU classes are registered via the main FFI loading system
|
||||
// This module doesn't export its own functions, it just provides class definitions
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ JSValue pixelformat2js(JSContext *js, SDL_PixelFormat fmt)
|
||||
|
||||
SDL_PixelFormat js2pixelformat(JSContext *js, JSValue v)
|
||||
{
|
||||
if (JS_IsUndefined(v)) return SDL_PIXELFORMAT_UNKNOWN;
|
||||
if (JS_IsNull(v)) return SDL_PIXELFORMAT_UNKNOWN;
|
||||
const char *s = JS_ToCString(js, v);
|
||||
if (!s) return SDL_PIXELFORMAT_UNKNOWN;
|
||||
|
||||
@@ -41,7 +41,7 @@ static JSValue scalemode2js(JSContext *js, SDL_ScaleMode mode){
|
||||
}
|
||||
|
||||
SDL_ScaleMode js2SDL_ScaleMode(JSContext *js, JSValue v){
|
||||
if(JS_IsUndefined(v)) return SDL_SCALEMODE_NEAREST;
|
||||
if(JS_IsNull(v)) return SDL_SCALEMODE_NEAREST;
|
||||
const char *s = JS_ToCString(js, v);
|
||||
if(!s) return SDL_SCALEMODE_NEAREST;
|
||||
const scale_entry *it;
|
||||
@@ -66,14 +66,14 @@ JSC_CCALL(surface_blit,
|
||||
SDL_Surface *dst = js2SDL_Surface(js, self);
|
||||
|
||||
irect dr = {0}, *pdr = NULL;
|
||||
if(!JS_IsUndefined(argv[0])){ dr = js2irect(js, argv[0]); pdr = &dr; }
|
||||
if(!JS_IsNull(argv[0])){ dr = js2irect(js, argv[0]); pdr = &dr; }
|
||||
|
||||
SDL_Surface *src = js2SDL_Surface(js, argv[1]);
|
||||
if (!src)
|
||||
return JS_ThrowReferenceError(js, "Argument must be a surface.");
|
||||
|
||||
irect sr = {0}, *psr = NULL;
|
||||
if(!JS_IsUndefined(argv[2])){ sr = js2irect(js, argv[2]); psr = &sr; }
|
||||
if(!JS_IsNull(argv[2])){ sr = js2irect(js, argv[2]); psr = &sr; }
|
||||
|
||||
SDL_ScaleMode mode = js2SDL_ScaleMode(js, argv[3]);
|
||||
|
||||
@@ -241,14 +241,14 @@ JSC_CCALL(surface_constructor,
|
||||
// Check for pixel format
|
||||
SDL_PixelFormat format = SDL_PIXELFORMAT_RGBA32; // default
|
||||
JSValue format_val = JS_GetPropertyStr(js, argv[0], "format");
|
||||
if (!JS_IsUndefined(format_val)) {
|
||||
if (!JS_IsNull(format_val)) {
|
||||
format = js2pixelformat(js, format_val);
|
||||
}
|
||||
JS_FreeValue(js, format_val);
|
||||
|
||||
// Check for pixel data
|
||||
JSValue pixels_val = JS_GetPropertyStr(js, argv[0], "pixels");
|
||||
if (!JS_IsUndefined(pixels_val)) {
|
||||
if (!JS_IsNull(pixels_val)) {
|
||||
// Create surface from pixel data
|
||||
size_t len;
|
||||
void *raw = js_get_blob_data(js, &len, pixels_val);
|
||||
@@ -261,7 +261,7 @@ JSC_CCALL(surface_constructor,
|
||||
// Get pitch if provided, otherwise calculate it
|
||||
int pitch;
|
||||
JSValue pitch_val = JS_GetPropertyStr(js, argv[0], "pitch");
|
||||
if (!JS_IsUndefined(pitch_val)) {
|
||||
if (!JS_IsNull(pitch_val)) {
|
||||
pitch = js2number(js, pitch_val);
|
||||
JS_FreeValue(js, pitch_val);
|
||||
} else {
|
||||
|
||||
@@ -87,7 +87,7 @@ static JSValue js_window_constructor(JSContext *js, JSValueConst new_target, int
|
||||
// Get basic properties (defaults are handled in JavaScript)
|
||||
const char *title = NULL;
|
||||
JSValue title_val = JS_GetPropertyStr(js, opts, "title");
|
||||
if (!JS_IsUndefined(title_val) && !JS_IsNull(title_val)) {
|
||||
if (!JS_IsNull(title_val) && !JS_IsNull(title_val)) {
|
||||
title = JS_ToCString(js, title_val);
|
||||
}
|
||||
JS_FreeValue(js, title_val);
|
||||
@@ -98,14 +98,14 @@ static JSValue js_window_constructor(JSContext *js, JSValueConst new_target, int
|
||||
|
||||
int width = 640;
|
||||
JSValue width_val = JS_GetPropertyStr(js, opts, "width");
|
||||
if (!JS_IsUndefined(width_val) && !JS_IsNull(width_val)) {
|
||||
if (!JS_IsNull(width_val) && !JS_IsNull(width_val)) {
|
||||
width = js2number(js, width_val);
|
||||
}
|
||||
JS_FreeValue(js, width_val);
|
||||
|
||||
int height = 480;
|
||||
JSValue height_val = JS_GetPropertyStr(js, opts, "height");
|
||||
if (!JS_IsUndefined(height_val) && !JS_IsNull(height_val)) {
|
||||
if (!JS_IsNull(height_val) && !JS_IsNull(height_val)) {
|
||||
height = js2number(js, height_val);
|
||||
}
|
||||
JS_FreeValue(js, height_val);
|
||||
@@ -120,7 +120,7 @@ static JSValue js_window_constructor(JSContext *js, JSValueConst new_target, int
|
||||
|
||||
// Handle window position
|
||||
JSValue x_val = JS_GetPropertyStr(js, opts, "x");
|
||||
if (!JS_IsUndefined(x_val)) {
|
||||
if (!JS_IsNull(x_val)) {
|
||||
if (JS_IsString(x_val)) {
|
||||
const char *pos = JS_ToCString(js, x_val);
|
||||
if (strcmp(pos, "centered") == 0)
|
||||
@@ -135,7 +135,7 @@ static JSValue js_window_constructor(JSContext *js, JSValueConst new_target, int
|
||||
JS_FreeValue(js, x_val);
|
||||
|
||||
JSValue y_val = JS_GetPropertyStr(js, opts, "y");
|
||||
if (!JS_IsUndefined(y_val)) {
|
||||
if (!JS_IsNull(y_val)) {
|
||||
if (JS_IsString(y_val)) {
|
||||
const char *pos = JS_ToCString(js, y_val);
|
||||
if (strcmp(pos, "centered") == 0)
|
||||
@@ -152,7 +152,7 @@ static JSValue js_window_constructor(JSContext *js, JSValueConst new_target, int
|
||||
// Helper function to check and set boolean properties
|
||||
#define SET_BOOL_PROP(js_name, sdl_prop) do { \
|
||||
JSValue val = JS_GetPropertyStr(js, opts, js_name); \
|
||||
if (!JS_IsUndefined(val)) { \
|
||||
if (!JS_IsNull(val)) { \
|
||||
SDL_SetBooleanProperty(props, sdl_prop, JS_ToBool(js, val)); \
|
||||
} \
|
||||
JS_FreeValue(js, val); \
|
||||
@@ -180,14 +180,14 @@ static JSValue js_window_constructor(JSContext *js, JSValueConst new_target, int
|
||||
|
||||
// Handle focusable (inverse logic)
|
||||
JSValue focusable_val = JS_GetPropertyStr(js, opts, "focusable");
|
||||
if (!JS_IsUndefined(focusable_val)) {
|
||||
if (!JS_IsNull(focusable_val)) {
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN, JS_ToBool(js, focusable_val));
|
||||
}
|
||||
JS_FreeValue(js, focusable_val);
|
||||
|
||||
// Handle notFocusable (for backwards compatibility)
|
||||
JSValue not_focusable_val = JS_GetPropertyStr(js, opts, "notFocusable");
|
||||
if (!JS_IsUndefined(not_focusable_val)) {
|
||||
if (!JS_IsNull(not_focusable_val)) {
|
||||
SDL_SetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN, !JS_ToBool(js, not_focusable_val));
|
||||
}
|
||||
JS_FreeValue(js, not_focusable_val);
|
||||
@@ -196,7 +196,7 @@ static JSValue js_window_constructor(JSContext *js, JSValueConst new_target, int
|
||||
|
||||
// Handle parent window
|
||||
JSValue parent_val = JS_GetPropertyStr(js, opts, "parent");
|
||||
if (!JS_IsUndefined(parent_val) && !JS_IsNull(parent_val)) {
|
||||
if (!JS_IsNull(parent_val) && !JS_IsNull(parent_val)) {
|
||||
SDL_Window *parent = js2SDL_Window(js, parent_val);
|
||||
if (parent) {
|
||||
SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_PARENT_POINTER, parent);
|
||||
@@ -224,22 +224,22 @@ static JSValue js_window_constructor(JSContext *js, JSValueConst new_target, int
|
||||
// These will be applied through the property setters
|
||||
|
||||
JSValue opacity_val = JS_GetPropertyStr(js, opts, "opacity");
|
||||
if (!JS_IsUndefined(opacity_val)) {
|
||||
if (!JS_IsNull(opacity_val)) {
|
||||
JS_SetPropertyStr(js, window_obj, "opacity", opacity_val);
|
||||
}
|
||||
|
||||
JSValue min_size_val = JS_GetPropertyStr(js, opts, "minimumSize");
|
||||
if (!JS_IsUndefined(min_size_val)) {
|
||||
if (!JS_IsNull(min_size_val)) {
|
||||
JS_SetPropertyStr(js, window_obj, "minimumSize", min_size_val);
|
||||
}
|
||||
|
||||
JSValue max_size_val = JS_GetPropertyStr(js, opts, "maximumSize");
|
||||
if (!JS_IsUndefined(max_size_val)) {
|
||||
if (!JS_IsNull(max_size_val)) {
|
||||
JS_SetPropertyStr(js, window_obj, "maximumSize", max_size_val);
|
||||
}
|
||||
|
||||
JSValue pos_val = JS_GetPropertyStr(js, opts, "position");
|
||||
if (!JS_IsUndefined(pos_val)) {
|
||||
if (!JS_IsNull(pos_val)) {
|
||||
JS_SetPropertyStr(js, window_obj, "position", pos_val);
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ JSValue js_SDL_Window_keyboard_shown(JSContext *js, JSValue self) {
|
||||
|
||||
JSValue js_window_theme(JSContext *js, JSValue self)
|
||||
{
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_safe_area(JSContext *js, JSValue self)
|
||||
@@ -290,7 +290,7 @@ JSValue js_window_bordered(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowBordered(w, JS_ToBool(js,argv[0]));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_get_title(JSContext *js, JSValue self)
|
||||
@@ -306,7 +306,7 @@ JSValue js_window_set_title(JSContext *js, JSValue self, JSValue val)
|
||||
const char *title = JS_ToCString(js,val);
|
||||
SDL_SetWindowTitle(w,title);
|
||||
JS_FreeCString(js,title);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_get_size(JSContext *js, JSValue self)
|
||||
@@ -322,7 +322,7 @@ JSValue js_window_set_size(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
HMM_Vec2 size = js2vec2(js,val);
|
||||
SDL_SetWindowSize(w,size.x,size.y);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_set_icon(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
@@ -331,7 +331,7 @@ JSValue js_window_set_icon(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
SDL_Surface *s = js2SDL_Surface(js,argv[0]);
|
||||
if (!SDL_SetWindowIcon(w,s))
|
||||
return JS_ThrowReferenceError(js, "could not set window icon: %s", SDL_GetError());
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Position getter/setter
|
||||
@@ -348,7 +348,7 @@ JSValue js_window_set_position(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
HMM_Vec2 pos = js2vec2(js,val);
|
||||
SDL_SetWindowPosition(w,pos.x,pos.y);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Mouse grab getter/setter
|
||||
@@ -362,7 +362,7 @@ JSValue js_window_set_mouseGrab(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowMouseGrab(w, JS_ToBool(js,val));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Keyboard grab getter/setter
|
||||
@@ -376,7 +376,7 @@ JSValue js_window_set_keyboardGrab(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowKeyboardGrab(w, JS_ToBool(js,val));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Opacity getter/setter
|
||||
@@ -391,7 +391,7 @@ JSValue js_window_set_opacity(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
float opacity = js2number(js,val);
|
||||
SDL_SetWindowOpacity(w, opacity);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Minimum size getter/setter
|
||||
@@ -408,7 +408,7 @@ JSValue js_window_set_minimumSize(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
HMM_Vec2 size = js2vec2(js,val);
|
||||
SDL_SetWindowMinimumSize(w,size.x,size.y);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Maximum size getter/setter
|
||||
@@ -425,7 +425,7 @@ JSValue js_window_set_maximumSize(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
HMM_Vec2 size = js2vec2(js,val);
|
||||
SDL_SetWindowMaximumSize(w,size.x,size.y);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Resizable setter (read from flags)
|
||||
@@ -440,7 +440,7 @@ JSValue js_window_set_resizable(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowResizable(w, JS_ToBool(js,val));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Bordered getter/setter
|
||||
@@ -455,7 +455,7 @@ JSValue js_window_set_bordered(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowBordered(w, JS_ToBool(js,val));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Always on top getter/setter
|
||||
@@ -470,7 +470,7 @@ JSValue js_window_set_alwaysOnTop(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowAlwaysOnTop(w, JS_ToBool(js,val));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Fullscreen getter/setter
|
||||
@@ -485,7 +485,7 @@ JSValue js_window_set_fullscreen(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowFullscreen(w, JS_ToBool(js,val));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Focusable setter
|
||||
@@ -500,7 +500,7 @@ JSValue js_window_set_focusable(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowFocusable(w, JS_ToBool(js,val));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Modal setter
|
||||
@@ -515,7 +515,7 @@ JSValue js_window_set_modal(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SetWindowModal(w, JS_ToBool(js,val));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Hidden/visible state
|
||||
@@ -533,7 +533,7 @@ JSValue js_window_set_visible(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_ShowWindow(w);
|
||||
else
|
||||
SDL_HideWindow(w);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Minimized state
|
||||
@@ -551,7 +551,7 @@ JSValue js_window_set_minimized(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_MinimizeWindow(w);
|
||||
else
|
||||
SDL_RestoreWindow(w);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Maximized state
|
||||
@@ -569,7 +569,7 @@ JSValue js_window_set_maximized(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_MaximizeWindow(w);
|
||||
else
|
||||
SDL_RestoreWindow(w);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Other window methods
|
||||
@@ -577,14 +577,14 @@ JSValue js_window_raise(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_RaiseWindow(w);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_restore(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_RestoreWindow(w);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_flash(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
@@ -599,14 +599,14 @@ JSValue js_window_flash(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
JS_FreeCString(js,operation);
|
||||
}
|
||||
SDL_FlashWindow(w, op);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_destroy(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_DestroyWindow(w);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_get_id(JSContext *js, JSValue self)
|
||||
@@ -627,10 +627,10 @@ JSValue js_window_set_parent(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_Window *parent = NULL;
|
||||
if (!JS_IsNull(val) && !JS_IsUndefined(val))
|
||||
if (!JS_IsNull(val) && !JS_IsNull(val))
|
||||
parent = js2SDL_Window(js,val);
|
||||
SDL_SetWindowParent(w, parent);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_get_pixelDensity(JSContext *js, JSValue self)
|
||||
@@ -667,7 +667,7 @@ JSValue js_window_updateSurface(JSContext *js, JSValue self, int argc, JSValue *
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
if (!SDL_UpdateWindowSurface(w))
|
||||
return JS_ThrowReferenceError(js, "Failed to update window surface: %s", SDL_GetError());
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_updateSurfaceRects(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
@@ -689,7 +689,7 @@ JSValue js_window_updateSurfaceRects(JSContext *js, JSValue self, int argc, JSVa
|
||||
|
||||
if (!SDL_UpdateWindowSurfaceRects(w, rects, len))
|
||||
return JS_ThrowReferenceError(js, "Failed to update window surface rects: %s", SDL_GetError());
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue js_window_get_flags(JSContext *js, JSValue self)
|
||||
@@ -702,7 +702,7 @@ JSValue js_window_sync(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
SDL_Window *w = js2SDL_Window(js,self);
|
||||
SDL_SyncWindow(w);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static const JSCFunctionListEntry js_SDL_Window_funcs[] = {
|
||||
@@ -768,7 +768,7 @@ JSC_CCALL(renderer_load_texture,
|
||||
JSC_CCALL(renderer_get_image,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
SDL_Surface *surf = NULL;
|
||||
if (!JS_IsUndefined(argv[0])) {
|
||||
if (!JS_IsNull(argv[0])) {
|
||||
rect rect = js2rect(js,argv[0]);
|
||||
surf = SDL_RenderReadPixels(r,&rect);
|
||||
} else
|
||||
@@ -812,7 +812,7 @@ JSC_CCALL(renderer_point,
|
||||
pts[i] = (SDL_FPoint){pt.x, pt.y};
|
||||
}
|
||||
SDL_RenderPoints(r, pts, len);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
HMM_Vec2 pt = js2vec2(js, argv[0]);
|
||||
@@ -839,7 +839,7 @@ JSC_CCALL(renderer_rects,
|
||||
/* array-of-rectangles case */
|
||||
if (JS_IsArray(js, argv[0])) {
|
||||
int len = JS_ArrayLength(js, argv[0]);
|
||||
if (len <= 0) return JS_UNDEFINED;
|
||||
if (len <= 0) return JS_NULL;
|
||||
|
||||
SDL_FRect rects[len];
|
||||
|
||||
@@ -852,7 +852,7 @@ JSC_CCALL(renderer_rects,
|
||||
|
||||
if (!SDL_RenderFillRects(r, rects, len))
|
||||
return JS_ThrowReferenceError(js, "SDL_RenderFillRects: %s", SDL_GetError());
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
/* single-rect path */
|
||||
@@ -893,7 +893,7 @@ JSC_CCALL(renderer_geometry_raw,
|
||||
|
||||
// argv[0] is texture
|
||||
SDL_Texture *tex = NULL;
|
||||
if (argc > 0 && !JS_IsNull(argv[0]) && !JS_IsUndefined(argv[0]))
|
||||
if (argc > 0 && !JS_IsNull(argv[0]) && !JS_IsNull(argv[0]))
|
||||
tex = js2SDL_Texture(js,argv[0]);
|
||||
|
||||
// Get blob data
|
||||
@@ -1045,7 +1045,7 @@ static JSValue logicalpresentation2js(JSContext *js,
|
||||
|
||||
static SDL_RendererLogicalPresentation
|
||||
js2SDL_LogicalPresentation(JSContext *js, JSValue v){
|
||||
if(JS_IsUndefined(v)) return SDL_LOGICAL_PRESENTATION_DISABLED;
|
||||
if(JS_IsNull(v)) return SDL_LOGICAL_PRESENTATION_DISABLED;
|
||||
const char *s = JS_ToCString(js, v);
|
||||
if(!s) return SDL_LOGICAL_PRESENTATION_DISABLED;
|
||||
const pres_entry *it;
|
||||
@@ -1069,13 +1069,13 @@ JSValue js_renderer_get_target(JSContext *js, JSValue self)
|
||||
JSValue js_renderer_set_target(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (JS_IsNull(val) || JS_IsUndefined(val))
|
||||
if (JS_IsNull(val) || JS_IsNull(val))
|
||||
SDL_SetRenderTarget(r, NULL);
|
||||
else {
|
||||
SDL_Texture *tex = js2SDL_Texture(js,val);
|
||||
SDL_SetRenderTarget(r,tex);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Logical presentation getter/setter
|
||||
@@ -1101,7 +1101,7 @@ JSValue js_renderer_set_logicalPresentation(JSContext *js, JSValue self, JSValue
|
||||
SDL_RendererLogicalPresentation mode = js2SDL_LogicalPresentation(js, mode_val);
|
||||
JS_FreeValue(js, mode_val);
|
||||
SDL_SetRenderLogicalPresentation(r, w, h, mode);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Viewport getter/setter
|
||||
@@ -1116,13 +1116,13 @@ JSValue js_renderer_get_viewport(JSContext *js, JSValue self)
|
||||
JSValue js_renderer_set_viewport(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (JS_IsNull(val) || JS_IsUndefined(val))
|
||||
if (JS_IsNull(val) || JS_IsNull(val))
|
||||
SDL_SetRenderViewport(r,NULL);
|
||||
else {
|
||||
rect view = js2rect(js,val);
|
||||
SDL_SetRenderViewport(r,&view);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Clip rect getter/setter
|
||||
@@ -1137,13 +1137,13 @@ JSValue js_renderer_get_clipRect(JSContext *js, JSValue self)
|
||||
JSValue js_renderer_set_clipRect(JSContext *js, JSValue self, JSValue val)
|
||||
{
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
if (JS_IsNull(val) || JS_IsUndefined(val))
|
||||
if (JS_IsNull(val) || JS_IsNull(val))
|
||||
SDL_SetRenderClipRect(r,NULL);
|
||||
else {
|
||||
rect clip = js2rect(js,val);
|
||||
SDL_SetRenderClipRect(r,&clip);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Scale getter/setter
|
||||
@@ -1160,7 +1160,7 @@ JSValue js_renderer_set_scale(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
HMM_Vec2 scale = js2vec2(js,val);
|
||||
SDL_SetRenderScale(r, scale.x, scale.y);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Draw color getter/setter (float version)
|
||||
@@ -1182,7 +1182,7 @@ JSValue js_renderer_set_drawColor(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
colorf color = js2color(js,val);
|
||||
SDL_SetRenderDrawColorFloat(r, color.r, color.g, color.b, color.a);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Color scale getter/setter
|
||||
@@ -1199,7 +1199,7 @@ JSValue js_renderer_set_colorScale(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
float scale = js2number(js,val);
|
||||
SDL_SetRenderColorScale(r, scale);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Draw blend mode getter/setter
|
||||
@@ -1216,7 +1216,7 @@ JSValue js_renderer_set_drawBlendMode(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
SDL_BlendMode mode = js2blendmode(js,val);
|
||||
SDL_SetRenderDrawBlendMode(r, mode);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// VSync getter/setter
|
||||
@@ -1233,7 +1233,7 @@ JSValue js_renderer_set_vsync(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
int vsync = js2number(js,val);
|
||||
SDL_SetRenderVSync(r, vsync);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Read-only properties
|
||||
@@ -1360,7 +1360,7 @@ JSC_CCALL(renderer_textureTiled,
|
||||
SDL_Texture *tex = js2SDL_Texture(js, argv[0]);
|
||||
|
||||
rect src_rect = {0};
|
||||
if (argc > 1 && !JS_IsNull(argv[1]) && !JS_IsUndefined(argv[1]))
|
||||
if (argc > 1 && !JS_IsNull(argv[1]) && !JS_IsNull(argv[1]))
|
||||
src_rect = js2rect(js, argv[1]);
|
||||
|
||||
float scale = 1.0f;
|
||||
@@ -1368,7 +1368,7 @@ JSC_CCALL(renderer_textureTiled,
|
||||
scale = js2number(js, argv[2]);
|
||||
|
||||
rect dst_rect = {0};
|
||||
if (argc > 3 && !JS_IsNull(argv[3]) && !JS_IsUndefined(argv[3]))
|
||||
if (argc > 3 && !JS_IsNull(argv[3]) && !JS_IsNull(argv[3]))
|
||||
dst_rect = js2rect(js, argv[3]);
|
||||
|
||||
if (!SDL_RenderTextureTiled(r, tex,
|
||||
@@ -1393,7 +1393,7 @@ JSC_CCALL(renderer_debugText,
|
||||
JSC_CCALL(renderer_readPixels,
|
||||
SDL_Renderer *r = js2SDL_Renderer(js,self);
|
||||
rect read_rect = {0};
|
||||
if (argc >= 1 && !JS_IsNull(argv[0]) && !JS_IsUndefined(argv[0]))
|
||||
if (argc >= 1 && !JS_IsNull(argv[0]) && !JS_IsNull(argv[0]))
|
||||
read_rect = js2rect(js, argv[0]);
|
||||
|
||||
SDL_Surface *surf = SDL_RenderReadPixels(r,
|
||||
@@ -1513,13 +1513,13 @@ static JSValue js_texture_constructor(JSContext *js, JSValueConst new_target, in
|
||||
|
||||
JSValue format_val = JS_GetPropertyStr(js, obj, "format");
|
||||
SDL_PixelFormat format = SDL_PIXELFORMAT_RGBA8888;
|
||||
if (!JS_IsUndefined(format_val))
|
||||
if (!JS_IsNull(format_val))
|
||||
format = js2pixelformat(js, format_val);
|
||||
JS_FreeValue(js, format_val);
|
||||
|
||||
// Check for pixels data
|
||||
JSValue pixels_val = JS_GetPropertyStr(js, obj, "pixels");
|
||||
if (!JS_IsUndefined(pixels_val)) {
|
||||
if (!JS_IsNull(pixels_val)) {
|
||||
// Create surface first, then texture
|
||||
size_t size;
|
||||
uint8_t *pixels = js_get_blob_data(js, &size, pixels_val);
|
||||
@@ -1611,7 +1611,7 @@ JSValue js_texture_set_alphaMod(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Texture *tex = js2SDL_Texture(js,self);
|
||||
float alpha = js2number(js,val);
|
||||
SDL_SetTextureAlphaModFloat(tex, alpha);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Color mod getter/setter
|
||||
@@ -1632,7 +1632,7 @@ JSValue js_texture_set_colorMod(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Texture *tex = js2SDL_Texture(js,self);
|
||||
colorf color = js2color(js,val);
|
||||
SDL_SetTextureColorModFloat(tex, color.r, color.g, color.b);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Blend mode getter/setter
|
||||
@@ -1649,7 +1649,7 @@ JSValue js_texture_set_blendMode(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Texture *tex = js2SDL_Texture(js,self);
|
||||
SDL_BlendMode mode = js2blendmode(js,val);
|
||||
SDL_SetTextureBlendMode(tex, mode);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Scale mode getter/setter
|
||||
@@ -1668,7 +1668,7 @@ JSValue js_texture_set_scaleMode(JSContext *js, JSValue self, JSValue val)
|
||||
SDL_Texture *tex = js2SDL_Texture(js,self);
|
||||
SDL_ScaleMode mode = js2SDL_ScaleMode(js,val);
|
||||
SDL_SetTextureScaleMode(tex, mode);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Size getter (read-only)
|
||||
@@ -1687,7 +1687,7 @@ JSC_CCALL(texture_update,
|
||||
void *pixels = NULL;
|
||||
int pitch = 0;
|
||||
|
||||
if (argc >= 1 && !JS_IsNull(argv[0]) && !JS_IsUndefined(argv[0]))
|
||||
if (argc >= 1 && !JS_IsNull(argv[0]) && !JS_IsNull(argv[0]))
|
||||
update_rect = js2rect(js, argv[0]);
|
||||
|
||||
if (argc >= 2) {
|
||||
@@ -1713,7 +1713,7 @@ JSC_CCALL(texture_lock,
|
||||
void *pixels;
|
||||
int pitch;
|
||||
|
||||
if (argc >= 1 && !JS_IsNull(argv[0]) && !JS_IsUndefined(argv[0]))
|
||||
if (argc >= 1 && !JS_IsNull(argv[0]) && !JS_IsNull(argv[0]))
|
||||
lock_rect = js2rect(js, argv[0]);
|
||||
|
||||
if (!SDL_LockTexture(tex,
|
||||
|
||||
@@ -35,10 +35,10 @@ JSC_CCALL(socket_getaddrinfo,
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
if (!JS_IsNull(argv[0]) && !JS_IsUndefined(argv[0]))
|
||||
if (!JS_IsNull(argv[0]) && !JS_IsNull(argv[0]))
|
||||
node = JS_ToCString(js, argv[0]);
|
||||
|
||||
if (!JS_IsNull(argv[1]) && !JS_IsUndefined(argv[1]))
|
||||
if (!JS_IsNull(argv[1]) && !JS_IsNull(argv[1]))
|
||||
service = JS_ToCString(js, argv[1]);
|
||||
|
||||
// Parse optional hints object
|
||||
@@ -46,7 +46,7 @@ JSC_CCALL(socket_getaddrinfo,
|
||||
JSValue val;
|
||||
|
||||
val = JS_GetPropertyStr(js, argv[2], "family");
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
const char *family = JS_ToCString(js, val);
|
||||
if (strcmp(family, "AF_INET") == 0) hints.ai_family = AF_INET;
|
||||
else if (strcmp(family, "AF_INET6") == 0) hints.ai_family = AF_INET6;
|
||||
@@ -55,7 +55,7 @@ JSC_CCALL(socket_getaddrinfo,
|
||||
JS_FreeValue(js, val);
|
||||
|
||||
val = JS_GetPropertyStr(js, argv[2], "socktype");
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
const char *socktype = JS_ToCString(js, val);
|
||||
if (strcmp(socktype, "SOCK_STREAM") == 0) hints.ai_socktype = SOCK_STREAM;
|
||||
else if (strcmp(socktype, "SOCK_DGRAM") == 0) hints.ai_socktype = SOCK_DGRAM;
|
||||
@@ -64,7 +64,7 @@ JSC_CCALL(socket_getaddrinfo,
|
||||
JS_FreeValue(js, val);
|
||||
|
||||
val = JS_GetPropertyStr(js, argv[2], "flags");
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
hints.ai_flags = js2number(js, val);
|
||||
}
|
||||
JS_FreeValue(js, val);
|
||||
@@ -192,7 +192,7 @@ JSC_CCALL(socket_bind,
|
||||
}
|
||||
}
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(socket_connect,
|
||||
@@ -220,7 +220,7 @@ JSC_CCALL(socket_connect,
|
||||
}
|
||||
}
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(socket_listen,
|
||||
@@ -236,7 +236,7 @@ JSC_CCALL(socket_listen,
|
||||
return JS_ThrowReferenceError(js, "listen failed: %s", strerror(errno));
|
||||
}
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(socket_accept,
|
||||
@@ -448,7 +448,7 @@ JSC_CCALL(socket_shutdown,
|
||||
return JS_ThrowReferenceError(js, "shutdown failed: %s", strerror(errno));
|
||||
}
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(socket_getpeername,
|
||||
@@ -538,7 +538,7 @@ JSC_CCALL(socket_setsockopt,
|
||||
return JS_ThrowTypeError(js, "Invalid option value");
|
||||
}
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(socket_close,
|
||||
@@ -548,7 +548,7 @@ JSC_CCALL(socket_close,
|
||||
if (close(sockfd) != 0)
|
||||
return JS_ThrowReferenceError(js, "close failed: %s", strerror(errno));
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
static const JSCFunctionListEntry js_socket_funcs[] = {
|
||||
|
||||
@@ -147,7 +147,7 @@ static const JSCFunctionListEntry *js_Wav_funcs;
|
||||
static JSValue js_voice_set_##ENTRY (JSContext *js, JSValueConst self, JSValue val) { \
|
||||
unsigned int voice = *js2voice(js, self); \
|
||||
Soloud_set##ENTRY(soloud, voice, js2##TYPE(js, val)); \
|
||||
return JS_UNDEFINED; \
|
||||
return JS_NULL; \
|
||||
} \
|
||||
static JSValue js_voice_get_##ENTRY (JSContext *js, JSValueConst self) { \
|
||||
unsigned int voice = *js2voice(js,self); \
|
||||
@@ -158,14 +158,14 @@ static JSValue js_voice_seek(JSContext *js, JSValue self, int argc, JSValue *arg
|
||||
{
|
||||
unsigned int voice = *js2voice(js, self);
|
||||
Soloud_seek(soloud, voice, js2number(js, argv[0]));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_voice_stop(JSContext *js, JSValue self, int argc, JSValue *argv)
|
||||
{
|
||||
unsigned int voice = *js2voice(js, self);
|
||||
Soloud_stop(soloud, voice);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_voice_setInaudibleBehavior(JSContext *js, JSValueConst self, int argc, JSValue *argv)
|
||||
@@ -174,7 +174,7 @@ static JSValue js_voice_setInaudibleBehavior(JSContext *js, JSValueConst self, i
|
||||
int mustTick = js2bool(js, argv[0]);
|
||||
int kill = js2bool(js, argv[1]);
|
||||
Soloud_setInaudibleBehavior(soloud, voice, mustTick, kill);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
SOLOUD_GETSET(Volume, number);
|
||||
|
||||
@@ -31,7 +31,7 @@ JSC_CCALL(spline_catmull,
|
||||
HMM_Vec2 *samples = catmull_rom_ma_v2(points, param);
|
||||
|
||||
if (!samples)
|
||||
ret = JS_UNDEFINED;
|
||||
ret = JS_NULL;
|
||||
else
|
||||
ret = vecarr2js(js, samples, arrlen(samples));
|
||||
|
||||
@@ -45,7 +45,7 @@ JSC_CCALL(spline_bezier,
|
||||
HMM_Vec2 *samples = bezier_cb_ma_v2(points, param);
|
||||
|
||||
if (!samples)
|
||||
ret = JS_UNDEFINED;
|
||||
ret = JS_NULL;
|
||||
else
|
||||
ret = vecarr2js(js, samples, arrlen(samples));
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ JSC_CCALL(sprite_set_affine,
|
||||
|
||||
JSC_CCALL(sprite_set_image,
|
||||
sprite *sp = js2sprite(js,self);
|
||||
if (!JS_IsUndefined(sp->image))
|
||||
if (!JS_IsNull(sp->image))
|
||||
JS_FreeValue(js,sp->image);
|
||||
sp->image = JS_DupValue(js, argv[0]);
|
||||
)
|
||||
@@ -75,7 +75,7 @@ static JSValue js_sprite_constructor(JSContext *js, JSValueConst new_target, int
|
||||
JS_GETATOM(js, sp->color, argv[0], color, color)
|
||||
|
||||
JSValue image = JS_GetProperty(js, argv[0], JS_NewAtom(js, "image"));
|
||||
if (!JS_IsUndefined(image)) {
|
||||
if (!JS_IsNull(image)) {
|
||||
sp->image = image; // Transfer ownership, no need to dup
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,14 +49,14 @@ JSC_CCALL(steam_shutdown,
|
||||
SteamAPI_Shutdown();
|
||||
steam_initialized = false;
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(steam_run_callbacks,
|
||||
if (steam_initialized) {
|
||||
SteamAPI_RunCallbacks();
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
// USER STATS & ACHIEVEMENTS
|
||||
@@ -84,7 +84,7 @@ JSC_CCALL(stats_get_int,
|
||||
bool success = SteamAPI_ISteamUserStats_GetStatInt32(steam_stats, name, &value);
|
||||
JS_FreeCString(js, name);
|
||||
|
||||
if (!success) return JS_UNDEFINED;
|
||||
if (!success) return JS_NULL;
|
||||
return JS_NewInt32(js, value);
|
||||
)
|
||||
|
||||
@@ -98,7 +98,7 @@ JSC_CCALL(stats_get_float,
|
||||
bool success = SteamAPI_ISteamUserStats_GetStatFloat(steam_stats, name, &value);
|
||||
JS_FreeCString(js, name);
|
||||
|
||||
if (!success) return JS_UNDEFINED;
|
||||
if (!success) return JS_NULL;
|
||||
return JS_NewFloat64(js, value);
|
||||
)
|
||||
|
||||
@@ -143,7 +143,7 @@ JSC_CCALL(achievement_get,
|
||||
bool success = SteamAPI_ISteamUserStats_GetAchievement(steam_stats, name, &achieved);
|
||||
JS_FreeCString(js, name);
|
||||
|
||||
if (!success) return JS_UNDEFINED;
|
||||
if (!success) return JS_NULL;
|
||||
return JS_NewBool(js, achieved);
|
||||
)
|
||||
|
||||
@@ -185,7 +185,7 @@ JSC_CCALL(achievement_name,
|
||||
JS_ToUint32(js, &index, argv[0]);
|
||||
|
||||
const char *name = SteamAPI_ISteamUserStats_GetAchievementName(steam_stats, index);
|
||||
if (!name) return JS_UNDEFINED;
|
||||
if (!name) return JS_NULL;
|
||||
|
||||
return JS_NewString(js, name);
|
||||
)
|
||||
@@ -307,7 +307,7 @@ JSC_CCALL(cloud_enable,
|
||||
|
||||
bool enable = JS_ToBool(js, argv[0]);
|
||||
SteamAPI_ISteamRemoteStorage_SetCloudEnabledForApp(steam_remote, enable);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
)
|
||||
|
||||
JSC_CCALL(cloud_quota,
|
||||
@@ -316,7 +316,7 @@ JSC_CCALL(cloud_quota,
|
||||
uint64 total, available;
|
||||
bool success = SteamAPI_ISteamRemoteStorage_GetQuota(steam_remote, &total, &available);
|
||||
|
||||
if (!success) return JS_UNDEFINED;
|
||||
if (!success) return JS_NULL;
|
||||
|
||||
JSValue obj = JS_NewObject(js);
|
||||
JS_SetPropertyStr(js, obj, "total", JS_NewBigUint64(js, total));
|
||||
@@ -367,7 +367,7 @@ JSC_CCALL(cloud_read,
|
||||
int32 size = SteamAPI_ISteamRemoteStorage_GetFileSize(steam_remote, filename);
|
||||
if (size <= 0) {
|
||||
JS_FreeCString(js, filename);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
uint8_t *buffer = (uint8_t*)js_malloc(js, size);
|
||||
@@ -381,7 +381,7 @@ JSC_CCALL(cloud_read,
|
||||
|
||||
if (read != size) {
|
||||
js_free(js, buffer);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
JSValue result = js_new_blob_stoned_copy(js, buffer, size);
|
||||
@@ -509,6 +509,6 @@ extern "C" JSValue js_steam_use(JSContext *js) {
|
||||
#else
|
||||
// Stub when Steam is disabled
|
||||
extern "C" JSValue js_steam_use(JSContext *js) {
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -35,23 +35,23 @@ static JSValue js_transform_get_change_hook(JSContext *js, JSValueConst self)
|
||||
static JSValue js_transform_set_change_hook(JSContext *js, JSValueConst self, JSValue v)
|
||||
{
|
||||
transform *t = js2transform(js,self);
|
||||
if (!JS_IsUndefined(v) && !JS_IsFunction(js,v)) return JS_ThrowReferenceError(js, "Hook must be a function.");
|
||||
if (!JS_IsNull(v) && !JS_IsFunction(js,v)) return JS_ThrowReferenceError(js, "Hook must be a function.");
|
||||
JS_FreeValue(js,t->change_hook);
|
||||
t->change_hook = JS_DupValue(js,v);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_transform_get_parent(JSContext *js, JSValueConst self)
|
||||
{
|
||||
transform *t = js2transform(js,self);
|
||||
if (t->parent) return JS_DupValue(js,t->jsparent);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_transform_set_parent(JSContext *js, JSValueConst self, JSValue v)
|
||||
{
|
||||
transform *p = js2transform(js,v);
|
||||
if (!JS_IsUndefined(v) && !p)
|
||||
if (!JS_IsNull(v) && !p)
|
||||
return JS_ThrowReferenceError(js,"Parent must be another transform.");
|
||||
|
||||
transform *t = js2transform(js,self);
|
||||
@@ -62,7 +62,7 @@ static JSValue js_transform_set_parent(JSContext *js, JSValueConst self, JSValue
|
||||
if (t->parent) {
|
||||
transform *cur_parent = t->parent;
|
||||
JS_FreeValue(js,t->jsparent);
|
||||
t->jsparent = JS_UNDEFINED;
|
||||
t->jsparent = JS_NULL;
|
||||
|
||||
for (int i = 0; i < arrlen(cur_parent->children); i++) {
|
||||
if (cur_parent->children[i] == t) {
|
||||
@@ -91,7 +91,7 @@ static JSValue js_transform_set_parent(JSContext *js, JSValueConst self, JSValue
|
||||
|
||||
transform_apply(t);
|
||||
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// TRANSFORM ACTION FUNCTIONS
|
||||
@@ -152,9 +152,9 @@ JSC_CCALL(transform_unit,
|
||||
|
||||
JSC_CCALL(transform_trs,
|
||||
transform *t = js2transform(js,self);
|
||||
t->pos = JS_IsUndefined(argv[0]) ? v3zero : js2vec3(js,argv[0]);
|
||||
t->rotation = JS_IsUndefined(argv[1]) ? QUAT1 : js2quat(js,argv[1]);
|
||||
t->scale = JS_IsUndefined(argv[2]) ? v3one : js2vec3(js,argv[2]);
|
||||
t->pos = JS_IsNull(argv[0]) ? v3zero : js2vec3(js,argv[0]);
|
||||
t->rotation = JS_IsNull(argv[1]) ? QUAT1 : js2quat(js,argv[1]);
|
||||
t->scale = JS_IsNull(argv[2]) ? v3one : js2vec3(js,argv[2]);
|
||||
transform_apply(t);
|
||||
)
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ JSC_CCALL(utf8_char_at,
|
||||
|
||||
if (!*ptr || count != index) {
|
||||
JS_FreeCString(js, str);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
// Get the character
|
||||
|
||||
@@ -61,8 +61,8 @@ static void wota_stack_free(WotaEncodeContext *enc)
|
||||
|
||||
static JSValue apply_replacer(WotaEncodeContext *enc, JSValueConst holder, JSAtom key, JSValueConst val)
|
||||
{
|
||||
if (JS_IsUndefined(enc->replacer)) return JS_DupValue(enc->ctx, val);
|
||||
JSValue key_val = (key == JS_ATOM_NULL) ? JS_UNDEFINED : JS_AtomToValue(enc->ctx, key);
|
||||
if (JS_IsNull(enc->replacer)) return JS_DupValue(enc->ctx, val);
|
||||
JSValue key_val = (key == JS_ATOM_NULL) ? JS_NULL : JS_AtomToValue(enc->ctx, key);
|
||||
JSValue args[2] = { key_val, JS_DupValue(enc->ctx, val) };
|
||||
JSValue result = JS_Call(enc->ctx, enc->replacer, holder, 2, args);
|
||||
JS_FreeValue(enc->ctx, args[0]);
|
||||
@@ -115,7 +115,7 @@ static void wota_encode_value(WotaEncodeContext *enc, JSValueConst val, JSValueC
|
||||
{
|
||||
JSContext *ctx = enc->ctx;
|
||||
JSValue replaced;
|
||||
if (!JS_IsUndefined(enc->replacer) && key != JS_ATOM_NULL)
|
||||
if (!JS_IsNull(enc->replacer) && key != JS_ATOM_NULL)
|
||||
replaced = apply_replacer(enc, holder, key, val);
|
||||
else
|
||||
replaced = JS_DupValue(enc->ctx, val);
|
||||
@@ -149,7 +149,6 @@ static void wota_encode_value(WotaEncodeContext *enc, JSValueConst val, JSValueC
|
||||
wota_write_sym(&enc->wb, JS_VALUE_GET_BOOL(replaced) ? WOTA_TRUE : WOTA_FALSE);
|
||||
break;
|
||||
case JS_TAG_NULL:
|
||||
case JS_TAG_UNDEFINED:
|
||||
wota_write_sym(&enc->wb, WOTA_NULL);
|
||||
break;
|
||||
case JS_TAG_OBJECT: {
|
||||
@@ -180,7 +179,7 @@ static void wota_encode_value(WotaEncodeContext *enc, JSValueConst val, JSValueC
|
||||
}
|
||||
cell_rt *crt = JS_GetContextOpaque(ctx);
|
||||
JSValue adata = JS_GetProperty(ctx, replaced, crt->actor_sym);
|
||||
if (!JS_IsUndefined(adata)) {
|
||||
if (!JS_IsNull(adata)) {
|
||||
wota_write_sym(&enc->wb, WOTA_PRIVATE);
|
||||
wota_encode_value(enc, adata, replaced, JS_ATOM_NULL);
|
||||
JS_FreeValue(ctx, adata);
|
||||
@@ -237,16 +236,16 @@ static char *decode_wota_value(JSContext *ctx, char *data_ptr, JSValue *out_val,
|
||||
int scode;
|
||||
data_ptr = wota_read_sym(&scode, data_ptr);
|
||||
if (scode == WOTA_PRIVATE) {
|
||||
JSValue inner = JS_UNDEFINED;
|
||||
JSValue inner = JS_NULL;
|
||||
data_ptr = decode_wota_value(ctx, data_ptr, &inner, holder, JS_ATOM_NULL, reviver);
|
||||
JSValue obj = JS_NewObject(ctx);
|
||||
cell_rt *crt = JS_GetContextOpaque(ctx);
|
||||
JS_SetProperty(ctx, obj, crt->actor_sym, inner);
|
||||
*out_val = obj;
|
||||
} else if (scode == WOTA_NULL) *out_val = JS_UNDEFINED;
|
||||
} else if (scode == WOTA_NULL) *out_val = JS_NULL;
|
||||
else if (scode == WOTA_FALSE) *out_val = JS_NewBool(ctx, 0);
|
||||
else if (scode == WOTA_TRUE) *out_val = JS_NewBool(ctx, 1);
|
||||
else *out_val = JS_UNDEFINED;
|
||||
else *out_val = JS_NULL;
|
||||
break;
|
||||
}
|
||||
case WOTA_BLOB: {
|
||||
@@ -270,7 +269,7 @@ static char *decode_wota_value(JSContext *ctx, char *data_ptr, JSValue *out_val,
|
||||
JSValue arr = JS_NewArray(ctx);
|
||||
JS_SetLength(ctx, arr, c);
|
||||
for (long long i = 0; i < c; i++) {
|
||||
JSValue elem_val = JS_UNDEFINED;
|
||||
JSValue elem_val = JS_NULL;
|
||||
JSAtom idx_atom = JS_NewAtomUInt32(ctx, (uint32_t)i);
|
||||
data_ptr = decode_wota_value(ctx, data_ptr, &elem_val, arr, idx_atom, reviver);
|
||||
JS_SetPropertyUint32(ctx, arr, i, elem_val);
|
||||
@@ -289,7 +288,7 @@ static char *decode_wota_value(JSContext *ctx, char *data_ptr, JSValue *out_val,
|
||||
data_ptr = wota_read_text_len(&key_len, &tkey, data_ptr);
|
||||
if (!tkey) continue; // invalid key
|
||||
JSAtom prop_key = JS_NewAtomLen(ctx, tkey, key_len);
|
||||
JSValue sub_val = JS_UNDEFINED;
|
||||
JSValue sub_val = JS_NULL;
|
||||
data_ptr = decode_wota_value(ctx, data_ptr, &sub_val, obj, prop_key, reviver);
|
||||
JS_SetProperty(ctx, obj, prop_key, sub_val);
|
||||
JS_FreeAtom(ctx, prop_key);
|
||||
@@ -300,11 +299,11 @@ static char *decode_wota_value(JSContext *ctx, char *data_ptr, JSValue *out_val,
|
||||
}
|
||||
default:
|
||||
data_ptr += 8;
|
||||
*out_val = JS_UNDEFINED;
|
||||
*out_val = JS_NULL;
|
||||
break;
|
||||
}
|
||||
if (!JS_IsUndefined(reviver)) {
|
||||
JSValue key_val = (key == JS_ATOM_NULL) ? JS_UNDEFINED : JS_AtomToValue(ctx, key);
|
||||
if (!JS_IsNull(reviver)) {
|
||||
JSValue key_val = (key == JS_ATOM_NULL) ? JS_NULL : JS_AtomToValue(ctx, key);
|
||||
JSValue args[2] = { key_val, JS_DupValue(ctx, *out_val) };
|
||||
JSValue revived = JS_Call(ctx, reviver, holder, 2, args);
|
||||
JS_FreeValue(ctx, args[0]);
|
||||
@@ -327,7 +326,7 @@ void *value2wota(JSContext *ctx, JSValue v, JSValue replacer, size_t *bytes)
|
||||
enc->cycle = 0;
|
||||
enc->replacer = replacer;
|
||||
wota_buffer_init(&enc->wb, 16);
|
||||
wota_encode_value(enc, v, JS_UNDEFINED, JS_ATOM_NULL);
|
||||
wota_encode_value(enc, v, JS_NULL, JS_ATOM_NULL);
|
||||
if (enc->cycle) {
|
||||
wota_stack_free(enc);
|
||||
wota_buffer_free(&enc->wb);
|
||||
@@ -342,9 +341,9 @@ void *value2wota(JSContext *ctx, JSValue v, JSValue replacer, size_t *bytes)
|
||||
|
||||
JSValue wota2value(JSContext *ctx, void *wota)
|
||||
{
|
||||
JSValue result = JS_UNDEFINED;
|
||||
JSValue result = JS_NULL;
|
||||
JSValue holder = JS_NewObject(ctx);
|
||||
decode_wota_value(ctx, wota, &result, holder, JS_ATOM_NULL, JS_UNDEFINED);
|
||||
decode_wota_value(ctx, wota, &result, holder, JS_ATOM_NULL, JS_NULL);
|
||||
JS_FreeValue(ctx, holder);
|
||||
return result;
|
||||
}
|
||||
@@ -353,7 +352,7 @@ static JSValue js_wota_encode(JSContext *ctx, JSValueConst this_val, int argc, J
|
||||
{
|
||||
if (argc < 1) return JS_ThrowTypeError(ctx, "wota.encode requires at least 1 argument");
|
||||
size_t total_bytes;
|
||||
void *wota = value2wota(ctx, argv[0], JS_IsFunction(ctx,argv[1]) ? argv[1] : JS_UNDEFINED, &total_bytes);
|
||||
void *wota = value2wota(ctx, argv[0], JS_IsFunction(ctx,argv[1]) ? argv[1] : JS_NULL, &total_bytes);
|
||||
JSValue ret = js_new_blob_stoned_copy(ctx, wota, total_bytes);
|
||||
free(wota);
|
||||
return ret;
|
||||
@@ -361,13 +360,13 @@ static JSValue js_wota_encode(JSContext *ctx, JSValueConst this_val, int argc, J
|
||||
|
||||
static JSValue js_wota_decode(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv)
|
||||
{
|
||||
if (argc < 1) return JS_UNDEFINED;
|
||||
if (argc < 1) return JS_NULL;
|
||||
size_t len;
|
||||
uint8_t *buf = js_get_blob_data(ctx, &len, argv[0]);
|
||||
if (!buf) return JS_UNDEFINED;
|
||||
JSValue reviver = (argc > 1 && JS_IsFunction(ctx, argv[1])) ? argv[1] : JS_UNDEFINED;
|
||||
if (!buf) return JS_NULL;
|
||||
JSValue reviver = (argc > 1 && JS_IsFunction(ctx, argv[1])) ? argv[1] : JS_NULL;
|
||||
char *data_ptr = (char *)buf;
|
||||
JSValue result = JS_UNDEFINED;
|
||||
JSValue result = JS_NULL;
|
||||
JSValue holder = JS_NewObject(ctx);
|
||||
JSAtom empty_atom = JS_NewAtom(ctx, "");
|
||||
decode_wota_value(ctx, data_ptr, &result, holder, empty_atom, reviver);
|
||||
|
||||
@@ -653,7 +653,7 @@ int js_module_test_json(JSContext *ctx, JSValueConst attributes)
|
||||
size_t len;
|
||||
BOOL res;
|
||||
|
||||
if (JS_IsUndefined(attributes))
|
||||
if (JS_IsNull(attributes))
|
||||
return FALSE;
|
||||
str = JS_GetPropertyStr(ctx, attributes, "type");
|
||||
if (!JS_IsString(str))
|
||||
@@ -734,7 +734,7 @@ static JSValue js_std_exit(JSContext *ctx, JSValueConst this_val,
|
||||
if (JS_ToInt32(ctx, &status, argv[0]))
|
||||
status = -1;
|
||||
exit(status);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_std_getenv(JSContext *ctx, JSValueConst this_val,
|
||||
@@ -747,7 +747,7 @@ static JSValue js_std_getenv(JSContext *ctx, JSValueConst this_val,
|
||||
str = getenv(name);
|
||||
JS_FreeCString(ctx, name);
|
||||
if (!str)
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
else
|
||||
return JS_NewString(ctx, str);
|
||||
}
|
||||
@@ -789,7 +789,7 @@ static JSValue js_std_setenv(JSContext *ctx, JSValueConst this_val,
|
||||
setenv(name, value, TRUE);
|
||||
JS_FreeCString(ctx, name);
|
||||
JS_FreeCString(ctx, value);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_std_unsetenv(JSContext *ctx, JSValueConst this_val,
|
||||
@@ -801,7 +801,7 @@ static JSValue js_std_unsetenv(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_EXCEPTION;
|
||||
unsetenv(name);
|
||||
JS_FreeCString(ctx, name);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
/* return an object containing the list of the available environment
|
||||
@@ -847,7 +847,7 @@ static JSValue js_std_gc(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
JS_RunGC(JS_GetRuntime(ctx));
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static int interrupt_handler(JSRuntime *rt, void *opaque)
|
||||
@@ -863,7 +863,7 @@ static int get_bool_option(JSContext *ctx, BOOL *pbool,
|
||||
val = JS_GetPropertyStr(ctx, obj, option);
|
||||
if (JS_IsException(val))
|
||||
return -1;
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
*pbool = JS_ToBool(ctx, val);
|
||||
}
|
||||
JS_FreeValue(ctx, val);
|
||||
@@ -995,7 +995,7 @@ static JSValue js_new_std_file(JSContext *ctx, FILE *f,
|
||||
|
||||
static void js_set_error_object(JSContext *ctx, JSValue obj, int err)
|
||||
{
|
||||
if (!JS_IsUndefined(obj)) {
|
||||
if (!JS_IsNull(obj)) {
|
||||
JS_SetPropertyStr(ctx, obj, "errno", JS_NewInt32(ctx, err));
|
||||
}
|
||||
}
|
||||
@@ -1164,7 +1164,7 @@ static JSValue js_std_file_puts(JSContext *ctx, JSValueConst this_val,
|
||||
fwrite(str, 1, len, f);
|
||||
JS_FreeCString(ctx, str);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_std_file_close(JSContext *ctx, JSValueConst this_val,
|
||||
@@ -1203,7 +1203,7 @@ static JSValue js_std_file_printObject(JSContext *ctx, JSValueConst this_val,
|
||||
int argc, JSValueConst *argv)
|
||||
{
|
||||
JS_PrintValue(ctx, js_print_value_write, stdout, argv[0], NULL);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_std_file_flush(JSContext *ctx, JSValueConst this_val,
|
||||
@@ -1213,7 +1213,7 @@ static JSValue js_std_file_flush(JSContext *ctx, JSValueConst this_val,
|
||||
if (!f)
|
||||
return JS_EXCEPTION;
|
||||
fflush(f);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_std_file_tell(JSContext *ctx, JSValueConst this_val,
|
||||
@@ -1281,7 +1281,7 @@ static JSValue js_std_file_clearerr(JSContext *ctx, JSValueConst this_val,
|
||||
if (!f)
|
||||
return JS_EXCEPTION;
|
||||
clearerr(f);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_std_file_fileno(JSContext *ctx, JSValueConst this_val,
|
||||
@@ -1373,9 +1373,9 @@ static JSValue js_std_file_readAsString(JSContext *ctx, JSValueConst this_val,
|
||||
if (argc >= 1)
|
||||
max_size_val = argv[0];
|
||||
else
|
||||
max_size_val = JS_UNDEFINED;
|
||||
max_size_val = JS_NULL;
|
||||
max_size = (size_t)-1;
|
||||
if (!JS_IsUndefined(max_size_val)) {
|
||||
if (!JS_IsNull(max_size_val)) {
|
||||
if (JS_ToIndex(ctx, &max_size64, max_size_val))
|
||||
return JS_EXCEPTION;
|
||||
if (max_size64 < max_size)
|
||||
@@ -1469,7 +1469,7 @@ static JSValue js_std_urlGet(JSContext *ctx, JSValueConst this_val,
|
||||
char *buf;
|
||||
size_t i, len;
|
||||
int status;
|
||||
JSValue response = JS_UNDEFINED, ret_obj;
|
||||
JSValue response = JS_NULL, ret_obj;
|
||||
JSValueConst options_obj;
|
||||
FILE *f;
|
||||
BOOL binary_flag, full_flag;
|
||||
@@ -1736,7 +1736,7 @@ static JSValue js_os_open(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_EXCEPTION;
|
||||
if (JS_ToInt32(ctx, &flags, argv[1]))
|
||||
goto fail;
|
||||
if (argc >= 3 && !JS_IsUndefined(argv[2])) {
|
||||
if (argc >= 3 && !JS_IsNull(argv[2])) {
|
||||
if (JS_ToInt32(ctx, &mode, argv[2])) {
|
||||
fail:
|
||||
JS_FreeCString(ctx, filename);
|
||||
@@ -1866,7 +1866,7 @@ static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val,
|
||||
handle = (HANDLE)_get_osfhandle(1); /* corresponding output */
|
||||
SetConsoleMode(handle, ENABLE_PROCESSED_OUTPUT | ENABLE_WRAP_AT_EOL_OUTPUT | __ENABLE_VIRTUAL_TERMINAL_PROCESSING);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
#else
|
||||
static JSValue js_os_ttyGetWinSize(JSContext *ctx, JSValueConst this_val,
|
||||
@@ -1924,7 +1924,7 @@ static JSValue js_os_ttySetRaw(JSContext *ctx, JSValueConst this_val,
|
||||
tcsetattr(fd, TCSANOW, &tty);
|
||||
|
||||
atexit(term_exit);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
#endif /* !_WIN32 */
|
||||
@@ -2043,7 +2043,7 @@ static JSValue js_os_setReadHandler(JSContext *ctx, JSValueConst this_val,
|
||||
JS_FreeValue(ctx, rh->rw_func[magic]);
|
||||
rh->rw_func[magic] = JS_DupValue(ctx, func);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSOSSignalHandler *find_sh(JSThreadState *ts, int sig_num)
|
||||
@@ -2093,7 +2093,7 @@ static JSValue js_os_signal(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_ThrowRangeError(ctx, "invalid signal number");
|
||||
func = argv[1];
|
||||
/* func = null: SIG_DFL, func = undefined, SIG_IGN */
|
||||
if (JS_IsNull(func) || JS_IsUndefined(func)) {
|
||||
if (JS_IsNull(func) || JS_IsNull(func)) {
|
||||
sh = find_sh(ts, sig_num);
|
||||
if (sh) {
|
||||
free_sh(JS_GetRuntime(ctx), sh);
|
||||
@@ -2118,7 +2118,7 @@ static JSValue js_os_signal(JSContext *ctx, JSValueConst this_val,
|
||||
sh->func = JS_DupValue(ctx, func);
|
||||
signal(sig_num, os_signal_handler);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
@@ -2218,9 +2218,9 @@ static JSValue js_os_clearTimeout(JSContext *ctx, JSValueConst this_val,
|
||||
return JS_EXCEPTION;
|
||||
th = find_timer_by_id(ts, timer_id);
|
||||
if (!th)
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
free_timer(rt, th);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
/* return a promise */
|
||||
@@ -2261,7 +2261,7 @@ static void call_handler(JSContext *ctx, JSValueConst func)
|
||||
/* 'func' might be destroyed when calling itself (if it frees the
|
||||
handler), so must take extra care */
|
||||
func1 = JS_DupValue(ctx, func);
|
||||
ret = JS_Call(ctx, func1, JS_UNDEFINED, 0, NULL);
|
||||
ret = JS_Call(ctx, func1, JS_NULL, 0, NULL);
|
||||
JS_FreeValue(ctx, func1);
|
||||
if (JS_IsException(ret))
|
||||
js_std_dump_error(ctx);
|
||||
@@ -2386,7 +2386,7 @@ static int handle_posted_message(JSRuntime *rt, JSContext *ctx,
|
||||
/* 'func' might be destroyed when calling itself (if it frees the
|
||||
handler), so must take extra care */
|
||||
func = JS_DupValue(ctx, port->on_message_func);
|
||||
retval = JS_Call(ctx, func, JS_UNDEFINED, 1, (JSValueConst *)&obj);
|
||||
retval = JS_Call(ctx, func, JS_NULL, 1, (JSValueConst *)&obj);
|
||||
JS_FreeValue(ctx, obj);
|
||||
JS_FreeValue(ctx, func);
|
||||
if (JS_IsException(retval)) {
|
||||
@@ -2439,7 +2439,7 @@ static int js_os_poll(JSContext *ctx)
|
||||
JSValue func;
|
||||
/* the timer expired */
|
||||
func = th->func;
|
||||
th->func = JS_UNDEFINED;
|
||||
th->func = JS_NULL;
|
||||
free_timer(rt, th);
|
||||
call_handler(ctx, func);
|
||||
JS_FreeValue(ctx, func);
|
||||
@@ -2549,7 +2549,7 @@ static int js_os_poll(JSContext *ctx)
|
||||
JSValue func;
|
||||
/* the timer expired */
|
||||
func = th->func;
|
||||
th->func = JS_UNDEFINED;
|
||||
th->func = JS_NULL;
|
||||
free_timer(rt, th);
|
||||
call_handler(ctx, func);
|
||||
JS_FreeValue(ctx, func);
|
||||
@@ -3164,7 +3164,7 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
||||
val = JS_GetPropertyStr(ctx, options, "file");
|
||||
if (JS_IsException(val))
|
||||
goto exception;
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
file = JS_ToCString(ctx, val);
|
||||
JS_FreeValue(ctx, val);
|
||||
if (!file)
|
||||
@@ -3174,7 +3174,7 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
||||
val = JS_GetPropertyStr(ctx, options, "cwd");
|
||||
if (JS_IsException(val))
|
||||
goto exception;
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
cwd = JS_ToCString(ctx, val);
|
||||
JS_FreeValue(ctx, val);
|
||||
if (!cwd)
|
||||
@@ -3186,7 +3186,7 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
||||
val = JS_GetPropertyStr(ctx, options, std_name[i]);
|
||||
if (JS_IsException(val))
|
||||
goto exception;
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
int fd;
|
||||
ret = JS_ToInt32(ctx, &fd, val);
|
||||
JS_FreeValue(ctx, val);
|
||||
@@ -3199,7 +3199,7 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
||||
val = JS_GetPropertyStr(ctx, options, "env");
|
||||
if (JS_IsException(val))
|
||||
goto exception;
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
envp = build_envp(ctx, val);
|
||||
JS_FreeValue(ctx, val);
|
||||
if (!envp)
|
||||
@@ -3209,7 +3209,7 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
||||
val = JS_GetPropertyStr(ctx, options, "uid");
|
||||
if (JS_IsException(val))
|
||||
goto exception;
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
ret = JS_ToUint32(ctx, &uid, val);
|
||||
JS_FreeValue(ctx, val);
|
||||
if (ret)
|
||||
@@ -3219,7 +3219,7 @@ static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
|
||||
val = JS_GetPropertyStr(ctx, options, "gid");
|
||||
if (JS_IsException(val))
|
||||
goto exception;
|
||||
if (!JS_IsUndefined(val)) {
|
||||
if (!JS_IsNull(val)) {
|
||||
ret = JS_ToUint32(ctx, &gid, val);
|
||||
JS_FreeValue(ctx, val);
|
||||
if (ret)
|
||||
@@ -3619,11 +3619,11 @@ static JSValue js_worker_ctor_internal(JSContext *ctx, JSValueConst new_target,
|
||||
JSWorkerMessagePipe *recv_pipe,
|
||||
JSWorkerMessagePipe *send_pipe)
|
||||
{
|
||||
JSValue obj = JS_UNDEFINED, proto;
|
||||
JSValue obj = JS_NULL, proto;
|
||||
JSWorkerData *s;
|
||||
|
||||
/* create the object */
|
||||
if (JS_IsUndefined(new_target)) {
|
||||
if (JS_IsNull(new_target)) {
|
||||
proto = JS_GetClassProto(ctx, js_worker_class_id);
|
||||
} else {
|
||||
proto = JS_GetPropertyStr(ctx, new_target, "prototype");
|
||||
@@ -3654,7 +3654,7 @@ static JSValue js_worker_ctor(JSContext *ctx, JSValueConst new_target,
|
||||
WorkerFuncArgs *args = NULL;
|
||||
pthread_t tid;
|
||||
pthread_attr_t attr;
|
||||
JSValue obj = JS_UNDEFINED;
|
||||
JSValue obj = JS_NULL;
|
||||
int ret;
|
||||
const char *filename = NULL, *basename;
|
||||
JSAtom basename_atom;
|
||||
@@ -3785,7 +3785,7 @@ static JSValue js_worker_postMessage(JSContext *ctx, JSValueConst this_val,
|
||||
js_waker_signal(&ps->waker);
|
||||
list_add_tail(&msg->link, &ps->msg_queue);
|
||||
pthread_mutex_unlock(&ps->mutex);
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
fail:
|
||||
if (msg) {
|
||||
free(msg->data);
|
||||
@@ -3830,7 +3830,7 @@ static JSValue js_worker_set_onmessage(JSContext *ctx, JSValueConst this_val,
|
||||
JS_FreeValue(ctx, port->on_message_func);
|
||||
port->on_message_func = JS_DupValue(ctx, func);
|
||||
}
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_worker_get_onmessage(JSContext *ctx, JSValueConst this_val)
|
||||
@@ -3982,7 +3982,7 @@ static int js_os_init(JSContext *ctx, JSModuleDef *m)
|
||||
/* set 'Worker.parent' if necessary */
|
||||
if (ts->recv_pipe && ts->send_pipe) {
|
||||
JS_DefinePropertyValueStr(ctx, obj, "parent",
|
||||
js_worker_ctor_internal(ctx, JS_UNDEFINED, ts->recv_pipe, ts->send_pipe),
|
||||
js_worker_ctor_internal(ctx, JS_NULL, ts->recv_pipe, ts->send_pipe),
|
||||
JS_PROP_C_W_E);
|
||||
}
|
||||
|
||||
@@ -4032,7 +4032,7 @@ static JSValue js_print(JSContext *ctx, JSValueConst this_val,
|
||||
}
|
||||
}
|
||||
putchar('\n');
|
||||
return JS_UNDEFINED;
|
||||
return JS_NULL;
|
||||
}
|
||||
|
||||
static JSValue js_console_log(JSContext *ctx, JSValueConst this_val,
|
||||
|
||||
@@ -69,7 +69,6 @@ DEF( push_i32, 5, 0, 1, i32)
|
||||
DEF( push_const, 5, 0, 1, const)
|
||||
DEF( fclosure, 5, 0, 1, const) /* must follow push_const */
|
||||
DEF(push_atom_value, 5, 0, 1, atom)
|
||||
DEF( undefined, 1, 0, 1, none)
|
||||
DEF( null, 1, 0, 1, none)
|
||||
DEF( push_this, 1, 0, 1, none) /* only used at the start of a function */
|
||||
DEF( push_false, 1, 0, 1, none)
|
||||
@@ -232,7 +231,6 @@ DEF( strict_neq, 1, 2, 1, none)
|
||||
DEF( and, 1, 2, 1, none)
|
||||
DEF( xor, 1, 2, 1, none)
|
||||
DEF( or, 1, 2, 1, none)
|
||||
DEF(is_undefined_or_null, 1, 1, 1, none)
|
||||
DEF(push_bigint_i32, 5, 0, 1, i32)
|
||||
/* must be the last non short and non temporary opcode */
|
||||
DEF( nop, 1, 0, 0, none)
|
||||
@@ -333,9 +331,7 @@ DEF( call1, 1, 1, 1, npopx)
|
||||
DEF( call2, 1, 1, 1, npopx)
|
||||
DEF( call3, 1, 1, 1, npopx)
|
||||
|
||||
DEF( is_undefined, 1, 1, 1, none)
|
||||
DEF( is_null, 1, 1, 1, none)
|
||||
DEF(typeof_is_undefined, 1, 1, 1, none)
|
||||
DEF( typeof_is_function, 1, 1, 1, none)
|
||||
#endif
|
||||
|
||||
|
||||
1156
source/quickjs.c
1156
source/quickjs.c
File diff suppressed because it is too large
Load Diff
@@ -86,7 +86,7 @@ enum {
|
||||
JS_TAG_INT = 0,
|
||||
JS_TAG_BOOL = 1,
|
||||
JS_TAG_NULL = 2,
|
||||
JS_TAG_UNDEFINED = 3,
|
||||
// TAG_UNDEFINED
|
||||
JS_TAG_UNINITIALIZED = 4,
|
||||
JS_TAG_CATCH_OFFSET = 5,
|
||||
JS_TAG_EXCEPTION = 6,
|
||||
@@ -285,7 +285,6 @@ static inline JSValue __JS_NewShortBigInt(JSContext *ctx, int64_t d)
|
||||
|
||||
/* special values */
|
||||
#define JS_NULL JS_MKVAL(JS_TAG_NULL, 0)
|
||||
#define JS_UNDEFINED JS_MKVAL(JS_TAG_UNDEFINED, 0)
|
||||
#define JS_FALSE JS_MKVAL(JS_TAG_BOOL, 0)
|
||||
#define JS_TRUE JS_MKVAL(JS_TAG_BOOL, 1)
|
||||
#define JS_EXCEPTION JS_MKVAL(JS_TAG_EXCEPTION, 0)
|
||||
@@ -624,11 +623,6 @@ static inline JS_BOOL JS_IsNull(JSValueConst v)
|
||||
return JS_VALUE_GET_TAG(v) == JS_TAG_NULL;
|
||||
}
|
||||
|
||||
static inline JS_BOOL JS_IsUndefined(JSValueConst v)
|
||||
{
|
||||
return JS_VALUE_GET_TAG(v) == JS_TAG_UNDEFINED;
|
||||
}
|
||||
|
||||
static inline JS_BOOL JS_IsException(JSValueConst v)
|
||||
{
|
||||
return js_unlikely(JS_VALUE_GET_TAG(v) == JS_TAG_EXCEPTION);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
sprite *make_sprite(void)
|
||||
{
|
||||
sprite *sprite = calloc(sizeof(*sprite),1);
|
||||
sprite->image = JS_UNDEFINED;
|
||||
sprite->image = JS_NULL;
|
||||
return sprite;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ transform *make_transform()
|
||||
{
|
||||
transform *t = malloc(sizeof(transform));
|
||||
*t = model;
|
||||
t->jsparent = JS_UNDEFINED;
|
||||
t->change_hook = JS_UNDEFINED;
|
||||
t->jsparent = JS_NULL;
|
||||
t->change_hook = JS_NULL;
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ void transform_clean(JSContext *js, transform *t)
|
||||
transform_clean(js, t->children[i]);
|
||||
}
|
||||
|
||||
if (!JS_IsUndefined(t->change_hook)) {
|
||||
if (!JS_IsNull(t->change_hook)) {
|
||||
JSValue ret = JS_Call(js, t->change_hook, JS_DupValue(js,t->self), 0, NULL);
|
||||
JS_FreeValue(js,ret);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ test("Multiple stone calls are safe and stone.p works", function() {
|
||||
assertEqual(b.read_logical(0), true, "Blob data should remain intact");
|
||||
|
||||
// Verify blob.stone is not available
|
||||
assert(b.stone == undefined, "blob.stone should not be available as a method");
|
||||
assert(b.stone == null, "blob.stone should not be available as a method");
|
||||
});
|
||||
|
||||
// Test 16: Invalid constructor arguments
|
||||
|
||||
@@ -15,7 +15,7 @@ $_.receiver(tree => {
|
||||
|
||||
var job = parseq.par_all({
|
||||
comment: load_comment_from_api_requestor(tree.id),
|
||||
children: cb => parseq.par_all(child_reqs, /*time*/undefined, /*thr*/10)(cb)
|
||||
children: cb => parseq.par_all(child_reqs, /*time*/null, /*thr*/10)(cb)
|
||||
})
|
||||
|
||||
job((result, reason) => {
|
||||
|
||||
@@ -105,7 +105,7 @@ var testCases = [
|
||||
{ input: -1023, expectedHex: "ef7f" },
|
||||
|
||||
// Symbol tests
|
||||
{ input: undefined, expectedHex: "70" },
|
||||
{ input: null, expectedHex: "70" },
|
||||
{ input: false, expectedHex: "72" },
|
||||
{ input: true, expectedHex: "73" },
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ log.console("arr[4] =", arr[4]);
|
||||
|
||||
arr[0] = 15
|
||||
log.console(arr[0])
|
||||
log.console("arr[10] =", arr[10]); // Should be undefined
|
||||
log.console("arr[10] =", arr[10]); // Should be null
|
||||
|
||||
log.console("arr.length =", arr.length);
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ var camera = {
|
||||
fov:50,
|
||||
near_z: 0,
|
||||
far_z: 1000,
|
||||
surface: undefined,
|
||||
surface: null,
|
||||
viewport: {x:0,y:0,width:1,height:1},
|
||||
ortho:true,
|
||||
anchor:[0,0],
|
||||
@@ -82,7 +82,7 @@ var qr_rect_gutter = {
|
||||
width: qr_rect.width + gutter*2,
|
||||
height: qr_rect.height + gutter*2
|
||||
}
|
||||
blit_img.cpu.blit(qr_rect, bsurf, undefined, "nearest")
|
||||
blit_img.cpu.blit(qr_rect, bsurf, null, "nearest")
|
||||
|
||||
graphics.save_png("blit.png", blit_img.cpu.width, blit_img.cpu.height, blit_img.cpu.pixels(), blit_img.cpu.pitch)
|
||||
|
||||
@@ -122,11 +122,11 @@ function parse_data(res)
|
||||
function extract_qr_surface(surface)
|
||||
{
|
||||
var qr = graphics.make_surface([qr_rect_gutter.width, qr_rect_gutter.height])
|
||||
qr.blit(undefined, surface, qr_rect_gutter)
|
||||
qr.blit(null, surface, qr_rect_gutter)
|
||||
return qr
|
||||
}
|
||||
|
||||
var display = undefined
|
||||
var display = null
|
||||
|
||||
$_.receiver(e => {
|
||||
if (e.type == 'quit')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
log.console("Testing actor access to $_:");
|
||||
|
||||
// In an actor script, $_ should be available
|
||||
if (typeof $_ != 'undefined') {
|
||||
if (typeof $_ != 'null') {
|
||||
log.console("✓ Actor has access to $_");
|
||||
log.console(" $_.random is a", typeof $_.random);
|
||||
log.console(" $_.clock is a", typeof $_.clock);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Child actor test
|
||||
log.console("Child actor spawned");
|
||||
|
||||
if (typeof $_ != 'undefined') {
|
||||
if (typeof $_ != 'null') {
|
||||
log.console("✓ Child actor has access to $_");
|
||||
} else {
|
||||
log.error("✗ Child actor does NOT have access to $_");
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Test module - should NOT have access to $_
|
||||
|
||||
function test() {
|
||||
if (typeof $_ != 'undefined') {
|
||||
if (typeof $_ != 'null') {
|
||||
log.error("✗ Module incorrectly has access to $_!");
|
||||
return "ERROR: Module has $_ access";
|
||||
} else {
|
||||
|
||||
@@ -117,19 +117,19 @@ var str = "miskatonic"
|
||||
var substr_tests = [
|
||||
{from: 0, to: 3, expected: "mis"},
|
||||
{from: 3, to: 6, expected: "kat"},
|
||||
{from: 5, to: undefined, expected: "tonic"},
|
||||
{from: 5, to: null, expected: "tonic"},
|
||||
{from: 0, to: -4, expected: "miskat"},
|
||||
{from: -3, to: undefined, expected: "nic"},
|
||||
{from: -3, to: null, expected: "nic"},
|
||||
{from: 0, to: 0, expected: ""},
|
||||
{from: 10, to: undefined, expected: ""},
|
||||
{from: 11, to: undefined, expected: null},
|
||||
{from: 10, to: null, expected: ""},
|
||||
{from: 11, to: null, expected: null},
|
||||
{from: 2, to: 1, expected: null}
|
||||
]
|
||||
|
||||
for (var i = 0; i < substr_tests.length; i++) {
|
||||
var test = substr_tests[i]
|
||||
var result = test.to == undefined ? text(str, test.from) : text(str, test.from, test.to)
|
||||
var args = test.to == undefined ? test.from : test.from + ", " + test.to
|
||||
var result = test.to == null ? text(str, test.from) : text(str, test.from, test.to)
|
||||
var args = test.to == null ? test.from : test.from + ", " + test.to
|
||||
log.console("text('" + str + "', " + args + ") = " + (result == null ? "null" : "'" + result + "'"))
|
||||
log.console("Expected: " + (test.expected == null ? "null" : "'" + test.expected + "'"))
|
||||
log.console("Passed: " + (result == test.expected))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$_.unneeded(_ => {
|
||||
log.console("Unneded function fired.");
|
||||
$_.start(undefined, "unneeded")
|
||||
$_.start(null, "unneeded")
|
||||
}, 1);
|
||||
|
||||
@@ -124,7 +124,7 @@ var testCases = [
|
||||
{ input: Math.pow(2, 55) - 1, expectedHex: 'e0ffffffffffffff' },
|
||||
{ input: -Math.pow(2, 55), expectedHex: 'e000000000000000' },
|
||||
|
||||
{ input: undefined, expectedHex: '70' },
|
||||
{ input: null, expectedHex: '70' },
|
||||
{ input: false, expectedHex: '72' },
|
||||
{ input: true, expectedHex: '73' },
|
||||
|
||||
@@ -189,7 +189,7 @@ for (var t of testCases) {
|
||||
}
|
||||
|
||||
var dec = t.reviver ? wota.decode(enc, t.reviver) : wota.decode(enc)
|
||||
var exp = t.expected != undefined ? t.expected : t.input
|
||||
var exp = t.expected != null ? t.expected : t.input
|
||||
|
||||
var cmp = deep_compare(exp, dec)
|
||||
if (!cmp.passed) { passed = false; msgs.push(...cmp.messages) }
|
||||
|
||||
Reference in New Issue
Block a user