Skip to content

Commit

Permalink
Merge pull request #29 from DoclerLabs/develop
Browse files Browse the repository at this point in the history
prepare 0.29.2
  • Loading branch information
aliokan authored Sep 12, 2017
2 parents 1cd3bef + 3bc88a9 commit e808219
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 38 deletions.
15 changes: 3 additions & 12 deletions src/hex/compiletime/basic/CompileTimeContextFactory.hx
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,6 @@ class CompileTimeContextFactory
this._expressions.push( macro @:mergeBlock { applicationContext.dispatch( $messageType ); } );
}

public function dispatchIdleMode() : Void
{
var messageType = MacroUtil.getStaticVariable( "hex.core.ApplicationAssemblerMessage.IDLE_MODE" );
this._expressions.push( macro @:mergeBlock { applicationContext.dispatch( $messageType ); } );
}

//
public function preprocess( vo : hex.vo.PreProcessVO ) : Void
{
Expand All @@ -168,11 +162,7 @@ class CompileTimeContextFactory
//listen to CoreFactory
public function onRegister( key : String, instance : Dynamic ) : Void
{
if ( this._propertyVOLocator.isRegisteredWithKey( key ) )
{
this._propertyVOLocator.locate( key )
.map( function( property ) this._expressions.push( macro @:mergeBlock ${ PropertyFactory.build( this, property ) } ) );
}
this.buildProperty( key );
}

public function onUnregister( key : String ) : Void { }
Expand Down Expand Up @@ -210,6 +200,7 @@ class CompileTimeContextFactory
{
this._propertyVOLocator.locate( key )
.map( function( property ) this._expressions.push( macro @:mergeBlock ${ PropertyFactory.build( this, property ) } ) );
this._propertyVOLocator.unregister( key );
}
}

Expand Down Expand Up @@ -249,7 +240,7 @@ class CompileTimeContextFactory

public function callModuleInitialisation() : Void
{
this._moduleLocator.values().map( function(moduleName) this._expressions.push( macro @:mergeBlock { $i{moduleName}.initialize(); } ) );
this._moduleLocator.values().map( function(moduleName) this._expressions.push( macro @:mergeBlock { $i{moduleName}.initialize(applicationContext); } ) );
this._moduleLocator.clear();
var messageType = MacroUtil.getStaticVariable( "hex.core.ApplicationAssemblerMessage.MODULES_INITIALIZED" );
this._expressions.push( macro @:mergeBlock { applicationContext.dispatch( $messageType ); } );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class StaticCompileTimeContextFactory extends CompileTimeContextFactory

if ( !constructorVO.lazy )
{
this._expressions.push( macro @:mergeBlock { $result; coreFactory.register( $v { id }, $i { id } ); this.$id = $i { id }; } );
this._expressions.push( macro @:mergeBlock { $result; /*coreFactory.register( $v { id }, $i { id } );*/ this.$id = $i { id }; } );
}

this._coreFactory.register( id, result );
Expand Down
7 changes: 6 additions & 1 deletion src/hex/compiletime/flow/parser/ObjectParser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,12 @@ class ObjectParser extends AbstractExprParser<hex.compiletime.basic.BuildRequest
constructorVO.arguments = [];
constructorVO.factory = factory;
constructorVO.staticCall = staticCall;


case EConst( ee ):
constructorVO.type = ExpressionUtil.compressField( e );
constructorVO.arguments = [];
constructorVO.staticCall = field;

case _:
logger.error( e.expr );
}
Expand Down
1 change: 0 additions & 1 deletion src/hex/core/ApplicationAssemblerMessage.hx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class ApplicationAssemblerMessage
static public var DOMAIN_LISTENERS_ASSIGNED = new MessageType( "onDomainListenersAssigned" );
static public var MODULES_INITIALIZED = new MessageType( "onModulesInitialized" );
static public var ASSEMBLING_END = new MessageType( "onAssemblingEnd" );
static public var IDLE_MODE = new MessageType( "onIdleMode" );

/** @private */
function new()
Expand Down
6 changes: 0 additions & 6 deletions src/hex/runtime/basic/RunTimeContextFactory.hx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ class RunTimeContextFactory
this.buildAllObjects();
this.callAllMethods();
this.dispatchAssemblingEnd();
this.dispatchIdleMode();
}

