UNPKG

tolk-codegen

Version:

## Example generator ### Create builder file in root folder ``builder.ts``

30 lines (29 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.travel = travel; const decorators_1 = require("./decorators"); const core_1 = require("@ton/core"); function travel(type, callback, deep = false) { const prototype = type.prototype; const props = Reflect.getMetadata(decorators_1.MetadataKey.PROPERTIES, prototype) || []; props.forEach((propertyKey) => { const buildType = Reflect.getMetadata(decorators_1.MetadataKey.DATATYPE, prototype, propertyKey); let size = Reflect.getMetadata(decorators_1.MetadataKey.SIZE, prototype, propertyKey); const type = Reflect.getMetadata("design:type", prototype, propertyKey); const dict = Reflect.getMetadata(decorators_1.MetadataKey.DICT, prototype, propertyKey); const mayBe = Reflect.getMetadata(decorators_1.MetadataKey.MAY_BE, prototype, propertyKey); if (!buildType) throw 'undefined data type'; if ((buildType == decorators_1.DataType.REF) && !(type == core_1.Cell) && deep) { travel(type, callback, deep); } callback(prototype, { name: propertyKey, buildType, size, type, dict, mayBe: !!mayBe }); }); }