Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare 0.26.0 #89

Merged
merged 8 commits into from
Jun 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/hex/compiler/parser/flow/FlowCompiler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ import hex.preprocess.flow.MacroConditionalVariablesProcessor;
class FlowCompiler
{
#if macro
static function _readFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr,
?applicationAssemblerExpression : Expr ) : ExprOf<IApplicationAssembler>
public static function _readFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr,
?applicationAssemblerExpression : Expr ) : ExprOf<IApplicationAssembler>
{
LogManager.context = new MacroLoggerContext();

Expand Down
61 changes: 59 additions & 2 deletions src/hex/compiler/parser/flow/ObjectParser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ class ObjectParser extends AbstractExprParser<hex.factory.BuildRequest>
} );
this._builder.build( OBJECT( constructorVO ) );

/*case macro $keyword( $a { args } ):
trace( new haxe.macro.Printer().printExpr( e ) );
trace( keyword );
trace( args );*/

case macro when( $a { when } ).then( $a { then } ):
var vo = _getDomainListenerVO( when, then );
vo.filePosition = e.pos;
this._builder.build( DOMAIN_LISTENER( vo ) );

case macro when( $a { when } ).adapt( $a { adapt } ).then( $a { then } ):
var vo = _getDomainListenerVO( when, then, adapt );
vo.filePosition = e.pos;
this._builder.build( DOMAIN_LISTENER( vo ) );

case macro when( $a { when } ).execute( $a { adapt } ):
var vo = _getDomainListenerVO( when, null, adapt );
vo.filePosition = e.pos;
this._builder.build( DOMAIN_LISTENER( vo ) );

case _:

switch( e.expr )
Expand All @@ -84,6 +104,43 @@ class ObjectParser extends AbstractExprParser<hex.factory.BuildRequest>
}
//logger.debug(e);
}

function _getDomainListenerVO( when, then, ?adapt ) : hex.ioc.vo.DomainListenerVO
{
var callback;

if ( then == null )
{
callback = 'uniquefuckingID';
var cvo = new ConstructorVO( callback, ContextTypeList.OBJECT );
cvo.filePosition = Context.currentPos();
this._builder.build( OBJECT( cvo ) );
}
else
{
callback = ExpressionUtil.compressField( then[0] );
}

var ident = callback.split('.').shift();
var vo = new hex.ioc.vo.DomainListenerVO( ident, ExpressionUtil.getIdent( when[0] ) );

if ( when.length == 2 )
{
var arg = new hex.ioc.vo.DomainListenerVOArguments();
arg.staticRef = ExpressionUtil.compressField( when[1] );
var cb = callback.split('.');
if ( cb.length > 1 ) arg.method = cb[ 1 ];
if ( adapt != null )
{
arg.strategy = ExpressionUtil.compressField( adapt[ 0 ] );
if ( adapt.length == 2 ) arg.injectedInModule = ExpressionUtil.getBool( adapt[1] );
}
vo.arguments = [ arg ];
arg.filePosition = when[1].pos;
}

return vo;
}

function _getConstructorVO( ident : String, value : Expr ) : ConstructorVO
{
Expand Down Expand Up @@ -166,9 +223,9 @@ class ObjectParser extends AbstractExprParser<hex.factory.BuildRequest>
}

