Skip to content

Commit

Permalink
Reactivate the IOS meta
Browse files Browse the repository at this point in the history
  • Loading branch information
shoebox committed Jan 6, 2015
1 parent 3a725c2 commit 41378f8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/mirror/Cpp.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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}]);
Expand Down
15 changes: 12 additions & 3 deletions src/mirror/CppFieldTool.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/mirror/Mirror.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/FieldTool.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/tools/FunctionTool.hx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import haxe.macro.Expr;

class FunctionTool
{
static inline function getArgsNames(func:Function):Array<Expr>
static public inline function getArgsNames(func:Function):Array<Expr>
{
var result:Array<Expr> = [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>):Expr
{
var expr:Expr = macro "";
Expand Down

0 comments on commit 41378f8

Please sign in to comment.