@colyseus/schema
Advanced tools
Comparing version 0.4.47 to 0.4.48
@@ -73,3 +73,3 @@ "use strict"; | ||
map(function (childType) { return "#include \"" + childType + ".hpp\""; }). | ||
join("\n") + "\n\nusing namespace colyseus::schema;\n\n" + (namespace ? "namespace " + namespace + " {" : "") + "\nclass " + klass.name + " : public " + klass.extends + " {\npublic:\n" + klass.properties.map(function (prop) { return generateProperty(prop); }).join("\n") + "\n\n\t" + klass.name + "() {\n\t\tthis->_indexes = " + generateAllIndexes(allProperties) + ";\n\t\tthis->_types = " + generateAllTypes(allProperties) + ";\n\t\tthis->_childPrimitiveTypes = " + generateAllChildPrimitiveTypes(allProperties) + ";\n\t\tthis->_childSchemaTypes = " + generateAllChildSchemaTypes(allProperties) + ";\n\t}\n\nprotected:\n" + Object.keys(propertiesPerType).map(function (type) { | ||
join("\n") + "\n\nusing namespace colyseus::schema;\n\n" + (namespace ? "namespace " + namespace + " {" : "") + "\nclass " + klass.name + " : public " + klass.extends + " {\npublic:\n" + klass.properties.map(function (prop) { return generateProperty(prop); }).join("\n") + "\n\n\t" + klass.name + "() {\n\t\tthis->_indexes = " + generateAllIndexes(allProperties) + ";\n\t\tthis->_types = " + generateAllTypes(allProperties) + ";\n\t\tthis->_childPrimitiveTypes = " + generateAllChildPrimitiveTypes(allProperties) + ";\n\t\tthis->_childSchemaTypes = " + generateAllChildSchemaTypes(allProperties) + ";\n\t}\n\n\t~" + klass.name + "() {\n\t\t" + generateDestructors(allProperties).join("\n\t\t") + "\n\t}\n\nprotected:\n" + Object.keys(propertiesPerType).map(function (type) { | ||
return generateGettersAndSetters(klass, type, propertiesPerType[type]); | ||
@@ -196,2 +196,12 @@ }). | ||
} | ||
function generateDestructors(properties) { | ||
return properties.map(function (property, i) { | ||
if (property.childType) { | ||
return "delete this->" + property.name + ";"; | ||
} | ||
else { | ||
return null; | ||
} | ||
}).filter(function (r) { return r !== null; }); | ||
} | ||
function getAllProperties(klass, allClasses) { | ||
@@ -198,0 +208,0 @@ var properties = []; |
{ | ||
"name": "@colyseus/schema", | ||
"version": "0.4.47", | ||
"version": "0.4.48", | ||
"description": "Schema-based binary serializer / de-serializer.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
149834
3623