Comparing version 0.0.4 to 0.0.6
{ | ||
"name": "ludi", | ||
"version": "0.0.4", | ||
"version": "0.0.6", | ||
"author": "John Susek <ludi@johnsolo.net>", | ||
@@ -5,0 +5,0 @@ "bin": "./driver.mjs", |
@@ -79,2 +79,8 @@ import { capitalize, camelCase, deindent, addSlashes, cleanIndent, stripQuotes } from './util.js'; | ||
// Special case for Scene | ||
if (tag === 'h2d.Scene' && instance === 's2d') { | ||
let params = heaps.constructorParams(tag); | ||
values = args(params, props, tag); | ||
} | ||
// Direct assignment e.g. | ||
@@ -84,3 +90,3 @@ // <Tile name="tile" :value="new Tile()"> | ||
// tile = new Tile() | ||
if (props.value) { | ||
else if (props.value) { | ||
let value = props.value; | ||
@@ -97,17 +103,19 @@ if (!value.startsWith('[')) value = addSlashes(value) | ||
// tile = Tile.fromColor(0xFFFFFF) | ||
let staticConstructor = heaps.findStaticConstructor(props, tag); | ||
if (staticConstructor) { | ||
let params = heaps.staticParams(tag, staticConstructor); | ||
values = args(params, props, staticConstructor); | ||
code += `${instance} = ${tag}.${camelCase(staticConstructor)}(${values.values});\n`; | ||
} | ||
// Create from constructor e.g. | ||
// <Bitmap name="bmp" :tile="mytile"> | ||
// -> | ||
// bmp = new Bitmap(mytile) | ||
else { | ||
let constructor = tag; | ||
let params = heaps.constructorParams(constructor); | ||
values = args(params, props, constructor); | ||
code += `${instance} = new ${constructor}(${values.values});\n`; | ||
let staticConstructor = heaps.findStaticConstructor(props, tag); | ||
if (staticConstructor) { | ||
let params = heaps.staticParams(tag, staticConstructor); | ||
values = args(params, props, staticConstructor); | ||
code += `${instance} = ${tag}.${camelCase(staticConstructor)}(${values.values});\n`; | ||
} | ||
// Create from constructor e.g. | ||
// <Bitmap name="bmp" :tile="mytile"> | ||
// -> | ||
// bmp = new Bitmap(mytile) | ||
else { | ||
let params = heaps.constructorParams(tag); | ||
values = args(params, props, tag); | ||
code += `${instance} = new ${tag}(${values.values});\n`; | ||
} | ||
} | ||
@@ -114,0 +122,0 @@ |
@@ -21,2 +21,4 @@ import * as hxgen from './hxgen'; | ||
if (!name && tag === 'Scene') name = 's2d'; | ||
if (name) { | ||
@@ -27,5 +29,2 @@ let klass = `${ns}.${tag}`; | ||
} | ||
else if (tag === 'Scene') { | ||
name = 's2d'; | ||
} | ||
else if (!['App', 'Window'].includes(tag)) { | ||
@@ -37,3 +36,3 @@ throw Error(`Missing required property 'name' on '${tag}'`); | ||
if (tag === 'Window') { | ||
if (['App', 'Window'].includes(tag) && props) { | ||
for (let prop of Object.entries(props)) { | ||
@@ -40,0 +39,0 @@ code.body += hxgen.handler(klass)(prop); |
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
9745426
131074