public function dispose() : Void
Expand Down Expand Up @@ -145,11 +144,6 @@ class RunTimeContextFactory
this._contextDispatcher.dispatch( ApplicationAssemblerMessage.ASSEMBLING_END );
}

public function dispatchIdleMode() : Void
{
this._contextDispatcher.dispatch( ApplicationAssemblerMessage.IDLE_MODE );
}

//
public function preprocess( vo : hex.vo.PreProcessVO ) : Void
{
Expand Down
2 changes: 1 addition & 1 deletion test/context/flow/hashmapFilledWithReferences.flow
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@context( name = 'applicationContext' )
{
fruits = new hex.collection.HashMap<Any, hex.mock.MockFruitVO>
fruits = new hex.collection.HashMap<Dynamic, hex.mock.MockFruitVO>
([
"0" => fruit0,
1 => fruit1,
Expand Down
2 changes: 2 additions & 0 deletions test/context/flow/instanceWithStaticMethod.flow
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
gateway = "http://localhost/amfphp/gateway.php";
service = hex.mock.MockServiceProvider.getInstance();
service.setGateway( gateway );

random = Math.random();
}
9 changes: 9 additions & 0 deletions test/hex/compiletime/flow/BasicFlowCompilerTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,15 @@ class BasicFlowCompilerTest
Assert.isInstanceOf( service, MockServiceProvider );
Assert.equals( "http://localhost/amfphp/gateway.php", MockServiceProvider.getInstance().getGateway(), "" );
}

@Test( "test static method on class without classpath" )
public function testStaticMethodOnClassWitoutClasspath() : Void
{
this._applicationAssembler = BasicFlowCompiler.compile( "context/flow/instanceWithStaticMethod.flow" );

var random = this._getCoreFactory().locate( "random" );
Assert.isInstanceOf( random, Float );
}

@Test( "test building instance with static method and arguments" )
public function testBuildingInstanceWithStaticMethodAndArguments() : Void
Expand Down
22 changes: 14 additions & 8 deletions test/hex/compiletime/flow/BasicStaticFlowCompilerTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import hex.di.mapping.MappingChecker;
import hex.di.mapping.MappingConfiguration;
import hex.domain.ApplicationDomainDispatcher;
import hex.domain.Domain;
import hex.error.NoSuchElementException;
import hex.mock.AnotherMockClass;
import hex.mock.ArrayOfDependenciesOwner;
import hex.mock.IAnotherMockInterface;
Expand All @@ -30,7 +29,6 @@ import hex.mock.MockRectangle;
import hex.mock.MockServiceProvider;
import hex.mock.MockTriggerListener;
import hex.runtime.ApplicationAssembler;
import hex.runtime.basic.ApplicationContext;
import hex.structures.Point;
import hex.structures.Size;
import hex.unittest.assertion.Assert;
Expand Down Expand Up @@ -93,8 +91,8 @@ class BasicStaticFlowCompilerTest
var code = BasicStaticFlowCompiler.compile( BasicStaticFlowCompilerTest.applicationAssembler, "context/flow/primitives/string.flow", "BasicStaticFlowCompiler_testBuildingStringWithAssemblerStaticProperty" );
code.execute();

var s : String = BasicStaticFlowCompilerTest.applicationAssembler.getApplicationContext( "BasicStaticFlowCompiler_testBuildingStringWithAssemblerStaticProperty", ApplicationContext ).getCoreFactory().locate( "s" );
Assert.equals( "hello", s );
Assert.equals( BasicStaticFlowCompilerTest.applicationAssembler, code.applicationAssembler );
Assert.equals( "hello", code.locator.s );
}

@Test( "test read twice the same context" )
Expand Down Expand Up @@ -473,6 +471,15 @@ class BasicStaticFlowCompilerTest
Assert.equals( "http://localhost/amfphp/gateway.php", code.locator.service.getGateway() );
Assert.equals( "http://localhost/amfphp/gateway.php", MockServiceProvider.getInstance().getGateway() );
}

