[provider] return null instead throw error
This commit is contained in:
@@ -8,8 +8,8 @@
|
|||||||
<source path="src"/>
|
<source path="src"/>
|
||||||
<assets path="src" rename="image" include="*.png"/>
|
<assets path="src" rename="image" include="*.png"/>
|
||||||
|
|
||||||
<haxelib name="lime" version="7.2.1"/>
|
<haxelib name="lime" version="7.3.0"/>
|
||||||
<haxelib name="openfl" version="8.8.0"/>
|
<haxelib name="openfl" version="8.9.0"/>
|
||||||
<haxelib name="hxcpp" version="4.0.8"/>
|
<haxelib name="hxcpp" version="4.0.8"/>
|
||||||
<haxelib name="promhx" version="1.1.0"/>
|
<haxelib name="promhx" version="1.1.0"/>
|
||||||
<haxelib name="yaml" version="1.3.0"/>
|
<haxelib name="yaml" version="1.3.0"/>
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package haxework.macro;
|
package haxework.macro;
|
||||||
|
|
||||||
|
import haxe.DynamicAccess;
|
||||||
|
|
||||||
class PositionYamlParser {
|
class PositionYamlParser {
|
||||||
|
|
||||||
private var filename:String;
|
private var filename:String;
|
||||||
@@ -18,16 +20,16 @@ class PositionYamlParser {
|
|||||||
parseBlock(result);
|
parseBlock(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseBlock(result:Dynamic):Void {
|
private function parseBlock(result:DynamicAccess<Dynamic>):Void {
|
||||||
for (field in Reflect.fields(result)) {
|
for (field in result.keys()) {
|
||||||
var offset = content.indexOf(field, cache.get(field));
|
var offset = content.indexOf(field, cache.get(field));
|
||||||
cache.set(field, offset);
|
cache.set(field, offset);
|
||||||
Reflect.setField(result, "$" + field, {
|
result.set("$" + field, {
|
||||||
min:offset,
|
min:offset,
|
||||||
max:offset + field.length,
|
max:offset + field.length,
|
||||||
file:filename,
|
file:filename,
|
||||||
});
|
});
|
||||||
var value = Reflect.field(result, field);
|
var value = result.get(field);
|
||||||
if (Std.is(value, Array)) {
|
if (Std.is(value, Array)) {
|
||||||
for (item in cast(value, Array<Dynamic>)) {
|
for (item in cast(value, Array<Dynamic>)) {
|
||||||
parseBlock(item);
|
parseBlock(item);
|
||||||
@@ -38,7 +40,7 @@ class PositionYamlParser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parse(filename:String, content:String, result:Dynamic):Void {
|
public static inline function parse(filename:String, content:String, result:Dynamic):Void {
|
||||||
new PositionYamlParser(filename, content, result).parseAll();
|
new PositionYamlParser(filename, content, result).parseAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ class Provider {
|
|||||||
instances.set(key, instance);
|
instances.set(key, instance);
|
||||||
return instance;
|
return instance;
|
||||||
} else {
|
} else {
|
||||||
throw 'Factory for "${key}" not found';
|
return null;
|
||||||
|
//throw 'Factory for "${key}" not found';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user