Skip to content

Commit

Permalink
Merge pull request #59 from DoclerLabs/develop
Browse files Browse the repository at this point in the history
prepare 0.24.0
  • Loading branch information
aliokan authored Jun 27, 2017
2 parents e21610a + d70bc01 commit 1899801
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/hex/di/mapping/MappingChecker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -136,21 +136,28 @@ class MappingChecker
var a : Array<Expr> = [];
for ( arg in func.args )
{
var p = Context.currentPos();
var isInstance = Context.unify( Context.resolveType( arg.type, p ), Context.resolveType( macro:MappingDefinition, p ) );
var isArray = Context.unify( Context.resolveType( arg.type, p ), Context.resolveType( macro:Array<MappingDefinition>, p ) );

if ( a.length == 0 )
var isDynamic = switch( arg.type )
{
if ( isInstance ) a.push( macro @:mergeBlock { var __injectInto__ = this.__map( [$i{arg.name}], Type.resolveClass( $v {Context.getLocalClass().toString()} ) ); } );
if ( isArray ) a.push( macro @:mergeBlock { var __injectInto__ = this.__map( $i{arg.name}, Type.resolveClass( $v {Context.getLocalClass().toString()} ) ); } );
case TPath( t ) if ( t.name == 'Dynamic' ) : true;
case _ : false;
}
else
if ( !isDynamic )
{
if ( isInstance ) a.push( macro @:mergeBlock { __injectInto__ = this.__map( [$i{arg.name}], Type.resolveClass( $v {Context.getLocalClass().toString()} ), __injectInto__ ); } );
if ( isArray ) a.push( macro @:mergeBlock { __injectInto__ = this.__map( $i{arg.name}, Type.resolveClass( $v {Context.getLocalClass().toString()} ), __injectInto__ ); } );
var p = Context.currentPos();
var isInstance = Context.unify( Context.resolveType( arg.type, p ), Context.resolveType( macro:MappingDefinition, p ) );
var isArray = Context.unify( Context.resolveType( arg.type, p ), Context.resolveType( macro:Array<MappingDefinition>, p ) );

if ( a.length == 0 )
{
if ( isInstance ) a.push( macro @:mergeBlock { var __injectInto__ = this.__map( [$i{arg.name}], Type.resolveClass( $v {Context.getLocalClass().toString()} ) ); } );
if ( isArray ) a.push( macro @:mergeBlock { var __injectInto__ = this.__map( $i{arg.name}, Type.resolveClass( $v {Context.getLocalClass().toString()} ) ); } );
}
else
{
if ( isInstance ) a.push( macro @:mergeBlock { __injectInto__ = this.__map( [$i{arg.name}], Type.resolveClass( $v {Context.getLocalClass().toString()} ), __injectInto__ ); } );
if ( isArray ) a.push( macro @:mergeBlock { __injectInto__ = this.__map( $i{arg.name}, Type.resolveClass( $v {Context.getLocalClass().toString()} ), __injectInto__ ); } );
}
}

}

if ( a.length > 0 )
Expand Down Expand Up @@ -250,4 +257,4 @@ class MappingChecker
var filtered = mappings.filter( function(e) return dependencies.indexOf( e.fromType + '|' + (e.withName==null?"":e.withName) ) != -1 );
return filtered.length == mappings.length && dependencies.length == mappings.length;
}
}
}

0 comments on commit 1899801

Please sign in to comment.