From dbebd0d70d9afbc47a42fcef57f8720396b29002 Mon Sep 17 00:00:00 2001 From: back2dos Date: Mon, 6 Mar 2017 17:57:30 +0100 Subject: [PATCH] Allow querying whether a type exists. --- src/tink/macro/Types.hx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/tink/macro/Types.hx b/src/tink/macro/Types.hx index 4a40208..87b8445 100644 --- a/src/tink/macro/Types.hx +++ b/src/tink/macro/Types.hx @@ -13,6 +13,16 @@ using tink.macro.Functions; using tink.CoreApi; class Types { + + static public function definedType(typeName:String) + return + try { + Some(Context.getType(typeName)); + } + catch (e:Dynamic) + if (Std.string(e) == 'Type not found \'$typeName\'') None; + else neko.Lib.rethrow(e); + static var types = new MapType>(); static var idCounter = 0; static public function getID(t:Type, ?reduced = true)