From ef86dd3ecf8327bc4d6ad6d43e1062cabe51e7aa Mon Sep 17 00:00:00 2001 From: John Alanbrook Date: Tue, 3 Jun 2025 23:58:44 -0500 Subject: [PATCH] remove some docstrings to save per actor memory --- prosperon/controller.cm | 1 - prosperon/main.ce | 2 - scripts/base.cm | 1266 --------------------------------------- scripts/clean.ce | 1 - scripts/engine.cm | 19 +- scripts/text.cm | 9 - scripts/util.cm | 97 +-- source/cell.c | 5 +- source/cell.h | 1 - source/jsffi.c | 17 - source/qjs_js.c | 2 +- 11 files changed, 13 insertions(+), 1407 deletions(-) diff --git a/prosperon/controller.cm b/prosperon/controller.cm index 33e7ebb4..7bcec6ab 100644 --- a/prosperon/controller.cm +++ b/prosperon/controller.cm @@ -1,5 +1,4 @@ var input = use('input') -var util = use('util') var downkeys = {}; diff --git a/prosperon/main.ce b/prosperon/main.ce index 8d99e402..b07ee356 100644 --- a/prosperon/main.ce +++ b/prosperon/main.ce @@ -100,8 +100,6 @@ var graphics var gameactor - - var last = os.now() // FPS tracking diff --git a/scripts/base.cm b/scripts/base.cm index 3e829cb7..d33424c6 100644 --- a/scripts/base.cm +++ b/scripts/base.cm @@ -393,1269 +393,3 @@ of itself to the end. For example, [1,2,3] -> [1,2,3,2,1]. If the array has leng :return: A new "mirrored" array. `; - - - -/// doc for builtin string -(String.prototype.at)[cell.DOC] = `Return the character (or surrogate pair) at the specified index, with support -for negative indices (counting from the end). If the index is out of range, -returns undefined. - -:param index: The position of the character to return (can be negative). -:return: A string of length 1 representing the character, or undefined if out of range. -`; - -(String.prototype.charCodeAt)[cell.DOC] = `Return a number indicating the UTF-16 code unit value at the given index. -If the index is out of range, returns NaN. - -:param index: An integer between 0 and string length - 1. -:return: An integer in the range [0, 65535] or NaN if out of range. -`; - -(String.prototype.charAt)[cell.DOC] = `Return a string consisting of the single UTF-16 code unit at the given index. -If the index is out of range, returns an empty string. - -:param index: The zero-based index of the desired character. -:return: The single-character string at the specified index, or '' if out of range. -`; - -(String.prototype.concat)[cell.DOC] = `Concatenate the provided string arguments to the current string and return a -new string. - -:param stringN: One or more strings to concatenate. -:return: A new string formed by joining the caller with the provided arguments. -`; - -(String.prototype.codePointAt)[cell.DOC] = `Return a non-negative integer that is the Unicode code point value at the -given position. Supports code points above 0xFFFF. Returns undefined if index -is out of range. - -:param position: The index in the string (can be surrogate pairs). -:return: The code point value, or undefined if out of range. -`; - -(String.prototype.isWellFormed)[cell.DOC] = `Return a boolean indicating whether the string is valid Unicode. -If it contains unpaired surrogate code points, return false. - -:return: True if the string is well-formed UTF-16, otherwise false. -`; - -(String.prototype.toWellFormed)[cell.DOC] = `Return a new string in which any unpaired surrogate code points have been -replaced by the Unicode replacement character U+FFFD. - -:return: A well-formed UTF-16 version of the string. -`; - -(String.prototype.indexOf)[cell.DOC] = `Return the zero-based index of the first occurrence of 'searchValue' in the -string, starting at 'fromIndex'. If not found, return -1. - -:param searchValue: The substring to search for. -:param fromIndex: The index at which to begin searching (default 0). -:return: The index of the first match, or -1 if not found. -`; - -(String.prototype.lastIndexOf)[cell.DOC] = `Return the zero-based index of the last occurrence of 'searchValue' in the -string, searching backwards from 'fromIndex'. If not found, return -1. - -:param searchValue: The substring to search for. -:param fromIndex: The index at which to begin the backward search (defaults to string length - 1). -:return: The index of the last match, or -1 if not found. -`; - -(String.prototype.includes)[cell.DOC] = `Return a boolean indicating whether 'searchString' appears within this string. -An optional position can be provided to start searching. - -:param searchString: The substring to search for. -:param position: The position from which to begin searching (default 0). -:return: True if the substring is found, otherwise false. -`; - -(String.prototype.endsWith)[cell.DOC] = `Return a boolean indicating whether the string ends with 'searchString'. -An optional 'length' can be provided to treat the string as if it were only -that long. - -:param searchString: The substring to search for at the end. -:param length: An optional length to truncate the string before testing. -:return: True if the string ends with 'searchString', otherwise false. -`; - -(String.prototype.startsWith)[cell.DOC] = `Return a boolean indicating whether the string begins with 'searchString'. -An optional position can be provided to start checking at that index. - -:param searchString: The substring to search for at the start. -:param position: The index in the string to start searching (default 0). -:return: True if the string starts with 'searchString', otherwise false. -`; - -(String.prototype.match)[cell.DOC] = `Use a regular expression to match the string. If 'regexp' is not a RegExp, it -is converted to one. Return an array of matches or null if none found. - -:param regexp: The pattern to match (RegExp or string). -:return: An array of matches or null. -`; - -(String.prototype.matchAll)[cell.DOC] = `Return an iterator of all RegExp match objects found within the string. -If 'regexp' is not a global or sticky RegExp, a TypeError is thrown. - -:param regexp: The global/sticky RegExp to match over this string. -:return: An iterator of match arrays. -`; - -(String.prototype.search)[cell.DOC] = `Use a regular expression to search for a match within the string. Return the -index of the first match, or -1 if no match is found. - -:param regexp: A RegExp or string. If a string, it is converted to RegExp. -:return: The index of the first match, or -1 if not found. -`; - -(String.prototype.split)[cell.DOC] = `Split the string into an array of substrings using 'separator' (RegExp or -string). An optional 'limit' can be provided to limit the number of splits. - -:param separator: A string or RegExp used to divide the string. -:param limit: Maximum number of splits to include in the result array. -:return: An array of the split substrings. -`; - -(String.prototype.substring)[cell.DOC] = `Return the substring between 'start' and 'end'. Indices outside the range -are clamped. If 'end' < 'start', they swap. - -:param start: The starting index (0-based). -:param end: The ending index (exclusive). -:return: The extracted substring. -`; - -(String.prototype.substr)[cell.DOC] = `Return the substring from 'start' for 'length' characters. Negative 'start' -counts from the end. This method is deprecated but still supported in many -engines. - -:param start: The starting index. -:param length: The number of characters to extract. -:return: The extracted substring. -`; - -(String.prototype.slice)[cell.DOC] = `Extract a section of the string from 'start' up to (but not including) 'end', -and return it as a new string. Supports negative indices. - -:param start: The starting index. Negative values count from the end. -:param end: The ending index (exclusive). Negative values count from the end. -:return: The extracted slice. -`; - -(String.prototype.repeat)[cell.DOC] = `Construct and return a new string which contains the specified number of copies -of the calling string, concatenated together. - -:param count: The number of times to repeat the string (must be >= 0). -:return: A new repeated string. -`; - -(String.prototype.replace)[cell.DOC] = `Return a new string where the first match (or all matches if 'searchValue' -is a global RegExp) of 'searchValue' is replaced by 'replaceValue'. -If 'searchValue' is a string, only the first occurrence is replaced. - -:param searchValue: A string or RegExp to match. -:param replaceValue: The replacement string or function. -:return: A new string with the matched substring(s) replaced. -`; - -(String.prototype.replaceAll)[cell.DOC] = `Return a new string where all (non-overlapping) occurrences of 'searchValue' -are replaced by 'replaceValue'. If 'searchValue' is a string, each exact match -is replaced. - -:param searchValue: A string or RegExp with the 'g' flag. -:param replaceValue: The replacement string or function. -:return: A new string with all matches replaced. -`; - -(String.prototype.padEnd)[cell.DOC] = `Pad the string from the end with the given 'padString' so its length reaches -'maxLength'. The result is a new string. - -:param maxLength: The desired length of the resulting string. -:param padString: The string to pad with (default ' '). -:return: A new string padded at the end. -`; - -(String.prototype.padStart)[cell.DOC] = `Pad the string from the start with the given 'padString' so its length reaches -'maxLength'. The result is a new string. - -:param maxLength: The desired length of the resulting string. -:param padString: The string to pad with (default ' '). -:return: A new string padded at the start. -`; - -(String.prototype.trim)[cell.DOC] = `Return a new string with whitespace trimmed from the start and end of this -string. - -:return: The trimmed string. -`; - -(String.prototype.trimEnd)[cell.DOC] = `Return a new string with trailing whitespace removed. Alias: trimRight(). - -:return: The string without trailing whitespace. -`; - -(String.prototype.trimRight)[cell.DOC] = `Alias for trimEnd(). Remove trailing whitespace from the string. - -:return: The string without trailing whitespace. -`; - -(String.prototype.trimStart)[cell.DOC] = `Return a new string with leading whitespace removed. Alias: trimLeft(). - -:return: The string without leading whitespace. -`; - -(String.prototype.trimLeft)[cell.DOC] = `Alias for trimStart(). Remove leading whitespace from the string. - -:return: The string without leading whitespace. -`; - -(String.prototype.toString)[cell.DOC] = `Return a string representing the specified object (itself). Usually called -implicitly. Overrides Object.prototype.toString. - -:return: The string itself. -`; - -(String.prototype.valueOf)[cell.DOC] = `Return the primitive string value of this String object. - -:return: The primitive string value. -`; - -(String.prototype.__quote)[cell.DOC] = `(Non-standard) Return a quoted representation of the string, typically for -debug or serialization. Implementation details may vary. - -:return: A quoted version of the string. -`; - -(String.prototype.toLowerCase)[cell.DOC] = `Return a new string with all alphabetic characters converted to lowercase. - -:return: The lowercase version of this string. -`; - -(String.prototype.toUpperCase)[cell.DOC] = `Return a new string with all alphabetic characters converted to uppercase. - -:return: The uppercase version of this string. -`; - -(String.prototype.toLocaleLowerCase)[cell.DOC] = `Return a locale-aware lowercase version of this string, using the host's -current locale or the specified locale if supported. - -:return: The locale-sensitive lowercase string. -`; - -(String.prototype.toLocaleUpperCase)[cell.DOC] = `Return a locale-aware uppercase version of this string, using the host's -current locale or the specified locale if supported. - -:return: The locale-sensitive uppercase string. -`; - -(String.prototype.anchor)[cell.DOC] = `Return a string representing an HTML element with a 'name' attribute -set to the current string. - -:param name: The name attribute for the anchor. -:return: An HTML ... string. -`; - -(String.prototype.big)[cell.DOC] = `Return a string representing an HTML element containing the current -string. - -:return: An HTML ... string. -`; - -(String.prototype.blink)[cell.DOC] = `Return a string representing an HTML element containing the current -string (historical, not recommended). - -:return: An HTML ... string. -`; - -(String.prototype.bold)[cell.DOC] = `Return a string representing an HTML element containing the current -string in bold. - -:return: An HTML ... string. -`; - -(String.prototype.fixed)[cell.DOC] = `Return a string representing an HTML element containing the current -string in fixed-width font. - -:return: An HTML ... string. -`; - -(String.prototype.fontcolor)[cell.DOC] = `Return a string representing an HTML element with a 'color' attribute, -containing the current string. - -:param color: The color value for the 'font' element. -:return: An HTML ... string. -`; - -(String.prototype.fontsize)[cell.DOC] = `Return a string representing an HTML element with a 'size' attribute, -containing the current string. - -:param size: The size value for the 'font' element. -:return: An HTML ... string. -`; - -(String.prototype.italics)[cell.DOC] = `Return a string representing an HTML element containing the current -string in italics. - -:return: An HTML ... string. -`; - -(String.prototype.link)[cell.DOC] = `Return a string representing an HTML element with an 'href' attribute set -to the current string. - -:param url: The URL for the 'href' attribute. -:return: An HTML ... string. -`; - -(String.prototype.small)[cell.DOC] = `Return a string representing an HTML element containing the current -string. - -:return: An HTML ... string. -`; - -(String.prototype.strike)[cell.DOC] = `Return a string representing an HTML element containing the current -string with strike-through. - -:return: An HTML ... string. -`; - -(String.prototype.sub)[cell.DOC] = `Return a string representing an HTML element containing the current -string as subscript. - -:return: An HTML ... string. -`; - -(String.prototype.sup)[cell.DOC] = `Return a string representing an HTML element containing the current -string as superscript. - -:return: An HTML ... string. -`; - - -// builtin array -(Array.prototype.at)[cell.DOC] = `Return the item at index 'index', supporting negative indices to count from -the end. If 'index' is out of range, returns undefined. - -:param index: The index of the element to return (can be negative). -:return: The element at the given index, or undefined. -`; - -(Array.prototype.with)[cell.DOC] = `Return a shallow copy of the array, but with the element at 'index' replaced -by 'value'. If 'index' is negative, it counts from the end. Throws if out of range. - -:param index: The zero-based index (can be negative) to replace. -:param value: The new value for the specified position. -:return: A new array with the updated element. -`; - -(Array.prototype.concat)[cell.DOC] = `Return a new array that is the result of concatenating this array with -any additional arrays or values provided. - -:param items: One or more arrays or values to concatenate. -:return: A new array with the items appended. -`; - -(Array.prototype.every)[cell.DOC] = `Return true if the provided callback function returns a truthy value for -every element in the array; otherwise false. - -:param callback: A function(element, index, array) => boolean. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: True if all elements pass the test, otherwise false. -`; - -(Array.prototype.some)[cell.DOC] = `Return true if the provided callback function returns a truthy value for at -least one element in the array; otherwise false. - -:param callback: A function(element, index, array) => boolean. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: True if at least one element passes the test, otherwise false. -`; - -(Array.prototype.forEach)[cell.DOC] = `Call the provided callback function once for each element in the array. -Does not produce a return value. - -:param callback: A function(element, index, array). -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: None -`; - -(Array.prototype.map)[cell.DOC] = `Create a new array with the results of calling a provided callback function -on every element in this array. - -:param callback: A function(element, index, array) => newElement. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: A new array of transformed elements. -`; - -(Array.prototype.filter)[cell.DOC] = `Create a new array containing all elements for which the provided callback -function returns a truthy value. - -:param callback: A function(element, index, array) => boolean. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: A new array of elements that passed the test. -`; - -(Array.prototype.reduce)[cell.DOC] = `Apply a callback function against an accumulator and each element in the -array (from left to right) to reduce it to a single value. - -:param callback: A function(accumulator, element, index, array) => newAccumulator. -:param initialValue: Optional. The initial value for the accumulator. -:return: The single resulting value. -`; - -(Array.prototype.reduceRight)[cell.DOC] = `Similar to reduce(), except it processes elements from right to left. - -:param callback: A function(accumulator, element, index, array) => newAccumulator. -:param initialValue: Optional. The initial value for the accumulator. -:return: The single resulting value. -`; - -(Array.prototype.fill)[cell.DOC] = `Fill the array with a static value from 'start' index up to (but not including) -'end' index. Modifies the original array. - -:param value: The value to fill. -:param start: The starting index (default 0). -:param end: The ending index (default array.length). -:return: The modified array (with filled values). -`; - -(Array.prototype.find)[cell.DOC] = `Return the first element in the array that satisfies the provided callback -function. If none is found, return undefined. - -:param callback: A function(element, index, array) => boolean. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: The first matching element, or undefined if not found. -`; - -(Array.prototype.findIndex)[cell.DOC] = `Return the index of the first element in the array that satisfies the -provided callback function. If none is found, return -1. - -:param callback: A function(element, index, array) => boolean. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: The index of the first matching element, or -1 if not found. -`; - -(Array.prototype.findLast)[cell.DOC] = `Return the last element in the array that satisfies the provided callback -function, searching from right to left. If none is found, return undefined. - -:param callback: A function(element, index, array) => boolean. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: The last matching element, or undefined if not found. -`; - -(Array.prototype.findLastIndex)[cell.DOC] = `Return the index of the last element in the array that satisfies the -provided callback function, searching from right to left. If none is found, -return -1. - -:param callback: A function(element, index, array) => boolean. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: The index of the last matching element, or -1 if not found. -`; - -(Array.prototype.indexOf)[cell.DOC] = `Return the first index at which a given element can be found. If not present, -return -1. - -:param searchElement: The item to locate in the array. -:param fromIndex: The index at which to start searching (default 0). -:return: The index of the found element, or -1 if not found. -`; - -(Array.prototype.lastIndexOf)[cell.DOC] = `Return the last index at which a given element can be found, or -1 if not -present. Searches backward from 'fromIndex'. - -:param searchElement: The item to locate in the array. -:param fromIndex: The index at which to start searching backward (default array.length - 1). -:return: The last index of the found element, or -1 if not found. -`; - -(Array.prototype.includes)[cell.DOC] = `Return a boolean indicating whether the array contains the given element, -comparing elements using the SameValueZero algorithm. - -:param searchElement: The value to search for. -:param fromIndex: The position in the array to start searching (default 0). -:return: True if the element is found, otherwise false. -`; - -(Array.prototype.join)[cell.DOC] = `Join all elements of the array into a string, separated by 'separator'. - -:param separator: The delimiter string to separate elements (default ','). -:return: A string of array elements joined by the separator. -`; - -(Array.prototype.toString)[cell.DOC] = `Return a string representing the elements of the array, separated by commas. -Overrides Object.prototype.toString. - -:return: A comma-separated string of array elements. -`; - -(Array.prototype.toLocaleString)[cell.DOC] = `Return a localized string representing the array and its elements, calling -each element's toLocaleString if available. - -:return: A locale-sensitive, comma-separated string of array elements. -`; - -(Array.prototype.pop)[cell.DOC] = `Remove the last element from the array and return it. This changes the length -of the array. - -:return: The removed element, or undefined if the array is empty. -`; - -(Array.prototype.push)[cell.DOC] = `Append one or more elements to the end of the array and return the new length -of the array. - -:param items: One or more items to append. -:return: The new length of the array. -`; - -(Array.prototype.shift)[cell.DOC] = `Remove the first element from the array and return it. This changes the length -of the array. - -:return: The removed element, or undefined if the array is empty. -`; - -(Array.prototype.unshift)[cell.DOC] = `Insert one or more elements at the start of the array and return the new -length of the array. - -:param items: One or more elements to insert at the start. -:return: The new length of the array. -`; - -(Array.prototype.reverse)[cell.DOC] = `Reverse the elements of the array in place and return the modified array. - -:return: The reversed array. -`; - -(Array.prototype.toReversed)[cell.DOC] = `Return a shallow copy of the array in reverse order, without modifying the original array. - -:return: A new reversed array. -`; - -(Array.prototype.sort)[cell.DOC] = `Sort the array in place, returning it. By default, sorts elements as strings in ascending order. An optional compareFunction may be used for custom sorting. - -:param compareFunction: A function(a, b) => number, defining sort order. -:return: The sorted array. -`; - -(Array.prototype.toSorted)[cell.DOC] = `Return a shallow copy of the array, sorted according to the optional compare -function, without modifying the original array. - -:param compareFunction: A function(a, b) => number, defining sort order. -:return: A new sorted array. -`; - -(Array.prototype.slice)[cell.DOC] = `Return a shallow copy of a portion of the array into a new array object, selected from 'start' to 'end' (end not included). - -:param start: The beginning index (0-based). Negative values count from the end. -:param end: The end index (exclusive). Negative values count from the end. -:return: A new array containing the extracted elements. -`; - -(Array.prototype.splice)[cell.DOC] = `Change the contents of the array by removing or replacing existing elements and/or adding new elements in place. Returns an array of removed elements. - -:param start: The index at which to start changing the array. -:param deleteCount: Number of elements to remove. -:param items: Elements to add in place of the removed elements. -:return: An array containing the removed elements (if any). -`; - -(Array.prototype.toSpliced)[cell.DOC] = `Return a shallow copy of the array, with a splice-like operation applied at 'start' removing 'deleteCount' elements and adding 'items'. Does not mutate the original array. - -:param start: The index at which to start the splice operation. -:param deleteCount: Number of elements to remove. -:param items: Elements to add in place of the removed elements. -:return: A new array with the splice applied. -`; - -(Array.prototype.copyWithin)[cell.DOC] = `Copy a sequence of array elements within the array, overwriting existing values. This operation is performed in place and returns the modified array. - -:param target: The index at which to copy the sequence to. -:param start: The beginning index of the sequence to copy. -:param end: The end index (exclusive) of the sequence to copy (default array.length). -:return: The modified array. -`; - -(Array.prototype.flatMap)[cell.DOC] = `Return a new array formed by applying a callback function to each element and then flattening the result by one level. - -:param callback: A function(element, index, array) => array or value. -:param thisArg: Optional. A value to use as 'this' within the callback. -:return: A new array with the flattened results. -`; - -(Array.prototype.flat)[cell.DOC] = `Return a new array with all sub-array elements concatenated into it recursively up to the specified depth. - -:param depth: The maximum depth to flatten (default 1). -:return: A new flattened array. -`; - -(Array.prototype.values)[cell.DOC] = `Return a new Array Iterator object that contains the values for each index in the array. - -:return: An iterator over the array's elements. -`; - -(Array.prototype.keys)[cell.DOC] = `Return a new Array Iterator object that contains the keys (indexes) for each index in the array. - -:return: An iterator over the array's indices. -`; - -(Array.prototype.entries)[cell.DOC] = `Return a new Array Iterator object that contains key/value pairs for each index in the array. Each entry is [index, value]. - -:return: An iterator over [index, value] pairs. -`; - -(Array.prototype.add)[cell.DOC] = `Non-standard. Add corresponding elements of the current array and 'other' element-wise, returning a new array. Behavior depends on data types. - -:param other: Another array or scalar to add to each element. -:return: A new array with element-wise sum results. -`; - -(Array.prototype.sub)[cell.DOC] = `Non-standard. Subtract corresponding elements of 'other' from the current array element-wise, returning a new array. Behavior depends on data types. - -:param other: Another array or scalar to subtract from each element. -:return: A new array with element-wise difference results. -`; - -(Array.prototype.div)[cell.DOC] = `Non-standard. Divide each element of the current array by the corresponding element of 'other' (or a scalar) element-wise, returning a new array. Behavior depends on data types. - -:param other: Another array or scalar for the division. -:return: A new array with element-wise division results. -`; - -// Object -(Object.prototype.toString)[cell.DOC] = `Return a string representing this object. By default, it returns a string of the form '[object ]', where is the object's class. - -:return: A string that describes the object. -`; - -(Object.prototype.toLocaleString)[cell.DOC] = `Return a localized string representation of this object, calling toString() by default or a locale-specific override if defined. - -:return: A locale-sensitive string representation of the object. -`; - -(Object.prototype.valueOf)[cell.DOC] = `Return the primitive value of this object if one exists. Typically, an object returns itself, while a wrapped type (e.g. Number, String) may return the underlying primitive value. - -:return: The primitive value of the object, or the object itself. -`; - -(Object.prototype.hasOwnProperty)[cell.DOC] = `Return a boolean indicating whether the object has a property with the specified name (key) as its own direct property, as opposed to inheriting it. It does not check the prototype chain. - -:param prop: The name or Symbol of the property to test. -:return: True if the property is found directly on the object, otherwise false. -`; - -(Object.prototype.isPrototypeOf)[cell.DOC] = `Return true if the object appears anywhere in the prototype chain of the specified object, otherwise false. - -:param obj: The object whose prototype chain will be checked. -:return: True if this object is in 'obj's prototype chain, otherwise false. -`; - -(Object.prototype.propertyIsEnumerable)[cell.DOC] = `Return a boolean indicating whether the specified property is enumerable, i.e., whether it shows up in a for...in loop or Object.keys() on the object. - -:param prop: The name or Symbol of the property to test. -:return: True if the property is found and enumerable, otherwise false. -`; - -(Object.create)[cell.DOC] = `Create a new object, using the specified prototype object and optional property descriptors. - -:param proto: The object to be used as the prototype. -:param propertiesObject: Optional. An object specifying properties to be added. -:return: A new object with the given prototype and properties. -`; - -(Object.getPrototypeOf)[cell.DOC] = `Return the prototype of the specified object. If no prototype is found (e.g. the object has null as its prototype), return null. - -:param obj: The object whose prototype is to be returned. -:return: The prototype of 'obj', or null. -`; - -(Object.setPrototypeOf)[cell.DOC] = `Set the prototype of the specified object to the provided value. Throws a TypeError if the object is non-extensible and the prototype is changed. - -:param obj: The object whose prototype is set. -:param proto: The new prototype or null. -:return: The object 'obj' after setting its prototype. -`; - -(Object.defineProperty)[cell.DOC] = `Define or modify a property on an object using a property descriptor, returning the object. Throws a TypeError if the descriptor is invalid. - -:param obj: The object on which to define or modify a property. -:param prop: The name or Symbol of the property. -:param descriptor: A property descriptor object (e.g., {value, writable, get, set, ...}). -:return: The object with the newly defined or updated property. -`; - -(Object.defineProperties)[cell.DOC] = `Define new or modify existing properties on an object, given an object of property descriptors. Returns the modified object. - -:param obj: The object on which to define or modify properties. -:param props: An object mapping property names to property descriptors. -:return: The modified object. -`; - -(Object.getOwnPropertyNames)[cell.DOC] = `Return an array of all own (non-Symbol) property names found directly on the given object, in the same order as a for...in loop would return. - -:param obj: The object whose own property names are returned. -:return: An array of strings that correspond to the properties. -`; - -(Object.getOwnPropertySymbols)[cell.DOC] = `Return an array of all own Symbol properties found directly on the given object. - -:param obj: The object to retrieve Symbol keys from. -:return: An array of Symbol keys. -`; - -(Object.groupBy)[cell.DOC] = `Non-standard / Proposed. Group the own properties of an object according to the return value of a grouping function. Typically returns a new object whose keys are the group identifiers. - -:param obj: The object to group. -:param fn: A function(key, value) => groupingKey, applied to each property. -:return: An object where properties are grouped by the returned keys. -`; - -(Object.keys)[cell.DOC] = `Return an array of the object's own enumerable (non-Symbol) property names, in the same order that a normal loop would. - -:param obj: The object whose property names are to be returned. -:return: An array of property names. -`; - -(Object.values)[cell.DOC] = `Return an array of the object's own enumerable (non-Symbol) property values, in the same order as Object.keys(). - -:param obj: The object whose property values are to be returned. -:return: An array of property values. -`; - -(Object.entries)[cell.DOC] = `Return an array of [key, value] pairs for the object's own enumerable (non-Symbol) properties, in the same order as Object.keys(). - -:param obj: The object whose [key, value] pairs are to be returned. -:return: An array of [key, value] pairs. -`; - -(Object.isExtensible)[cell.DOC] = `Return a boolean indicating whether new properties can be added to the specified object. - -:param obj: The object to test. -:return: True if the object is extensible, otherwise false. -`; - -(Object.preventExtensions)[cell.DOC] = `Prevent new properties from ever being added to an object. Existing properties are not affected. - -:param obj: The object to mark as non-extensible. -:return: The non-extensible object. -`; - -(Object.getOwnPropertyDescriptor)[cell.DOC] = `Return the property descriptor for a named property on the specified object, if it exists, otherwise undefined. - -:param obj: The object in which to look for the property. -:param prop: The name or Symbol of the property. -:return: The property descriptor, or undefined if not found. -`; - -(Object.getOwnPropertyDescriptors)[cell.DOC] = `Return an object containing all own property descriptors for the given object, keyed by property names (and Symbols). - -:param obj: The object to retrieve property descriptors from. -:return: An object mapping property keys to property descriptors. -`; - -(Object.is)[cell.DOC] = `Compare two values for strict equality, like '===' but without special treatment for +0 and -0, and treating NaN as equal to NaN. - -:param value1: A value to compare. -:param value2: Another value to compare. -:return: True if both values are the same, otherwise false. -`; - -(Object.assign)[cell.DOC] = `Copy all enumerable own properties from one or more source objects to a target object, returning the modified target. - -:param target: The object to receive properties. -:param sources: One or more objects containing properties to copy. -:return: The updated target object. -`; - -(Object.seal)[cell.DOC] = `Seal an object, preventing new properties from being added and marking all existing properties as non-configurable. Values of present properties can still be changed if they are writable. - -:param obj: The object to seal. -:return: The sealed object. -`; - -(Object.freeze)[cell.DOC] = `Freeze an object, preventing new properties from being added, existing properties from being removed, or current properties from being changed (to the extent permitted by property descriptors). - -:param obj: The object to freeze. -:return: The frozen object. -`; - -(Object.isSealed)[cell.DOC] = `Check if an object is sealed. A sealed object has no configurable properties and is non-extensible. - -:param obj: The object to test. -:return: True if the object is sealed, otherwise false. -`; - -(Object.isFrozen)[cell.DOC] = `Check if an object is frozen. A frozen object is sealed and all data properties are non-writable. - -:param obj: The object to test. -:return: True if the object is frozen, otherwise false. -`; - -(Object.fromEntries)[cell.DOC] = `Transform a list of key-value pairs into an object. The iterable argument should yield pairs [key, value], which become properties on the resulting object. - -:param entries: An iterable of [key, value] pairs. -:return: A new object formed from the given entries. -`; - -(Object.hasOwn)[cell.DOC] = `Return a boolean indicating whether the specified property exists on the object as a direct own property (similar to hasOwnProperty, but directly on Object). - -:param obj: The object on which to check the property. -:param prop: The name or Symbol of the property to check. -:return: True if the property is found on 'obj', otherwise false. -`; - -(Object.id)[cell.DOC] = `Non-standard. Return a unique identifier for the given object, assigning one if necessary. The same object will always yield the same ID. - -:param obj: The object to retrieve or assign a unique ID. -:return: A unique identifier (string or number) associated with the object. -`; - -(String.fromCharCode)[cell.DOC] = `Return a string created from the specified sequence of UTF-16 code units. -Each argument is treated as a code unit in the range [0, 65535]. - -:param codeUnits: A series of numbers representing UTF-16 code units. -:return: A string constructed by mapping each code unit to a character. -`; - -(String.fromCodePoint)[cell.DOC] = `Return a string created from the specified sequence of code points, -including those above U+FFFF (which will become surrogate pairs). -Throws a RangeError for invalid code points. - -:param codePoints: A series of numbers representing Unicode code points. -:return: A string constructed from the given code points. -`; - -(String.raw)[cell.DOC] = `A tag function of template literals that returns a raw where escape sequences (e.g., '\\n', '\\u00A9') are not processed. -Commonly used to retrieve the unprocessed text of a template. - -:param template: A template literal, or an object with a 'raw' property. -:param substitutions: Additional values to substitute (if any). -:return: The combined raw string from the template. -`; - -(Math.min)[cell.DOC] = `Return the smallest of the zero or more given numbers. If no arguments are provided, the result is Infinity. If any value is NaN, the result is NaN. - -:param values: One or more numeric values. -:return: The smallest numeric value, Infinity if no arguments, or NaN if any argument cannot be converted to a number. -`; - -(Math.max)[cell.DOC] = `Return the largest of the zero or more given numbers. If no arguments are provided, the result is -Infinity. If any value is NaN, the result is NaN. - -:param values: One or more numeric values. -:return: The largest numeric value, -Infinity if no arguments, or NaN if any argument cannot be converted to a number. -`; - -(Math.abs)[cell.DOC] = `Return the absolute value of the given number. For example, -5 becomes 5. - -:param x: A numeric value. -:return: The absolute value of x. -`; - -(Math.floor)[cell.DOC] = `Return the greatest integer less than or equal to x, effectively rounding down to the nearest integer. - -:param x: A numeric value. -:return: The largest integer <= x. -`; - -(Math.ceil)[cell.DOC] = `Return the smallest integer greater than or equal to x, effectively rounding up to the nearest integer. - -:param x: A numeric value. -:return: The smallest integer >= x. -`; - -(Math.round)[cell.DOC] = `Return x rounded to the nearest integer. If the fractional portion is 0.5 or -greater, rounds up; otherwise, rounds down. Ties away from zero in modern ECMAScript. - -:param x: A numeric value. -:return: x rounded to the nearest integer. -`; - -(Math.sqrt)[cell.DOC] = `Return the positive square root of x. If x is negative, the result is NaN. - -:param x: A non-negative numeric value. -:return: The positive square root of x, or NaN if x is negative. -`; - -(Math.acos)[cell.DOC] = `Return the arccosine (in radians) of x, in the range [0, π]. If x is outside -the range [-1, 1], the result is NaN. - -:param x: A numeric value in [-1, 1]. -:return: The arccosine of x in radians, or NaN if out of range. -`; - -(Math.asin)[cell.DOC] = `Return the arcsine (in radians) of x, in the range [-π/2, π/2]. If x is -outside [-1, 1], the result is NaN. - -:param x: A numeric value in [-1, 1]. -:return: The arcsine of x in radians, or NaN if out of range. -`; - -(Math.atan)[cell.DOC] = `Return the arctangent (in radians) of x, in the range [-π/2, π/2]. - -:param x: A numeric value. -:return: The arctangent of x in radians. -`; - -(Math.atan2)[cell.DOC] = `Return the arctangent of the quotient of its arguments (y / x), in the range -(-π, π]. This takes into account the signs of both x and y to determine -the correct quadrant. - -:param y: The y coordinate. -:param x: The x coordinate. -:return: The angle in radians between the positive x-axis and the point (x, y). -`; - -(Math.cos)[cell.DOC] = `Return the cosine of x, where x is in radians. - -:param x: A numeric value in radians. -:return: The cosine of x, in the range [-1, 1]. -`; - -(Math.exp)[cell.DOC] = `Return e^x, where e is Euler's number (approximately 2.71828). - -:param x: A numeric exponent. -:return: The value of e raised to x. -`; - -(Math.log)[cell.DOC] = `Return the natural logarithm (base e) of x. If x is <= 0, the result is NaN. - -:param x: A positive numeric value. -:return: The natural logarithm of x. -`; - -(Math.pow)[cell.DOC] = `Return base raised to the power exponent, i.e. base^exponent. If base is -negative and exponent is not an integer, result is NaN. - -:param base: The base number. -:param exponent: The exponent number. -:return: base raised to exponent. -`; - -(Math.sin)[cell.DOC] = `Return the sine of x, where x is in radians. - -:param x: A numeric value in radians. -:return: The sine of x, in the range [-1, 1]. -`; - -(Math.tan)[cell.DOC] = `Return the tangent of x, where x is in radians. If x is (π/2 + nπ), the -result is ±Infinity or NaN. - -:param x: A numeric value in radians. -:return: The tangent of x. -`; - -(Math.trunc)[cell.DOC] = `Return the integer part of x by removing any fractional digits. Does not -round, just truncates. - -:param x: A numeric value. -:return: x truncated toward zero. -`; - -(Math.sign)[cell.DOC] = `Return the sign of x, indicating whether x is positive, negative, or zero. -Returns 1 if x > 0, -1 if x < 0, 0 if x is 0, and NaN if x is NaN. - -:param x: A numeric value. -:return: 1, -1, 0, -0, or NaN, depending on x. -`; - -(Math.cosh)[cell.DOC] = `Return the hyperbolic cosine of x, (e^x + e^-x) / 2. - -:param x: A numeric value. -:return: The hyperbolic cosine of x. -`; - -(Math.sinh)[cell.DOC] = `Return the hyperbolic sine of x, (e^x - e^-x) / 2. - -:param x: A numeric value. -:return: The hyperbolic sine of x. -`; - -(Math.tanh)[cell.DOC] = `Return the hyperbolic tangent of x, (e^x - e^-x) / (e^x + e^-x). - -:param x: A numeric value. -:return: The hyperbolic tangent of x. -`; - -(Math.acosh)[cell.DOC] = `Return the inverse hyperbolic cosine of x, defined as ln(x + sqrt(x^2 - 1)). -If x < 1, the result is NaN. - -:param x: A numeric value >= 1. -:return: The inverse hyperbolic cosine of x. -`; - -(Math.asinh)[cell.DOC] = `Return the inverse hyperbolic sine of x, defined as ln(x + sqrt(x^2 + 1)). - -:param x: A numeric value. -:return: The inverse hyperbolic sine of x. -`; - -(Math.atanh)[cell.DOC] = `Return the inverse hyperbolic tangent of x, defined as 1/2 * ln((1 + x) / (1 - x)). -If |x| >= 1, the result is NaN. - -:param x: A numeric value in the range (-1, 1). -:return: The inverse hyperbolic tangent of x. -`; - -(Math.expm1)[cell.DOC] = `Return e^x - 1, for small values of x this provides higher precision than -Math.exp(x) - 1. - -:param x: A numeric exponent. -:return: e^x - 1. -`; - -(Math.log1p)[cell.DOC] = `Return the natural logarithm of (1 + x). More accurate than Math.log(1 + x) -for small x. - -:param x: A numeric value > -1. -:return: ln(1 + x). -`; - -(Math.log2)[cell.DOC] = `Return the base-2 logarithm of x. If x <= 0, the result is NaN. - -:param x: A positive numeric value. -:return: The base-2 logarithm of x. -`; - -(Math.log10)[cell.DOC] = `Return the base-10 logarithm of x. If x <= 0, the result is NaN. - -:param x: A positive numeric value. -:return: The base-10 logarithm of x. -`; - -(Math.cbrt)[cell.DOC] = `Return the cube root of x, including negative values. - -:param x: A numeric value (can be negative). -:return: The cube root of x. -`; - -(Math.hypot)[cell.DOC] = `Return the square root of the sum of squares of its arguments, i.e. -sqrt(x1^2 + x2^2 + ...). If any value is ±Infinity, returns Infinity. If -any value is NaN, returns NaN. - -:param values: One or more numeric values. -:return: The square root of the sum of squares of the arguments. -`; - -(Math.random)[cell.DOC] = `Return a pseudo-random floating-point number in the range [0, 1). -The result is usually seeded by an engine-defined source of randomness. - -:return: A number >= 0 and < 1. -`; - -(Math.fround)[cell.DOC] = `Return the nearest 32-bit single-precision float representation of x. - -:param x: A numeric value. -:return: The 32-bit float representation of x. -`; - -(Math.imul)[cell.DOC] = `Return the result of a 32-bit integer multiplication of two values. -Effectively (a * b) | 0 in many implementations. - -:param a: A numeric value. -:param b: A numeric value. -:return: The 32-bit integer result of multiplying a by b. -`; - -(Math.clz32)[cell.DOC] = `Return the number of leading zero bits in the 32-bit binary representation -of x. If x is 0, returns 32. - -:param x: A numeric value, treated as a 32-bit unsigned integer. -:return: The count of leading zero bits, in the range [0, 32]. -`; - -(Number.parseInt)[cell.DOC] = `Parse a string argument and return an integer of the specified radix (base). -If the string does not start with a valid integer, return NaN. Leading -whitespace is ignored. - -:param string: The string to parse as an integer. -:param radix: An integer between 2 and 36 indicating the base of the number in the string. -:return: The parsed integer, or NaN if the input is not a valid integer. -`; - -(Number.parseFloat)[cell.DOC] = `Parse a string argument and return a floating-point number. If the string does not represent a valid number, return NaN. Leading whitespace is ignored, and the string can include a decimal point or exponent. - -:param string: The string to parse as a floating-point number. -:return: The parsed number, or NaN if invalid. -`; - -(Number.isNaN)[cell.DOC] = `Determine if a value is the special numeric value NaN, without converting the argument. Unlike the global isNaN(), this returns false for non-numeric values. - -:param value: The value to test. -:return: True if the value is NaN, otherwise false. -`; - -(Number.isFinite)[cell.DOC] = `Determine if a value is a finite number. Unlike the global isFinite(), this returns false for non-numeric values without attempting to convert them. - -:param value: The value to test. -:return: True if the value is a finite number, otherwise false. -`; - -(Number.isInteger)[cell.DOC] = `Check if the given value is a finite number and also an integer (no fractional part). Returns false for non-numeric values or NaN. - -:param value: The value to test. -:return: True if value is an integer, otherwise false. -`; - -(Number.isSafeInteger)[cell.DOC] = `Check if the given value is a safe integer. A safe integer is one that can be exactly represented as an IEEE-754 double-precision number (i.e., between -9007199254740991 and 9007199254740991 inclusive). - -:param value: The value to test. -:return: True if value is an integer within the safe range, otherwise false. -`; - -(Array.isArray)[cell.DOC] = `Determine if the given value is an Array. Returns true if the argument is an array, otherwise false. - -:param value: The value to be checked. -:return: True if 'value' is an array, otherwise false. -`; - -(Array.from)[cell.DOC] = `Create a new array from an array-like or iterable object. An optional map function can be invoked on each element before it is added to the new array. - -:param arrayLike: An array-like or iterable object to convert. -:param mapFn: Optional. A function to call on every element of the new array. -:param thisArg: Optional. A value to use as 'this' within the map function. -:return: A new array populated with elements processed from arrayLike. -`; - -(Array.of)[cell.DOC] = `Create a new array with a variable number of arguments, regardless of the number or type of the arguments. Unlike the Array constructor, there is no special treatment for a single numeric argument. - -:param elements: A variable number of arguments which become array elements. -:return: A new array containing the provided arguments. -`; - -(Symbol.for)[cell.DOC] = `Search the global symbol registry for a symbol with the given key. If found, return that symbol; otherwise, create a new symbol with that key and add it to the registry, then return the new symbol. - -:param key: A string key used to identify the symbol in the global registry. -:return: A symbol associated with the given key in the global registry. -`; - -(Symbol.keyFor)[cell.DOC] = `Retrieve a shared symbol’s key from the global symbol registry. If the symbol is not in the global registry, return undefined. - -:param sym: The symbol to find the key for. -:return: The string key if 'sym' is a global symbol, otherwise undefined. -`; - -// ------------------------------------------ -// MAP -// ------------------------------------------ -Map.prototype[cell.DOC] = {} -Map.prototype[cell.DOC][cell.DOC] = `A Map object holds key-value pairs, where any value (both objects and primitive values) may be used as either a key or a value. Insertion order is remembered, which allows iteration in that order.`; - -Map.prototype[cell.DOC].size = `A read-only property returning the number of key-value pairs in the Map. - -:return: The number of entries in the Map. -`; - -(Map.prototype.set)[cell.DOC] = `Add or update an entry in the Map with the specified key and value. - -:param key: The key of the element to add or update. -:param value: The value associated with the key. -:return: The Map object (for chaining). -`; - -(Map.prototype.get)[cell.DOC] = `Return the value associated with the specified key, or undefined if no -such key exists. - -:param key: The key of the element to retrieve. -:return: The value associated with the key, or undefined if not found. -`; - -(Map.prototype.has)[cell.DOC] = `Return a boolean indicating whether the Map contains an element with the -specified key. - -:param key: The key to test for presence in the Map. -:return: True if the key is found, otherwise false. -`; - -(Map.prototype.delete)[cell.DOC] = `Remove the specified key and its associated value from the Map, if it exists. - -:param key: The key to remove. -:return: True if an element was removed, otherwise false. -`; - -(Map.prototype.clear)[cell.DOC] = `Remove all entries from the Map, leaving it empty. - -:return: None -`; - -(Map.prototype.forEach)[cell.DOC] = `Execute a provided callback function once per each key-value pair in the Map, -in insertion order. - -:param callbackFn: A function(value, key, map) to execute on each entry. -:param thisArg: Optional. A value to use as 'this' when executing callbackFn. -:return: None -`; - -(Map.prototype.values)[cell.DOC] = `Return a new Iterator object that contains the values for each element -in the Map, in insertion order. - -:return: An iterator of the Map's values. -`; - -(Map.prototype.keys)[cell.DOC] = `Return a new Iterator object that contains the keys for each element in -the Map, in insertion order. - -:return: An iterator of the Map's keys. -`; - -(Map.prototype.entries)[cell.DOC] = `Return a new Iterator object that contains the [key, value] pairs for -each element in the Map, in insertion order. - -:return: An iterator of [key, value] pairs. -`; - - -// ------------------------------------------ -// SET -// ------------------------------------------ -Set.prototype[cell.DOC] = {} -Set.prototype[cell.DOC][cell.DOC] = `A Set object lets you store unique values of any type, whether primitive values or object references. It remembers insertion order for iteration.`; - -Set.prototype[cell.DOC].size = `A read-only property returning the number of elements in the Set. - -:return: The number of unique values in the Set. -`; - -(Set.prototype.add)[cell.DOC] = `Add a new element with the given value to the Set, if it’s not already present. - -:param value: The value to add. -:return: The Set object (for chaining). -`; - -(Set.prototype.has)[cell.DOC] = `Return a boolean indicating whether the Set contains the specified value. - -:param value: The value to check for presence in the Set. -:return: True if the value is found, otherwise false. -`; - -(Set.prototype.delete)[cell.DOC] = `Remove the specified value from the Set if it exists. - -:param value: The value to remove. -:return: True if the value was present and removed, otherwise false. -`; - -(Set.prototype.clear)[cell.DOC] = `Remove all elements from the Set, leaving it empty. - -:return: None -`; - -(Set.prototype.forEach)[cell.DOC] = `Execute a provided callback function once for each value in the Set, -in insertion order. - -:param callbackFn: A function(value, valueAgain, set) to execute on each element. -:param thisArg: Optional. A value to use as 'this' when executing callbackFn. -:return: None -`; - -(Set.prototype.values)[cell.DOC] = `Return a new Iterator object containing all the values in the Set, -in insertion order. - -:return: An iterator of the Set's values. -`; - -(Set.prototype.keys)[cell.DOC] = `Alias for values() in a Set. Return a new Iterator object containing all -the values (as keys) in the Set, in insertion order. - -:return: An iterator of the Set's values. -`; - -(Set.prototype.entries)[cell.DOC] = `Return a new Iterator object containing [value, value] pairs for each value -in the Set, in insertion order. This maintains API consistency with Map objects. - -:return: An iterator of [value, value] pairs. -`; diff --git a/scripts/clean.ce b/scripts/clean.ce index 426c7f44..23c49592 100644 --- a/scripts/clean.ce +++ b/scripts/clean.ce @@ -15,7 +15,6 @@ log.console("Cleaning build artifacts...") // Remove the build directory try { io.rmdir('.cell/build') - remove_dir('.cell/build') log.console("Build directory removed") } catch (e) { log.error("Failed during cleanup: " + e) diff --git a/scripts/engine.cm b/scripts/engine.cm index 256e5acf..7248e690 100644 --- a/scripts/engine.cm +++ b/scripts/engine.cm @@ -1,6 +1,6 @@ (function engine() { globalThis.cell = prosperon -cell.DOC = cell.hidden.DOCSYM +cell.DOC = Symbol() var ACTORDATA = cell.hidden.ACTORSYM ACTORDATA = '__ACTORDATA__' // TODO: implement the actual actorsym var SYSYM = '__SYSTEM__' @@ -103,6 +103,7 @@ function disrupt(err) os.on(disrupt) var js = use_embed('js') + var io = use_embed('io') if (!io.exists('.cell')) { @@ -236,6 +237,9 @@ globalThis.use = function use(file, ...args) { return ret } +globalThis.json = use('json') +var time = use('time') +var st_now = time.number() var shop = use('shop') var config = shop.load_config() @@ -251,10 +255,8 @@ config.system.__proto__ = default_config ENETSERVICE = config.system.net_service REPLYTIMEOUT = config.system.reply_timeout - -globalThis.json = use('json') + globalThis.text = use('text') -var time = use('time') // Load actor-specific configuration function load_actor_config(program) { @@ -333,7 +335,6 @@ stone.p = function(object) */ var util = use('util') -var math = use('math') var crypto = use('crypto') var HEADER = Symbol() @@ -647,8 +648,6 @@ function turn(msg) load_actor_config(cell.args.program) -log.console(`actor ${cell.args.program} is ${cell.args.main}`) - actor_mod.register_actor(cell.id, turn, cell.args.main, config.system.ar_timer) if (config.system.actor_memory) @@ -773,9 +772,6 @@ function enet_check() // Finally, run the program actor_mod.setname(cell.args.program) -// Load actor-specific configuration before running - - var prog = null var progPath = cell.args.program @@ -790,7 +786,6 @@ if (io.exists(progPath + ACTOR_EXT) && !io.is_directory(progPath + ACTOR_EXT)) { if (!prog) throw new Error(cell.args.program + " not found."); - var progDir = io.realdir(prog) + "/" + prog.substring(0, prog.lastIndexOf('/')) @@ -803,7 +798,7 @@ var prog_script = `(function ${cell.args.program.name()}_start($_, arg) { var ar var val = js.eval(cell.args.program, prog_script)($_, cell.args.arg) if (val) throw new Error('Program must not return anything'); - + send_messages() })() \ No newline at end of file diff --git a/scripts/text.cm b/scripts/text.cm index 9cdf74f3..c38adf38 100644 --- a/scripts/text.cm +++ b/scripts/text.cm @@ -521,13 +521,4 @@ function format_number(num, format) { return null; } -/* -------- documentation -------------------------------------------- */ - -text[cell.DOC] = { - doc: "Text conversion and formatting utilities", - text: "text(value, ...) → formatted text string" -}; - -/* -------- exports -------------------------------------------------- */ - return text; \ No newline at end of file diff --git a/scripts/util.cm b/scripts/util.cm index afe0bd44..c0673e51 100644 --- a/scripts/util.cm +++ b/scripts/util.cm @@ -1,20 +1,6 @@ var util = this -util[cell.DOC] = ` -A collection of general-purpose utility functions for object manipulation, merging, -deep copying, safe property access, etc. -` -util.deepfreeze = function (obj) { - for (var key in obj) { - if (typeof obj[key] === "object") Object.deepfreeze(obj[key]) - } - Object.freeze(obj) -} -util.deepfreeze[cell.DOC] = ` -:param obj: The object to recursively freeze. -:return: None -Recursively freeze an object and all of its nested objects so they cannot be modified. -` +return util util.dainty_assign = function (target, source) { Object.keys(source).forEach(function (k) { @@ -25,13 +11,6 @@ util.dainty_assign = function (target, source) { else target[k] = source[k] }) } -util.dainty_assign[cell.DOC] = ` -:param target: The target object whose keys may be updated. -:param source: The source object containing new values. -:return: None -Copy non-function properties from source into matching keys of target without overwriting -keys that don't exist in target. Arrays are deep-copied, and objects are recursively assigned. -` util.get = function (obj, path, defValue) { if (!path) return undefined @@ -39,23 +18,10 @@ util.get = function (obj, path, defValue) { var result = pathArray.reduce((prevObj, key) => prevObj && prevObj[key], obj) return result === undefined ? defValue : result } -util.get[cell.DOC] = ` -:param obj: The object to traverse. -:param path: A string like "a.b.c" or an array of path segments. -:param defValue: The default value if the property is undefined. -:return: The nested property or defValue. -Safely retrieve a nested property from obj at path (array or dot-string). -Returns defValue if the property is undefined. -` util.isEmpty = function(o) { return Object.keys(o).length === 0 } -util.isEmpty[cell.DOC] = ` -:param o: The object to check. -:return: Boolean indicating if the object is empty. -Return true if the object has no own properties, otherwise false. -` util.dig = function (obj, path, def = {}) { var pp = path.split(".") @@ -65,14 +31,6 @@ util.dig = function (obj, path, def = {}) { obj[pp[pp.length - 1]] = def return def } -util.dig[cell.DOC] = ` -:param obj: The root object to modify. -:param path: A dot-string specifying nested objects to create. -:param def: The value to store in the final path component, default {}. -:return: The assigned final value. -Ensure a nested path of objects exists inside obj; create objects if missing, and set -the final path component to def. -` util.access = function (obj, name) { var dig = name.split(".") @@ -82,13 +40,6 @@ util.access = function (obj, name) { } return obj } -util.access[cell.DOC] = ` -:param obj: The object to traverse. -:param name: A dot-string path (e.g. "foo.bar.baz"). -:return: The value at that path, or undefined if missing. -Traverse obj by dot-separated path name, returning the final value or undefined -if any step is missing. -` util.mergekey = function (o1, o2, k) { if (!o2) return @@ -101,38 +52,17 @@ util.mergekey = function (o1, o2, k) { } } else o1[k] = o2[k] } -util.mergekey[cell.DOC] = ` -:param o1: The target object. -:param o2: The source object. -:param k: The key to merge. -:return: None -Helper for merge, updating key k from o2 into o1. Arrays are deep-copied and objects are -recursively merged. -` util.merge = function (target, ...objs) { for (var obj of objs) for (var key of Object.keys(obj)) util.mergekey(target, obj, key) return target } -util.merge[cell.DOC] = ` -:param target: The target object. -:param objs: One or more objects to merge into target. -:return: The updated target object. -Merge all passed objects into target, copying or merging each key as needed. -Arrays are deep-copied, objects are recursively merged, etc. -` util.copy = function (proto, ...objs) { var c = Object.create(proto) for (var obj of objs) Object.mixin(c, obj) return c } -util.copy[cell.DOC] = ` -:param proto: The prototype object for the new object. -:param objs: One or more objects whose properties will be mixed in. -:return: The newly created object. -Create a new object with proto as its prototype, then mix in additional objects’ properties. -` util.obj_lerp = function(a,b,t) { if (a.lerp) return a.lerp(b, t) @@ -142,14 +72,6 @@ util.obj_lerp = function(a,b,t) { }) return obj } -util.obj_lerp[cell.DOC] = ` -:param a: The start object (its properties must have .lerp()). -:param b: The end object (matching properties). -:param t: Interpolation factor (0..1). -:return: A new object with interpolated properties. -Linearly interpolate between two objects a and b by factor t, assuming each property -supports .lerp(). -` util.normalizeSpacing = function normalizeSpacing(spacing) { if (typeof spacing === 'number') { @@ -166,23 +88,6 @@ util.normalizeSpacing = function normalizeSpacing(spacing) { return {l:0, r:0, t:0, b:0} } } -util.normalizeSpacing[cell.DOC] = ` -:param spacing: A number, an array of length 2 or 4, or an object with l/r/t/b. -:return: An object {l, r, t, b}. -Normalize any spacing input into a {l, r, t, b} object. -` - -util.guid[cell.DOC] = ` -:return: A random 32-character string (hex). -Return a random 32-character hexadecimal UUID-like string (not guaranteed RFC4122-compliant). -` - -util.insertion_sort[cell.DOC] = ` -:param arr: The array to be sorted in-place. -:param cmp: Comparison function cmp(a,b)->Number. -:return: The same array, sorted in-place. -In-place insertion sort of an array using cmp(a,b)->Number for ordering. -` function deep_copy(from) { return json.decode(json.encode(from)) diff --git a/source/cell.c b/source/cell.c index 8502ef67..6fc15258 100644 --- a/source/cell.c +++ b/source/cell.c @@ -109,7 +109,6 @@ void actor_free(cell_rt *actor) JS_FreeValue(js, actor->message_handle); JS_FreeValue(js, actor->on_exception); JS_FreeValue(js, actor->unneeded); - JS_FreeAtom(js, actor->doc_sym); JS_FreeAtom(js, actor->actor_sym); SDL_RemoveTimer(actor->ar); @@ -705,6 +704,7 @@ static int actor_interrupt_cb(JSRuntime *rt, cell_rt *crt) void script_startup(cell_rt *prt) { JSRuntime *rt; + #ifdef TRACY_ENABLE if (tracy_profiling_enabled) rt = JS_NewRuntime2(&tracy_malloc_funcs, NULL); @@ -730,6 +730,9 @@ void script_startup(cell_rt *prt) JS_AddIntrinsicJSON(js); JS_AddIntrinsicMapSet(js); JS_AddIntrinsicProxy(js); +// JS_AddIntrinsicTypedArrays(js); +// JS_AddIntrinsicDate(js); +// JS_AddIntrinsicPromise(js); JS_SetContextOpaque(js, prt); prt->context = js; diff --git a/source/cell.h b/source/cell.h index e2968fee..e7f1885a 100644 --- a/source/cell.h +++ b/source/cell.h @@ -70,7 +70,6 @@ typedef struct cell_rt { int main_thread_only; JSAtom actor_sym; - JSAtom doc_sym; const char *name; // human friendly name } cell_rt; diff --git a/source/jsffi.c b/source/jsffi.c index 925d496a..03d423d1 100644 --- a/source/jsffi.c +++ b/source/jsffi.c @@ -1585,15 +1585,6 @@ void ffi_load(JSContext *js) JSValue prosp = JS_NewObject(js); JS_SetPropertyStr(js,globalThis,"prosperon", prosp); - JSValue c_types = JS_NewObject(js); - JS_SetPropertyStr(js,prosp, "c_types", c_types); - - QJSCLASSPREP_FUNCS(font); - QJSCLASSPREP_FUNCS(datastream); - - JSValue jsobject = JS_GetPropertyStr(js,globalThis, "Object"); - JS_SetPropertyStr(js, jsobject, "id", JS_NewCFunction(js, js_os_value_id, "id", 1)); - JS_FreeValue(js,jsobject); JSValue jsarray = JS_GetPropertyStr(js,globalThis, "Array"); JSValue array_proto = JS_GetPropertyStr(js,jsarray, "prototype"); @@ -1607,9 +1598,6 @@ void ffi_load(JSContext *js) JS_FreeValue(js,jsnumber); JS_FreeValue(js,number_proto); - //JS_SetPropertyStr(js,prosp, "version", JS_NewString(js,CELL_VERSION)); - //JS_SetPropertyStr(js,prosp,"revision",JS_NewString(js,CELL_COMMIT)); - JSValue hidden_fn = JS_NewObject(js); // add engine.js-only functions to hidden_fn. It should grab them and then remove so nothing else can use them. @@ -1636,11 +1624,6 @@ void ffi_load(JSContext *js) actor->actor_sym = JS_ValueToAtom(js, actorsym); JS_SetPropertyStr(js, hidden_fn, "ACTORDATA", JS_DupValue(js,actorsym)); JS_FreeValue(js, actorsym); - JSValue docsym = js_newsymbol(js, "+documentation+", 0); - actor->doc_sym = JS_ValueToAtom(js, docsym); - JS_SetPropertyStr(js, hidden_fn, "DOCSYM", JS_DupValue(js,docsym)); - JS_FreeValue(js,docsym); - JS_SetPropertyStr(js, prosp, "hidden", hidden_fn); JS_FreeValue(js,globalThis); diff --git a/source/qjs_js.c b/source/qjs_js.c index b33e9692..aba72e82 100644 --- a/source/qjs_js.c +++ b/source/qjs_js.c @@ -54,7 +54,7 @@ JSC_CCALL(js_eval_compile, #include "qjs_blob.h" JSC_CCALL(js_compile_blob, -// JSRuntime *rt = JS_GetRuntime(js); + JSRuntime *rt = JS_GetRuntime(js); // JS_SetStripInfo(rt, JS_STRIP_SOURCE); // JS_SetStripInfo(rt, JS_STRIP_DEBUG); size_t size;