case ECall( _.expr => EConst(CIdent(keyword)), params ):
if ( this.parser.methodParser.exists( keyword ) )
if ( this.parser.buildMethodParser.exists( keyword ) )
{
return this.parser.methodParser.get( keyword )( this.parser, new ConstructorVO( ident ), params, value );
return this.parser.buildMethodParser.get( keyword )( this.parser, new ConstructorVO( ident ), params, value );
}
else
{
Expand Down
12 changes: 6 additions & 6 deletions src/hex/compiler/parser/flow/StaticFlowCompiler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ using hex.util.LambdaUtil;
class StaticFlowCompiler
{
#if macro
static public function _readFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr,
?applicationAssemblerExpression : Expr,
isExtending : Bool = false ) : Expr
public static function _readFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr,
?applicationAssemblerExpression : Expr,
isExtending : Bool = false ) : Expr
{
LogManager.context = new MacroLoggerContext();

Expand Down
12 changes: 6 additions & 6 deletions src/hex/compiler/parser/xml/StaticXmlCompiler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ import hex.util.MacroUtil;
class StaticXmlCompiler
{
#if macro
static public function _readFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr,
?applicationAssemblerExpression : Expr,
isExtending : Bool = false ) : Expr
public static function _readFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr,
?applicationAssemblerExpression : Expr,
isExtending : Bool = false ) : Expr
{
LogManager.context = new MacroLoggerContext();

Expand Down
14 changes: 7 additions & 7 deletions src/hex/compiler/parser/xml/XmlCompiler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ using StringTools;
class XmlCompiler
{
#if macro
static function _readXmlFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr,
?applicationAssemblerExpression : Expr ) : ExprOf<IApplicationAssembler>
public static function _readFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr,
?applicationAssemblerExpression : Expr ) : ExprOf<IApplicationAssembler>
{
LogManager.context = new MacroLoggerContext();

Expand All @@ -57,7 +57,7 @@ class XmlCompiler
?preprocessingVariables : Expr,
?conditionalVariables : Expr ) : ExprOf<IApplicationAssembler>
{
return XmlCompiler._readXmlFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables );
return XmlCompiler._readFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables );
}

macro public static function compileWithAssembler( assemblerExpr : Expr,
Expand All @@ -66,6 +66,6 @@ class XmlCompiler
?preprocessingVariables : Expr,
?conditionalVariables : Expr ) : ExprOf<IApplicationAssembler>
{
return XmlCompiler._readXmlFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables, assemblerExpr );
return XmlCompiler._readFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables, assemblerExpr );
}
}
14 changes: 7 additions & 7 deletions src/hex/ioc/parser/xml/XmlReader.hx
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,10 @@ class XmlReader
}
}

static function _readXmlFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr ) : ExprOf<String>
public static function _readFile( fileName : String,
?applicationContextName : String,
?preprocessingVariables : Expr,
?conditionalVariables : Expr ) : ExprOf<String>
{
var conditionalVariablesMap = MacroConditionalVariablesProcessor.parse( conditionalVariables );
var conditionalVariablesChecker = new ConditionalVariablesChecker( conditionalVariablesMap );
Expand Down Expand Up @@ -249,7 +249,7 @@ class XmlReader
?preprocessingVariables : Expr,
?conditionalVariables : Expr ) : ExprOf<String>
{
return XmlReader._readXmlFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables );
return XmlReader._readFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables );
}

macro public static function getXml( fileName : String,
Expand All @@ -258,7 +258,7 @@ class XmlReader
?conditionalVariables : Expr ) : ExprOf<Xml>
{
var tp = MacroUtil.getPack( Type.getClassName( Xml ) );
var data = XmlReader._readXmlFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables );
var data = XmlReader._readFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables );
return macro @:pos( Context.currentPos() ){ $p { tp }.parse( $data ); }
}

Expand All @@ -270,7 +270,7 @@ class XmlReader
var xmlPack = MacroUtil.getPack( Type.getClassName( Xml ) );
var applicationAssemblerTypePath = MacroUtil.getTypePath( "hex.runtime.ApplicationAssembler" );
var applicationXMLParserTypePath = MacroUtil.getTypePath( Type.getClassName( ApplicationXMLParser ) );
var data = XmlReader._readXmlFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables );
var data = XmlReader._readFile( fileName, applicationContextName, preprocessingVariables, conditionalVariables );

