-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from shoebox/feature/refactoring
All : Add - Refactoring
- Loading branch information
Showing
48 changed files
with
1,990 additions
and
935 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# mtask | ||
bin | ||
gen | ||
report | ||
.temp | ||
lib | ||
|
||
# munit and mcover | ||
/.mcover | ||
TestSuite.hx | ||
|
||
# OS junk | ||
Thumbs.db | ||
.DS_Store | ||
|
||
/storefront-companion.sublime-workspace | ||
/storefront-companion.sublime-project | ||
*.hxproj | ||
node_modules | ||
|
||
/.idea/ | ||
|
||
*.iml | ||
|
||
#iOS | ||
*.a | ||
*.ipa | ||
*.so | ||
*.DSYM | ||
*.DSYM.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version=munit | ||
src=test/src | ||
bin=bin | ||
report=report | ||
hxml=build.hxml | ||
classPaths=src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
Copyright (c) 2013, shoe[box] | ||
All rights reserved. | ||
Copyright (c) 2014 shoe[box] | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
|
||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
## Flash 9+ | ||
-main TestMain | ||
-lib munit | ||
-lib hamcrest | ||
-cp src | ||
-cp test/extension/src | ||
-cp test/src | ||
-swf-version 11 | ||
-swf bin/as3_test.swf | ||
|
||
--next | ||
|
||
## JavaScript | ||
-main TestMain | ||
-lib munit | ||
-lib hamcrest | ||
-cp src | ||
-cp test/extension/src | ||
-cp test/src | ||
-js bin/js_test.js | ||
|
||
--next | ||
|
||
## Neko | ||
-main TestMain | ||
-lib munit | ||
-lib hamcrest | ||
-cp src | ||
-cp test/extension/src | ||
-cp test/src | ||
-neko bin/neko_test.n | ||
|
||
--next | ||
|
||
## CPP | ||
-main TestMain | ||
-lib munit | ||
-lib hamcrest | ||
-cp src | ||
-cp test/extension/src | ||
-cp test/src | ||
#-D HXCPP_M64 | ||
-cpp bin/cpp_test | ||
|
||
-cmd haxelib run openfl test cpp -debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<project> | ||
|
||
<meta title="Validation" package="org.intheboxmacro.validation" | ||
version="1.0.0" company="OpenFL" /> | ||
<app file="TestMain" main="TestMain" path="bin" /> | ||
|
||
<include path="test/extension/" /> | ||
<source path="test/extension/src" /> | ||
<source path="test/src" /> | ||
<source path="src" /> | ||
|
||
<haxelib name="openfl" /> | ||
<haxelib name="munit" /> | ||
<haxelib name="mlib" /> | ||
<haxelib name="hamcrest" /> | ||
<haxelib name="format" /> | ||
|
||
<!-- <template path="src/index.html" rename="index.html" if="html5" /> | ||
--> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,16 @@ | ||
/* | ||
Copyright (c) 2013, shoe[box] | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
package ; | ||
|
||
import org.shoebox.macros.*; | ||
|
||
#if macro | ||
import haxe.macro.Context; | ||
import haxe.macro.Expr; | ||
#end | ||
|
||
/** | ||
* ... | ||
* @author shoe[box] | ||
*/ | ||
|
||
class ShortCuts{ | ||
|
||
// -------o constructor | ||
|
||
/** | ||
* constructor | ||
* | ||
* @param | ||
* @return void | ||
*/ | ||
public function new() { | ||
|
||
} | ||
|
||
// -------o public | ||
#if macro | ||
|
||
/** | ||
* | ||
* | ||
* @public | ||
* @return void | ||
*/ | ||
static public function inject( ) : Array<Field> { | ||
return MacroInjector.inject( ); | ||
} | ||
|
||
/** | ||
* | ||
* | ||
* @public | ||
* @return void | ||
*/ | ||
static public function mirrors( ) : Array<Field> { | ||
return MacroMirrors.build( ); | ||
} | ||
|
||
/** | ||
* | ||
* | ||
* @public | ||
* @return void | ||
*/ | ||
static public function errorReport( ) : Array<Field> { | ||
return MacroErrReport.report( ); | ||
} | ||
|
||
#end | ||
|
||
// -------o protected | ||
|
||
|
||
|
||
// -------o misc | ||
class ShortCuts | ||
{ | ||
function new(){} | ||
|
||
} | ||
static public function mirrors( ):Array<Field> | ||
{ | ||
return mirror.Mirror.build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package mirror; | ||
|
||
import haxe.macro.Context; | ||
import haxe.macro.Expr; | ||
import haxe.macro.Type.ClassType; | ||
|
||
using haxe.macro.Tools; | ||
using mirror.CppFieldTool; | ||
using tools.ExprTool; | ||
using tools.FieldTool; | ||
using tools.FunctionTool; | ||
using tools.MetadataTools; | ||
using tools.VariableTool; | ||
|
||
class Cpp | ||
{ | ||
function new(){} | ||
|
||
public static function build(field:Field, localClass:ClassType):Field | ||
{ | ||
var library = field.getLibraryName(localClass); | ||
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}]); | ||
field.meta.push(entryPrimitive); | ||
|
||
var entryLibrary = MetadataTools.create("cpp_library", field.pos, | ||
[macro $v{library}]); | ||
field.meta.push(entryLibrary); | ||
#end | ||
|
||
#if (verbose_mirrors) | ||
Sys.println($v{library} + " :: " + $v{primitive} + '($argsCount)'); | ||
#end | ||
|
||
var fieldName = getMirrorName(field.name); | ||
var args = func.getArgsNames(); | ||
var argsCount = args.length; | ||
var returnExpr = func.createReturnExpr(fieldName, args); | ||
var result = func.create(fieldName, field.pos); | ||
if (Context.defined("cpp")) | ||
{ | ||
func.expr = macro | ||
{ | ||
if ($i{fieldName} == null) | ||
{ | ||
$i{fieldName} = cpp.Lib.load($v{library}, $v{primitive}, $v{argsCount}); | ||
#if verbose_mirrors | ||
Sys.println("Lib not loaded, loading it"); | ||
Sys.println($v{library} + "::" + $v{primitive} + '($argsCount)'); | ||
#end | ||
} | ||
$returnExpr; | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
static inline function getMirrorName(name:String) | ||
{ | ||
return 'mirror_cpp_$name'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package mirror; | ||
|
||
import haxe.macro.Context; | ||
import haxe.macro.Expr; | ||
import haxe.macro.Type.ClassType; | ||
|
||
using tools.ExprTool; | ||
using tools.FieldTool; | ||
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"; | ||
|
||
public static function isCpp(field:Field):Bool | ||
{ | ||
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 = isIos(field) ? field.meta.get(TagiOS) | ||
: field.meta.get(TagCpp); | ||
var result:String; | ||
if (entry.params.length > 1) | ||
{ | ||
result = entry.params[1].getString(); | ||
} | ||
else | ||
{ | ||
var prefix = ""; | ||
var func = field.getFunction(); | ||
var context = Context.getLocalClass(); | ||
var metas = localClass.meta.get(); | ||
if ( metas.has(TagPrimitivePrefix)) | ||
{ | ||
entry = metas.get(TagPrimitivePrefix); | ||
if (entry.params.length == 0) | ||
{ | ||
Context.error("C++ primitive tag is defined without value", | ||
field.pos); | ||
} | ||
|
||
prefix = entry.params[0].getString() + '_'; | ||
} | ||
|
||
result = prefix + field.name; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
public static function getLibraryName(field:Field, | ||
localClass:ClassType):String | ||
{ | ||
var entry:MetadataEntry = isIos(field) ? field.meta.get(TagiOS) | ||
: field.meta.get(TagCpp); | ||
var meta = localClass.meta.get(); | ||
if ((entry.params == null || entry.params.length == 0) | ||
&& !meta.has(TagDefaultLibrary)) | ||
{ | ||
Context.error("Not default C++ library defined globary or locally", | ||
field.pos); | ||
} | ||
|
||
var expr = entry.params.length > 0 ? entry.params[0] | ||
: meta.get(TagDefaultLibrary).params[0]; | ||
var result:String = expr.getString(); | ||
|
||
return result; | ||
} | ||
} |
Oops, something went wrong.