Comparing version 0.0.12 to 0.0.13
0.0.13 / 2012-05-30 | ||
=================== | ||
- make `refType()` coerce string types properly | ||
- make the `bool` type inherit from a proper fixed type (like `uint8`) | ||
0.0.12 / 2012-05-30 | ||
@@ -3,0 +9,0 @@ =================== |
@@ -35,3 +35,3 @@ | ||
exports.refType = function refType (type) { | ||
var rtn = exports.cloneType(type) | ||
var rtn = exports.cloneType(exports.coerceType(type)) | ||
rtn.indirection++ | ||
@@ -487,23 +487,10 @@ return rtn | ||
/** | ||
* the "bool" type should return/accept JS true/false values | ||
* XXX: should "int8" always be used here? | ||
*/ | ||
exports.types.bool = { | ||
size: exports.sizeof.bool | ||
, indirection: 1 | ||
, get: function get (buf, offset) { | ||
return exports.types.int8.get(buf, offset) ? true : false | ||
} | ||
, set: function set (buf, offset, val) { | ||
return exports.types.int8.set(buf, offset, val ? 1 : 0) | ||
} | ||
} | ||
// "typedef"s for the variable-sized types | ||
;[ 'byte', 'char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long' | ||
;[ 'bool', 'byte', 'char', 'uchar', 'short', 'ushort', 'int', 'uint', 'long' | ||
, 'ulong', 'longlong', 'ulonglong', 'size_t' ].forEach(function (name) { | ||
var unsigned = name === 'byte' || name === 'size_t' || name[0] === 'u' | ||
var unsigned = name === 'bool' | ||
|| name === 'byte' | ||
|| name === 'size_t' | ||
|| name[0] === 'u' | ||
var size = exports.sizeof[name] | ||
@@ -527,3 +514,18 @@ assert(size >= 1 && size <= 8) | ||
// make the `Utf8String` type have the correct 'alignment' property | ||
exports.types.Utf8String.alignment = exports.alignof.pointer | ||
// make the `bool` type work with JS true/false values | ||
exports.types.bool.get = (function (_get) { | ||
return function get (buf, offset) { | ||
return _get(buf, offset) ? true : false | ||
} | ||
})(exports.types.bool.get) | ||
exports.types.bool.set = (function (_set) { | ||
return function set (buf, offset, val) { | ||
return _set(buf, offset, val ? 1 : 0) | ||
} | ||
})(exports.types.bool.set) | ||
/** | ||
@@ -530,0 +532,0 @@ * NULL_POINTER is essentially: |
@@ -19,3 +19,3 @@ { "name": "ref" | ||
] | ||
, "version": "0.0.12" | ||
, "version": "0.0.13" | ||
, "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)" | ||
@@ -22,0 +22,0 @@ , "repository": { "type": "git", "url": "git://github.com/TooTallNate/ref.git" } |
@@ -17,3 +17,3 @@ | ||
it('should work 2 levels deep', function () { | ||
it('should work 2 layers deep', function () { | ||
var test = new Buffer('two layers deep') | ||
@@ -20,0 +20,0 @@ var one = ref.ref(test) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69524
996