@socketsupply/ltp
Advanced tools
Comparing version 2.1.0 to 2.1.1
@@ -29,2 +29,7 @@ var path = require('path') | ||
if(pointed) | ||
if(!pointed.type) throw new Error('pointed codec must have type, was:'+JSON.stringify(field)) | ||
if(direct) | ||
if(!direct.type) throw new Error('direct codec must have type, was:'+JSON.stringify(field)) | ||
//Direct to Pointed - (variable size value) | ||
@@ -82,6 +87,5 @@ if(direct && pointed) { | ||
if(field.isLength) { | ||
s += (` | ||
void ${encode(field)} (byte* buf, byte* free) { | ||
ltp_encode__${direct.type}((byte*)(buf+${position}), (${direct.type})(free-buf)); | ||
ltp_encode__${direct.type}((byte*)(buf+${position}), (${direct.type})(free-buf-${field.offset|0})); | ||
} | ||
@@ -91,3 +95,3 @@ `) | ||
${direct.type}* ${decode(field)} (byte* buf) { | ||
return ltp_decode__${direct.type}((byte*)(buf+${position})); | ||
return ltp_decode__${direct.type}((byte*)(buf+${position}+${field.offset|0})); | ||
} | ||
@@ -94,0 +98,0 @@ `) |
@@ -66,3 +66,3 @@ 'use strict' | ||
var _end = start + decode.bytes | ||
if(_end > end) throw new Error('length field out of bounds') | ||
if(_end > end) throw new Error('length field out of bounds, expected:'+end+', got:'+_end) | ||
//but a smaller value for end is acceptable. | ||
@@ -69,0 +69,0 @@ end = _end |
{ | ||
"name": "@socketsupply/ltp", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A schemaful parseless binary format, like a simpler version of captnproto. fast access to fields without allocating memory", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -71,4 +71,2 @@ var codex = require('./codex') | ||
assertFixedSize(direct) | ||
// console.log("LengthField", {name, position, direct, isLength: true}) | ||
// if(position !== 0) throw new Error('length position must be zero') | ||
return { | ||
@@ -171,8 +169,4 @@ name, position, direct, isLength: true, offset | ||
function decodeField (position, direct, pointed, buffer, start, end=buffer.length, allow_zero=false) { | ||
// if(!direct) | ||
// throw new Error('field must have direct codec') | ||
var test = direct && start + position + direct.bytes > end | ||
if(test) { | ||
// console.log('lo???g', {direct, start, position, end}); | ||
// console.log() | ||
//TODO XXX end is not big enough to contain: start + position + direct.bytes | ||
@@ -179,0 +173,0 @@ throw new Error('direct value out of bounds? attempted to read '+direct.type+' at:'+ (start+position) + '(position:'+position+') end was:'+ end) |
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
135441
1654