@Test( "test static method on class without classpath" )
public function testStaticMethodOnClassWitoutClasspath() : Void
{
var code = BasicStaticFlowCompiler.compile( this._myApplicationAssembler, "context/flow/instanceWithStaticMethod.flow", "BasicStaticFlowCompiler_testStaticMethodOnClassWitoutClasspath" );
code.execute();

Assert.isInstanceOf( code.locator.random, Float );
}

@Test( "test building instance with static method and arguments" )
public function testBuildingInstanceWithStaticMethodAndArguments() : Void
Expand Down Expand Up @@ -802,11 +809,10 @@ class BasicStaticFlowCompilerTest
{
var code = BasicStaticFlowCompiler.compile( this._myApplicationAssembler, "context/flow/includeWithIfAttribute.flow", "BasicStaticFlowCompiler_testIncludeFailsWithIfAttribute", null, [ "prodz" => false, "testing" => true, "releasing" => true ] );
code.execute();

var coreFactory = this._myApplicationAssembler.getApplicationContext( "BasicStaticFlowCompiler_testIncludeFailsWithIfAttribute", ApplicationContext ).getCoreFactory();
Assert.methodCallThrows( NoSuchElementException, coreFactory, coreFactory.locate, [ "message" ], "'NoSuchElementException' should be thrown" );

Assert.isFalse( Reflect.hasField(code.locator, "message"), "locator shouldn't have message field" );
}

@Test( "test building mapping configuration" )
public function testBuildingMappingConfiguration() : Void
{
Expand Down
13 changes: 5 additions & 8 deletions test/hex/compiletime/xml/BasicStaticXmlCompilerTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import hex.di.mapping.MappingConfiguration;
import hex.domain.ApplicationDomainDispatcher;
import hex.domain.Domain;
import hex.error.Exception;
import hex.error.NoSuchElementException;
import hex.mock.AnotherMockClass;
import hex.mock.ArrayOfDependenciesOwner;
import hex.mock.IAnotherMockInterface;
Expand All @@ -26,7 +25,6 @@ import hex.mock.MockReceiver;
import hex.mock.MockRectangle;
import hex.mock.MockServiceProvider;
import hex.runtime.ApplicationAssembler;
import hex.runtime.basic.ApplicationContext;
import hex.structures.Size;
import hex.unittest.assertion.Assert;

Expand Down Expand Up @@ -87,9 +85,9 @@ class BasicStaticXmlCompilerTest
BasicStaticXmlCompilerTest.applicationAssembler = new ApplicationAssembler();
var code = BasicStaticXmlCompiler.compile( BasicStaticXmlCompilerTest.applicationAssembler, "context/xml/primitives/string.xml", "BasicStaticXmlCompiler_testBuildingStringWithAssemblerStaticProperty" );
code.execute();
var s : String = BasicStaticXmlCompilerTest.applicationAssembler.getApplicationContext( "BasicStaticXmlCompiler_testBuildingStringWithAssemblerStaticProperty", ApplicationContext ).getCoreFactory().locate( "s" );
Assert.equals( "hello", s );

Assert.equals( BasicStaticXmlCompilerTest.applicationAssembler, code.applicationAssembler );
Assert.equals( "hello", code.locator.s );
}

//Reading twice the same context cannot be tested
Expand Down Expand Up @@ -758,9 +756,8 @@ class BasicStaticXmlCompilerTest
{
var code = BasicStaticXmlCompiler.compile( this._applicationAssembler, "context/xml/static/includeWithIfAttribute.xml", "BasicStaticXmlCompiler_testIncludeFailsWithIfAttribute", null, [ "prodz2" => false, "testing2" => true, "releasing2" => true ] );
code.execute();

var coreFactory = this._applicationAssembler.getApplicationContext( "BasicStaticXmlCompiler_testIncludeFailsWithIfAttribute", ApplicationContext ).getCoreFactory();
Assert.methodCallThrows( NoSuchElementException, coreFactory, coreFactory.locate, [ "message" ], "'NoSuchElementException' should be thrown" );

Assert.isFalse( Reflect.hasField(code.locator, "message"), "locator shouldn't have message field" );
}

@Test( "test file preprocessor with Xml file" )
Expand Down

0 comments on commit e808219

Please sign in to comment.