return macro @:pos( Context.currentPos() )
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@context( name = 'applicationContext' )
{
sender = new hex.ioc.parser.xml.mock.MockSenderModule();
receiver = new hex.ioc.parser.xml.mock.MockReceiverModule();

when( sender, hex.ioc.parser.xml.mock.MockChatModule.TEXT_INPUT )
.then( receiver.onMessage );
}
19 changes: 19 additions & 0 deletions test/context/flow/eventProxy.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@context( name = 'applicationContext' )
{
chat = new hex.ioc.parser.xml.mock.MockChatModule();
receiver = new hex.ioc.parser.xml.mock.MockReceiverModule();

@map_type( 'hex.ioc.parser.xml.mock.IMockMessageParserModule' )
parser = new hex.ioc.parser.xml.mock.MockMessageParserModule();

//Don't do that
eventProxy = new hex.event.EventProxy( receiver, receiver.onMessage );
when( chat, hex.ioc.parser.xml.mock.MockChatModule.TEXT_INPUT )
.adapt( hex.ioc.parser.xml.mock.MockChatEventAdapterStrategyMacro )
.then( eventProxy );

//Do that Instead
/*when( chat, hex.ioc.parser.xml.mock.MockChatModule.TEXT_INPUT )
.adapt( hex.ioc.parser.xml.mock.MockChatEventAdapterStrategyMacro )
.then( receiver.onMessage );*/
}
13 changes: 13 additions & 0 deletions test/context/flow/eventTrigger.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@context( name = 'applicationContext' )
{
chat = new hex.ioc.parser.xml.mock.MockChatModule();

@map_type( 'hex.ioc.parser.xml.mock.MockReceiverModule' )
receiver = new hex.ioc.parser.xml.mock.MockReceiverModule();

@map_type( 'hex.ioc.parser.xml.mock.IMockMessageParserModule' )
parser = new hex.ioc.parser.xml.mock.MockMessageParserModule();

when( chat, hex.ioc.parser.xml.mock.MockChatModule.TEXT_INPUT )
.execute( hex.ioc.parser.xml.mock.MockChatAdapterStrategyMacro );
}
8 changes: 8 additions & 0 deletions test/context/flow/macroWithAnnotation.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
<?xml version="1.0" encoding="utf-8" ?>
<root name="applicationContext">
<state id="assemblingEnd" ref="this.state.ASSEMBLING_END">
<enter command-class="hex.ioc.parser.xml.mock.MockMacroWithAnnotation" fire-once="true" />
</state>
</root>
*/
7 changes: 7 additions & 0 deletions test/context/flow/moduleListener.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@context( name = 'applicationContext' )
{
myModule = new hex.ioc.parser.xml.mock.MockModuleWithServiceCallback();

when( myService, hex.ioc.parser.xml.mock.MockStubStatefulService.BOOLEAN_VO_UPDATE )
.then( myModule.onBooleanServiceCallback );
}
8 changes: 8 additions & 0 deletions test/context/flow/moduleListeningService.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@context( name = 'applicationContext' )
{
myService = new hex.ioc.parser.xml.mock.MockStubStatefulService();
myModule = new hex.ioc.parser.xml.mock.MockModuleWithServiceCallback();

when( myService, hex.ioc.parser.xml.mock.MockStubStatefulService.BOOLEAN_VO_UPDATE )
.then( myModule.onBooleanServiceCallback );
}
10 changes: 10 additions & 0 deletions test/context/flow/moduleListeningServiceWithMapType.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@context( name = 'applicationContext' )
{
@map_type( 'hex.ioc.parser.xml.mock.IMockStubStatefulService' )
myService = new hex.ioc.parser.xml.mock.MockStubStatefulService();

myModule = new hex.ioc.parser.xml.mock.MockModuleWithServiceCallback();

when( myService, hex.ioc.parser.xml.mock.MockStubStatefulService.BOOLEAN_VO_UPDATE )
.then( myModule.onBooleanServiceCallback );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@context( name = 'applicationContext' )
{
@map_type( 'hex.ioc.parser.xml.mock.IMockDividerHelper' )
mockDividerHelper = new hex.ioc.parser.xml.mock.MockDividerHelper();

myService = new hex.ioc.parser.xml.mock.MockStubStatefulService();
myModuleA = new hex.ioc.parser.xml.mock.MockModuleWithServiceCallback();
myModuleB = new hex.ioc.parser.xml.mock.AnotherMockModuleWithServiceCallback();

when( myService, hex.ioc.parser.xml.mock.MockStubStatefulService.INT_VO_UPDATE )
.adapt( hex.ioc.parser.xml.mock.MockIntDividerEventAdapterStrategy, true )
.then( myModuleA.onFloatServiceCallback );

when( myService, hex.ioc.parser.xml.mock.MockStubStatefulService.INT_VO_UPDATE )
.adapt( hex.ioc.parser.xml.mock.MockIntDividerEventAdapterStrategy, false )
.then( myModuleB.onFloatServiceCallback );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@context( name = 'applicationContext' )
{
myService = new hex.ioc.parser.xml.mock.MockStubStatefulService();
myModule = new hex.ioc.parser.xml.mock.MockModuleWithServiceCallback();

when( myService, hex.ioc.parser.xml.mock.MockStubStatefulService.INT_VO_UPDATE )
.adapt( hex.ioc.parser.xml.mock.MockIntDividerEventAdapterStrategy, true )
.then( myModule.onFloatServiceCallback );
}
4 changes: 4 additions & 0 deletions test/context/flow/serviceToBeListened.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@context( name = 'applicationContext' )
{
myService = new hex.ioc.parser.xml.mock.MockStubStatefulService();
}
4 changes: 4 additions & 0 deletions test/context/flow/testAnnotationProviderWithInheritance.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@context( name = 'applicationContext' )
{
module = new hex.ioc.parser.xml.mock.MockModuleWithAnnotationProviding();
}
4 changes: 4 additions & 0 deletions test/context/flow/testMockObjectWithAnnotation.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@context( name = 'applicationContext' )
{
mockObjectWithAnnotation = new hex.metadata.MockObjectWithAnnotation();
}
23 changes: 23 additions & 0 deletions test/context/flow/triggerInjection.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
<?xml version="1.0" encoding="utf-8" ?>
<root name="applicationContext">

<model id="model" type="hex.mock.MockWeatherModel"/>

<config id="config" type="hex.di.mapping.MappingConfiguration">
<item map-name="temperature">
<key type="Class" value="hex.event.ITrigger<Int->Void>"/>
<value ref="model.temperature"/>
</item>
<item map-name="weather">
<key type="Class" value="hex.event.ITrigger<String->Void>"/>
<value ref="model.weather"/>
</item>
</config>

<view id="module" type="hex.mock.MockWeatherListener">
<argument ref="config"/>
</view>

</root>
*/
8 changes: 8 additions & 0 deletions test/context/flow/twoModulesListeningEachOther.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@context( name = 'applicationContext' )
{
chat = new hex.ioc.parser.xml.mock.MockChatModule();
translation = new hex.ioc.parser.xml.mock.MockTranslationModule();

when( chat, hex.ioc.parser.xml.mock.MockChatModule.TEXT_INPUT ).then( translation.onSomethingToTranslate );
when( translation ).then( chat );
}
11 changes: 11 additions & 0 deletions test/context/flow/twoModulesListeningEachOtherWithAdapter.flow
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@context( name = 'applicationContext' )
{
chat = new hex.ioc.parser.xml.mock.MockChatModule();
translation = new hex.ioc.parser.xml.mock.MockTranslationModule();

when( chat, hex.ioc.parser.xml.mock.MockChatModule.TEXT_INPUT )
.adapt( hex.ioc.parser.xml.mock.MockChatAdapterStrategy )
.then( translation.onTranslateWithTime );

when( translation ).then( chat );
}
Loading