-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.0.2 : Added : - Abstract statics support - Date and Datetools defaults for RuleScriptInterp Fixed : - Fixed bug when code ignored properties
- Loading branch information
Showing
14 changed files
with
277 additions
and
29 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 |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.vscode | ||
/test/export | ||
hxformat.json | ||
/test/dump |
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,14 @@ | ||
# Changelog | ||
|
||
# 0.0.2 : | ||
|
||
### Added : | ||
- Abstract statics support | ||
- Date and Datetools defaults for RuleScriptInterp | ||
|
||
### Fixed : | ||
- Fixed bug when code ignored properties | ||
|
||
# 0.0.1 : | ||
|
||
### Initial Release |
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
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
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
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,13 @@ | ||
package rulescript; | ||
|
||
import rulescript.macro.AbstractMacro; | ||
|
||
using StringTools; | ||
|
||
class Abstracts | ||
{ | ||
public static dynamic function resolveAbstract(name:String):Class<Dynamic> | ||
{ | ||
return Type.resolveClass('rulescript.__abstracts.${name.substring(0, name.lastIndexOf('.') + 1) + '_' + name.substring(name.lastIndexOf('.') + 1)}'); | ||
} | ||
} |
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
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,76 @@ | ||
package rulescript.macro; | ||
|
||
import haxe.macro.Context; | ||
import haxe.macro.Expr; | ||
import sys.FileSystem; | ||
import sys.io.File; | ||
|
||
using StringTools; | ||
|
||
class AbstractMacro | ||
{ | ||
/** | ||
* Converts abstract to class | ||
*/ | ||
#if !macro macro #end public static function buildAbstract(name:String, pack:String):Array<Field> | ||
{ | ||
var fields = Context.getBuildFields(); | ||
var pos = Context.currentPos(); | ||
|
||
var type = Context.getLocalClass(); | ||
|
||
var isEnum:Bool = type.get().meta.has(':enum'); | ||
|
||
var cl = macro class {}; | ||
|
||
var imports = Context.getLocalImports(); | ||
|
||
imports.push({ | ||
path: name.split('.').map(s -> { | ||
name: s, | ||
pos: pos | ||
}), | ||
mode: INormal | ||
}); | ||
|
||
if (name.contains('.')) | ||
{ | ||
var list = name.split('.'); | ||
|
||
while (list.length > 1) | ||
pack += '.' + list.shift(); | ||
|
||
name = list[0]; | ||
} | ||
|
||
cl.name = '_' + name; | ||
cl.pack = pack.split('.'); | ||
|
||
for (f in fields) | ||
{ | ||
if (isEnum && (f.kind.match(FVar(_, _)))) | ||
{ | ||
cl.fields.push({ | ||
name: f.name, | ||
doc: f.doc, | ||
access: [APublic, AStatic], | ||
kind: switch (f.kind) | ||
{ | ||
case FVar(t, e) if (e != null): | ||
f.kind; | ||
default: | ||
FVar(macro :String, macro $v{f.name}); | ||
}, | ||
pos: f.pos, | ||
meta: f.meta | ||
}); | ||
} | ||
else if (f.access.contains(AStatic)) | ||
cl.fields.push(f); | ||
} | ||
|
||
Context.defineModule('$pack._$name', [cl], imports); | ||
|
||
return fields; | ||
} | ||
} |
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,37 @@ | ||
package rulescript.macro; | ||
|
||
import haxe.macro.Compiler; | ||
import haxe.macro.Context; | ||
import haxe.macro.Expr; | ||
import sys.FileSystem; | ||
import sys.io.File; | ||
|
||
using StringTools; | ||
|
||
class Converter | ||
{ | ||
// Language server shows errors... | ||
public static function init() | ||
{ | ||
var files:Array<String> = []; | ||
|
||
var filename:String = Context.definedValue('rulescript_abstracts_file_path') ?? 'RuleScriptAbstracts.txt'; | ||
|
||
var abstractsList:Array<String> = []; | ||
|
||
for (dir in Context.getClassPath()) | ||
if (FileSystem.exists(dir + filename)) | ||
for (abs in parseFile(File.getContent(dir + filename))) | ||
if (!abstractsList.contains(abs)) | ||
abstractsList.push(abs); | ||
|
||
for (name in abstractsList) | ||
Compiler.addMetadata('@:build(rulescript.macro.AbstractMacro.buildAbstract("$name","rulescript.__abstracts"))', name); | ||
} | ||
|
||
static function parseFile(content:String):Array<String> | ||
{ | ||
var text:String = content.replace('\r', '').replace(' ', ''); | ||
return text.split('\n'); | ||
} | ||
} |
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
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,2 @@ | ||
TestAbstract | ||
test.HelloWorldAbstract |
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,12 @@ | ||
package; | ||
|
||
class Test | ||
{ | ||
public var test:Int = 123456; | ||
|
||
public function new(?test:Int) | ||
{ | ||
if (test != null) | ||
this.test = test; | ||
} | ||
} |
Oops, something went wrong.