Permalink
Browse files

docs: more

  • Loading branch information...
1 parent 39b9387 commit 2425c69a64bd478805f588d5dabc2adf7b8574dc @TooTallNate committed Jul 5, 2012
Showing with 22 additions and 8 deletions.
  1. +22 −8 lib/ref.js
View
@@ -332,11 +332,24 @@ exports.derefType = function derefType (type) {
}
/**
- * Coerces a "type" object from a String or an actual "type" object. So:
+ * Coerces a "type" object from a String or an actual "type" object. String values
+ * are looked up from the `ref.types` Object. So:
*
* * `"int"` gets coerced into `ref.types.int`.
* * `"int *"` gets translated into `ref.refType(ref.types.int)`
- * * `ref.types.int` gets translated into `ref.types.int` (itself)
+ * * `ref.types.int` gets translated into `ref.types.int` (returns itself)
+ *
+ * Throws an Error if no valid "type" object could be determined. Most `ref`
+ * functions use this function under the, so anywhere a "type" object is expected,
+ * a String may be passed as well, including simply setting the `buffer.type`
+ * property.
+ *
+ * ```
+ * var type = ref.coerceType('int **');
+ *
+ * console.log(type.indirection);
+ * 3
+ * ```
*
* @param {Object|String} type The "type" Object or String to coerce.
* @return {Object} A "type" object
@@ -610,14 +623,15 @@ exports.ref = function ref (buffer) {
/**
* Acceps a Buffer instance and attempts to "dereference" it.
- * That is, first it checks the "indirection" count, and if it's greater than
- * 0 then it merely returns another Buffer, but with one level less indirection.
+ * That is, first it checks the "indirection" count of _buffer_'s "type", and if
+ * it's greater than __1__ then it merely returns another Buffer, but with one
+ * level less `indirection`.
*
- * When the buffer's indirection is at __1__, then it checks for "type"
- * which should be an Object with it's own "get()" function.
+ * When _buffer_'s indirection is at __1__, then it checks for `buffer.type`
+ * which should be an Object with its own `get()` function.
*
- * @param {Buffer} buffer A Buffer instance to read a reference from.
- * @return {?} The returned value after dereferencing "buffer".
+ * @param {Buffer} buffer A Buffer instance to dereference.
+ * @return {?} The returned value after dereferencing _buffer_.
*/
exports.deref = function deref (buffer) {

0 comments on commit 2425c69

Please sign in to comment.