Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/typedObjects.js

Issue 5665229014827008: Issue 150 - [Typed objects] Implement string type (Closed)
Patch Set: Created May 19, 2014, 3:15 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | lib/typedObjects/arrayTypes.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/typedObjects.js
===================================================================
--- a/lib/typedObjects.js
+++ b/lib/typedObjects.js
@@ -150,19 +150,40 @@
* get(index): retrieves the array element at specified index.
* set(index, value): sets the array element at specified index.
* length: number of elements in the array, by default 0. Increase the length
* to match your data size.
* size: size of the allocated buffer in array elements, will be at least
* equal to length. Normally you won't need to set the size explicitly.
* However, the size won't decrease automatically if the array gets
* smaller so you might want to set it in order to shrink the array.
+ *
+ * String type
+ * -----------
+ *
+ * There is a special array type called string:
+ *
+ * var str1 = string(); // empty string
+ * var str2 = string(2); // "\0\0"
+ * var str3 = string("foo"); // "foo"
+ * var str4 = string(str3, 1, 2); // "oo"
+ * str4.get(0); // 111 - character code of "o"
+ *
+ * Without any constructor parameters the string will be empty, a number as
+ * parameter will set the initial string length accordingly. A JavaScript string
+ * or another string instance as first parameter indicate that the string data
+ * should be copied from these. Optionally, a second (offset) and third
+ * parameter (length) can be given.
+ *
+ * To convert a string instance into a JavaScript string you can call the
+ * toString() method.
*/
function forwardExports(module)
{
let moduleExports = require(module);
for (let key in moduleExports)
exports[key] = moduleExports[key];
}
forwardExports("typedObjects/primitiveTypes");
forwardExports("typedObjects/objectTypes");
+forwardExports("typedObjects/stringType");
« no previous file with comments | « no previous file | lib/typedObjects/arrayTypes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld