New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

kiwi-schema

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kiwi-schema - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

example.kiwi

62

kiwi.js

@@ -909,3 +909,3 @@ var kiwi = exports || kiwi || {}, exports;

else {
cpp.push('bool ' + definition.name + '::encode(kiwi::ByteBuffer &bb) {');
cpp.push('bool ' + definition.name + '::encode(kiwi::ByteBuffer &_bb) {');

@@ -915,3 +915,3 @@ for (var j = 0; j < fields.length; j++) {

var name = cppFieldName(field);
var value = field.isArray ? 'it' : name;
var value = field.isArray ? '_it' : name;
var flagIndex = cppFlagIndex(j);

@@ -923,3 +923,3 @@ var flagMask = cppFlagMask(j);

case 'bool': {
code = 'bb.writeByte(' + value + ');';
code = '_bb.writeByte(' + value + ');';
break;

@@ -929,3 +929,3 @@ }

case 'byte': {
code = 'bb.writeByte(' + value + ');';
code = '_bb.writeByte(' + value + ');';
break;

@@ -935,3 +935,3 @@ }

case 'int': {
code = 'bb.writeVarInt(' + value + ');';
code = '_bb.writeVarInt(' + value + ');';
break;

@@ -941,3 +941,3 @@ }

case 'uint': {
code = 'bb.writeVarUint(' + value + ');';
code = '_bb.writeVarUint(' + value + ');';
break;

@@ -947,3 +947,3 @@ }

case 'float': {
code = 'bb.writeFloat(' + value + ');';
code = '_bb.writeFloat(' + value + ');';
break;

@@ -953,3 +953,3 @@ }

case 'string': {
code = 'bb.writeString(' + value + '.c_str());';
code = '_bb.writeString(' + value + '.c_str());';
break;

@@ -966,7 +966,7 @@ }

else if (type.kind === 'ENUM') {
code = 'bb.writeVarUint(static_cast<uint32_t>(' + value + '));';
code = '_bb.writeVarUint(static_cast<uint32_t>(' + value + '));';
}
else {
code = 'if (!' + value + (cppIsFieldPointer(definitions, field) ? '->' : '.') + 'encode(bb)) return false;';
code = 'if (!' + value + (cppIsFieldPointer(definitions, field) ? '->' : '.') + 'encode(_bb)) return false;';
}

@@ -985,8 +985,8 @@ }

if (definition.kind === 'MESSAGE') {
cpp.push(indent + 'bb.writeVarUint(' + field.value + ');');
cpp.push(indent + '_bb.writeVarUint(' + field.value + ');');
}
if (field.isArray) {
cpp.push(indent + 'bb.writeVarUint(' + name + '.size());');
cpp.push(indent + 'for (' + cppType(definitions, field, false) + ' &it : ' + name + ') ' + code);
cpp.push(indent + '_bb.writeVarUint(' + name + '.size());');
cpp.push(indent + 'for (' + cppType(definitions, field, false) + ' &_it : ' + name + ') ' + code);
} else {

@@ -1002,3 +1002,3 @@ cpp.push(indent + code);

if (definition.kind === 'MESSAGE') {
cpp.push(' bb.writeVarUint(0);');
cpp.push(' _bb.writeVarUint(0);');
}

@@ -1010,7 +1010,7 @@

cpp.push('bool ' + definition.name + '::decode(kiwi::ByteBuffer &bb, kiwi::MemoryPool &pool) {');
cpp.push('bool ' + definition.name + '::decode(kiwi::ByteBuffer &_bb, kiwi::MemoryPool &_pool) {');
for (var j = 0; j < fields.length; j++) {
if (fields[j].isArray) {
cpp.push(' uint32_t count;');
cpp.push(' uint32_t _count;');
break;

@@ -1022,5 +1022,5 @@ }

cpp.push(' while (true) {');
cpp.push(' uint32_t type;');
cpp.push(' if (!bb.readVarUint(type)) return false;');
cpp.push(' switch (type) {');
cpp.push(' uint32_t _type;');
cpp.push(' if (!_bb.readVarUint(_type)) return false;');
cpp.push(' switch (_type) {');
cpp.push(' case 0:');

@@ -1041,3 +1041,3 @@

var name = cppFieldName(field);
var value = field.isArray ? 'it' : name;
var value = field.isArray ? '_it' : name;
var isPointer = cppIsFieldPointer(definitions, field);

@@ -1048,3 +1048,3 @@ var code;

case 'bool': {
code = 'bb.readByte(' + value + ')';
code = '_bb.readByte(' + value + ')';
break;

@@ -1054,3 +1054,3 @@ }

case 'byte': {
code = 'bb.readByte(' + value + ')';
code = '_bb.readByte(' + value + ')';
break;

@@ -1060,3 +1060,3 @@ }

case 'int': {
code = 'bb.readVarInt(' + value + ')';
code = '_bb.readVarInt(' + value + ')';
break;

@@ -1066,3 +1066,3 @@ }

case 'uint': {
code = 'bb.readVarUint(' + value + ')';
code = '_bb.readVarUint(' + value + ')';
break;

@@ -1072,3 +1072,3 @@ }

case 'float': {
code = 'bb.readFloat(' + value + ')';
code = '_bb.readFloat(' + value + ')';
break;

@@ -1078,3 +1078,3 @@ }

case 'string': {
code = 'bb.readString(' + value + ', pool)';
code = '_bb.readString(' + value + ', _pool)';
break;

@@ -1091,7 +1091,7 @@ }

else if (type.kind === 'ENUM') {
code = 'bb.readVarUint(reinterpret_cast<uint32_t &>(' + value + '))';
code = '_bb.readVarUint(reinterpret_cast<uint32_t &>(' + value + '))';
}
else {
code = value + (isPointer ? '->' : '.') + 'decode(bb, pool)';
code = value + (isPointer ? '->' : '.') + 'decode(_bb, _pool)';
}

@@ -1110,4 +1110,4 @@ }

if (field.isArray) {
cpp.push(indent + 'if (!bb.readVarUint(count)) return false;');
cpp.push(indent + 'for (' + type + ' &it : set_' + field.name + '(pool, count)) if (!' + code + ') return false;');
cpp.push(indent + 'if (!_bb.readVarUint(_count)) return false;');
cpp.push(indent + 'for (' + type + ' &_it : set_' + field.name + '(_pool, _count)) if (!' + code + ') return false;');
}

@@ -1117,3 +1117,3 @@

if (isPointer) {
cpp.push(indent + name + ' = pool.allocate<' + type + '>();');
cpp.push(indent + name + ' = _pool.allocate<' + type + '>();');
}

@@ -1120,0 +1120,0 @@

{
"name": "kiwi-schema",
"version": "0.0.6",
"version": "0.0.7",
"description": "",

@@ -5,0 +5,0 @@ "main": "kiwi.js",

@@ -8,4 +8,4 @@ var assert = require('assert');

function check(i, o) {
assert.deepEqual(schema.encodeBoolStruct({x: i}), Buffer(o));
assert.deepEqual(schema.decodeBoolStruct(Buffer(o)), {x: i});
assert.deepEqual(Buffer(schema.encodeBoolStruct({x: i})), Buffer(o));
assert.deepEqual(schema.decodeBoolStruct(new Uint8Array(o)), {x: i});
}

@@ -19,4 +19,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeByteStruct({x: i}), Buffer(o));
assert.deepEqual(schema.decodeByteStruct(Buffer(o)), {x: i});
assert.deepEqual(Buffer(schema.encodeByteStruct({x: i})), Buffer(o));
assert.deepEqual(schema.decodeByteStruct(new Uint8Array(o)), {x: i});
}

@@ -33,4 +33,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeUintStruct({x: i}), Buffer(o));
assert.deepEqual(schema.decodeUintStruct(Buffer(o)), {x: i});
assert.deepEqual(Buffer(schema.encodeUintStruct({x: i})), Buffer(o));
assert.deepEqual(schema.decodeUintStruct(new Uint8Array(o)), {x: i});
}

@@ -58,4 +58,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeIntStruct({x: i}), Buffer(o));
assert.deepEqual(schema.decodeIntStruct(Buffer(o)), {x: i});
assert.deepEqual(Buffer(schema.encodeIntStruct({x: i})), Buffer(o));
assert.deepEqual(schema.decodeIntStruct(new Uint8Array(o)), {x: i});
}

@@ -87,4 +87,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeFloatStruct({x: i}), Buffer(o));
assert.deepEqual(schema.decodeFloatStruct(Buffer(o)), {x: i});
assert.deepEqual(Buffer(schema.encodeFloatStruct({x: i})), Buffer(o));
assert.deepEqual(schema.decodeFloatStruct(new Uint8Array(o)), {x: i});
}

@@ -101,4 +101,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeStringStruct({x: i}), Buffer(o));
assert.deepEqual(schema.decodeStringStruct(Buffer(o)), {x: i});
assert.deepEqual(Buffer(schema.encodeStringStruct({x: i})), Buffer(o));
assert.deepEqual(schema.decodeStringStruct(new Uint8Array(o)), {x: i});
}

@@ -113,4 +113,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeCompoundStruct(i), Buffer(o));
assert.deepEqual(schema.decodeCompoundStruct(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeCompoundStruct(i)), Buffer(o));
assert.deepEqual(schema.decodeCompoundStruct(new Uint8Array(o)), i);
}

@@ -125,4 +125,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeNestedStruct(i), Buffer(o));
assert.deepEqual(schema.decodeNestedStruct(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeNestedStruct(i)), Buffer(o));
assert.deepEqual(schema.decodeNestedStruct(new Uint8Array(o)), i);
}

@@ -137,4 +137,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeBoolMessage(i), Buffer(o));
assert.deepEqual(schema.decodeBoolMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeBoolMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeBoolMessage(new Uint8Array(o)), i);
}

@@ -149,4 +149,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeByteMessage(i), Buffer(o));
assert.deepEqual(schema.decodeByteMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeByteMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeByteMessage(new Uint8Array(o)), i);
}

@@ -160,4 +160,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeUintMessage(i), Buffer(o));
assert.deepEqual(schema.decodeUintMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeUintMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeUintMessage(new Uint8Array(o)), i);
}

@@ -171,4 +171,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeIntMessage(i), Buffer(o));
assert.deepEqual(schema.decodeIntMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeIntMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeIntMessage(new Uint8Array(o)), i);
}

@@ -182,4 +182,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeFloatMessage(i), Buffer(o));
assert.deepEqual(schema.decodeFloatMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeFloatMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeFloatMessage(new Uint8Array(o)), i);
}

@@ -193,4 +193,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeStringMessage(i), Buffer(o));
assert.deepEqual(schema.decodeStringMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeStringMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeStringMessage(new Uint8Array(o)), i);
}

@@ -205,4 +205,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeCompoundMessage(i), Buffer(o));
assert.deepEqual(schema.decodeCompoundMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeCompoundMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeCompoundMessage(new Uint8Array(o)), i);
}

@@ -219,4 +219,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeNestedMessage(i), Buffer(o));
assert.deepEqual(schema.decodeNestedMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeNestedMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeNestedMessage(new Uint8Array(o)), i);
}

@@ -233,4 +233,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeBoolArrayStruct({x: i}), Buffer(o));
assert.deepEqual(schema.decodeBoolArrayStruct(Buffer(o)), {x: i});
assert.deepEqual(Buffer(schema.encodeBoolArrayStruct({x: i})), Buffer(o));
assert.deepEqual(schema.decodeBoolArrayStruct(new Uint8Array(o)), {x: i});
}

@@ -244,4 +244,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeBoolArrayMessage(i), Buffer(o));
assert.deepEqual(schema.decodeBoolArrayMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeBoolArrayMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeBoolArrayMessage(new Uint8Array(o)), i);
}

@@ -256,4 +256,4 @@

function check(i, o) {
assert.deepEqual(schema.encodeRecursiveMessage(i), Buffer(o));
assert.deepEqual(schema.decodeRecursiveMessage(Buffer(o)), i);
assert.deepEqual(Buffer(schema.encodeRecursiveMessage(i)), Buffer(o));
assert.deepEqual(schema.decodeRecursiveMessage(new Uint8Array(o)), i);
}

@@ -270,4 +270,4 @@

assert.throws(function() { schema.decodeRequiredField(Buffer([0])); }, Error);
assert.doesNotThrow(function() { schema.decodeRequiredField(Buffer([1, 1, 0])); }, Error);
assert.throws(function() { schema.decodeRequiredField(new Uint8Array([0])); }, Error);
assert.doesNotThrow(function() { schema.decodeRequiredField(new Uint8Array([1, 1, 0])); }, Error);
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc