From 41378f8808ec2d896efa6e732aada9c7e42b8f30 Mon Sep 17 00:00:00 2001 From: shoebox Date: Tue, 6 Jan 2015 10:53:36 +0000 Subject: [PATCH] Reactivate the IOS meta --- src/mirror/Cpp.hx | 1 - src/mirror/CppFieldTool.hx | 15 ++++++++++++--- src/mirror/Mirror.hx | 3 ++- src/tools/FieldTool.hx | 2 +- src/tools/FunctionTool.hx | 6 +++--- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/mirror/Cpp.hx b/src/mirror/Cpp.hx index 36896a1..3e07fd1 100644 --- a/src/mirror/Cpp.hx +++ b/src/mirror/Cpp.hx @@ -22,7 +22,6 @@ class Cpp var primitive = field.getPrimitiveName(localClass); var func = field.getFunction(); var argsCount = func.args.length; - #if munit var entryPrimitive = MetadataTools.create("cpp_primitive", field.pos, [macro $v{primitive}]); diff --git a/src/mirror/CppFieldTool.hx b/src/mirror/CppFieldTool.hx index ca547aa..534cd2b 100644 --- a/src/mirror/CppFieldTool.hx +++ b/src/mirror/CppFieldTool.hx @@ -11,6 +11,7 @@ using tools.MetadataTools; class CppFieldTool { public static inline var TagCpp = "CPP"; + public static inline var TagiOS = "IOS"; public static inline var TagDefaultLibrary = "CPP_DEFAULT_LIBRARY"; public static inline var TagPrimitivePrefix = "CPP_PRIMITIVE_PREFIX"; @@ -19,10 +20,16 @@ class CppFieldTool return field.meta.has(TagCpp); } + public static function isIos(field:Field):Bool + { + return field.meta.has(TagiOS); + } + public static function getPrimitiveName(field:Field, localClass:ClassType):String { - var entry:MetadataEntry = field.meta.get(TagCpp); + var entry:MetadataEntry = isIos(field) ? field.meta.get(TagiOS) + : field.meta.get(TagCpp); var result:String; if (entry.params.length > 1) { @@ -55,9 +62,11 @@ class CppFieldTool public static function getLibraryName(field:Field, localClass:ClassType):String { - var entry:MetadataEntry = field.meta.get(TagCpp); + var entry:MetadataEntry = isIos(field) ? field.meta.get(TagiOS) + : field.meta.get(TagCpp); var meta = localClass.meta.get(); - if (entry.params.length == 0 && !meta.has(TagDefaultLibrary)) + if ((entry.params == null || entry.params.length == 0) + && !meta.has(TagDefaultLibrary)) { Context.error("Not default C++ library defined globary or locally", field.pos); diff --git a/src/mirror/Mirror.hx b/src/mirror/Mirror.hx index f577a70..539e56a 100644 --- a/src/mirror/Mirror.hx +++ b/src/mirror/Mirror.hx @@ -28,6 +28,7 @@ class Mirror var fields = Context.getBuildFields(); var isCpp = #if munit true #else Context.defined("cpp") #end; + var isIos = #if munit true #else Context.defined("ios") #end; var isAndroid = #if munit true #else Context.defined("android") #end; var isOpenFl = Context.defined("openfl") || Context.defined("nme"); var isEnabled = #if (openfl || munit) true #else false #end; @@ -53,7 +54,7 @@ class Mirror fieldDisabled = field.meta.has(MirrorDisabledMeta); if (!fieldDisabled) { - if (isCpp && field.isCpp()) + if ((isCpp && field.isCpp()) || (isIos && field.isIos())) { result = Cpp.build(field, localClass); } diff --git a/src/tools/FieldTool.hx b/src/tools/FieldTool.hx index 599c5af..29141ac 100644 --- a/src/tools/FieldTool.hx +++ b/src/tools/FieldTool.hx @@ -19,7 +19,7 @@ class FieldTool return result; } - static inline function isStaticField(field:Field):Bool + public static inline function isStaticField(field:Field):Bool { var result = Lambda.has(field.access, AStatic); return result; diff --git a/src/tools/FunctionTool.hx b/src/tools/FunctionTool.hx index 8323a21..ba3ff98 100644 --- a/src/tools/FunctionTool.hx +++ b/src/tools/FunctionTool.hx @@ -4,19 +4,19 @@ import haxe.macro.Expr; class FunctionTool { - static inline function getArgsNames(func:Function):Array + static public inline function getArgsNames(func:Function):Array { var result:Array = [for (a in func.args) macro $i{a.name}]; return result.copy(); } - static inline function isStaticField(field:Field):Bool + static public inline function isStaticField(field:Field):Bool { var result = Lambda.has(field.access, AStatic); return result; } - static function createReturnExpr(func:Function, name:String, + static public function createReturnExpr(func:Function, name:String, args:Array):Expr { var expr:Expr = macro "";