Comparing version 1.1.1 to 1.1.2
1.1.2 / 2015-09-19 | ||
================== | ||
* CString: allow a Buffer to be used as backing store in `set()` (https://github.com/node-ffi/node-ffi/issues/169) | ||
* travis, appveyor: test Node.js v4 | ||
1.1.1 / 2015-09-14 | ||
@@ -3,0 +9,0 @@ ================== |
@@ -1030,11 +1030,17 @@ | ||
, get: function get (buf, offset) { | ||
var _buf = buf.readPointer(offset) | ||
if (_buf.isNull()) { | ||
var _buf = exports.readPointer(buf, offset) | ||
if (exports.isNull(_buf)) { | ||
return null | ||
} | ||
return _buf.readCString(0) | ||
return exports.readCString(_buf, 0) | ||
} | ||
, set: function set (buf, offset, val) { | ||
var _buf = exports.allocCString(val) | ||
return buf.writePointer(_buf, offset) | ||
var _buf | ||
if (Buffer.isBuffer(val)) { | ||
_buf = val | ||
} else { | ||
// assume string | ||
_buf = exports.allocCString(val) | ||
} | ||
return exports.writePointer(buf, offset, _buf) | ||
} | ||
@@ -1041,0 +1047,0 @@ } |
@@ -20,3 +20,3 @@ { | ||
], | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"license": "MIT", | ||
@@ -23,0 +23,0 @@ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)", |
@@ -75,2 +75,3 @@ | ||
// another version of the same test | ||
assert.strictEqual(null, ref.get(ref.NULL_POINTER, 0, ref.types.CString)) | ||
@@ -82,8 +83,18 @@ }) | ||
var buf = ref.alloc(ref.types.CString) | ||
buf.writePointer(Buffer(str + '\0')) | ||
buf.writePointer(new Buffer(str + '\0')) | ||
assert.strictEqual(str, buf.deref()) | ||
}) | ||
// https://github.com/node-ffi/node-ffi/issues/169 | ||
it('should set a Buffer as backing store', function () { | ||
var str = 'hey!' | ||
var store = new Buffer(str + '\0') | ||
var buf = ref.alloc(ref.types.CString) | ||
ref.set(buf, 0, store) | ||
assert.equal(str, ref.get(buf, 0)) | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
428867
2930