Skip to content
Open
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
2 changes: 1 addition & 1 deletion hscript/Async.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
package hscript;
import hscript.Expr;

import hscript.expr.Expr;

enum VarMode {
Defined;
Expand Down
3 changes: 2 additions & 1 deletion hscript/Bytes.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
package hscript;
import hscript.Expr;

import hscript.expr.Expr;

class Bytes {

Expand Down
3 changes: 2 additions & 1 deletion hscript/Checker.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package hscript;
import hscript.Expr;

import hscript.expr.Expr;

/**
This is a special type that can be used in API.
Expand Down
18 changes: 12 additions & 6 deletions hscript/Interp.hx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@
*/
package hscript;

import hscript.behaviours.*;
import hscript.expr.*;

import hscript.utils.Tools;
import hscript.utils.UsingHandler;
import hscript.utils.UnsafeReflect;
import hscript.expr.HEnum.HEnumValue;
import hscript.expr.HEnum;
import hscript.expr.Expr;

import haxe.Exception;
import haxe.ds.StringMap;
import hscript.HEnum.HEnumValue;
import haxe.CallStack;
import hscript.utils.UsingHandler;
import hscript.utils.UnsafeReflect;
import haxe.PosInfos;
import hscript.Expr;
import haxe.Constraints.IMap;

using StringTools;
Expand Down Expand Up @@ -83,7 +89,7 @@ class RedeclaredVar {
public var depth:Int;
}

@:access(hscript.CustomClass)
@:access(hscript.expr.CustomClass)
@:analyzer(optimize, local_dce, fusion, user_var_fusion)
class Interp {
private var hasScriptObject(default, null):Bool = false;
Expand Down Expand Up @@ -1751,7 +1757,7 @@ class Interp {
}

// Custom Class Static Extension
@:access(hscript.CustomClassHandler)
@:access(hscript.expr.CustomClassHandler)
function setCustomClassUsing(name:String, cls:CustomClassHandler) {
if (usingHandler.entryExists(name)) return;

Expand Down
3 changes: 2 additions & 1 deletion hscript/Parser.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* DEALINGS IN THE SOFTWARE.
*/
package hscript;
import hscript.Expr;

import hscript.expr.Expr;

using StringTools;

Expand Down
7 changes: 5 additions & 2 deletions hscript/Printer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
* DEALINGS IN THE SOFTWARE.
*/
package hscript;
import hscript.Expr;

import hscript.expr.Expr;
import hscript.expr.Expr.Error;
import hscript.utils.Tools;

class Printer {

Expand Down Expand Up @@ -468,7 +471,7 @@ class Printer {
return new Printer().exprToString(e);
}

public static function errorToString( e : Expr.Error ):String {
public static function errorToString( e : Error ):String {
var message = switch( #if hscriptPos e.e #else e #end ) {
case EInvalidChar(c): "Invalid character: '"+(StringTools.isEof(c) ? "EOF (End Of File)" : String.fromCharCode(c))+"' ("+c+")";
case EUnexpected(s): "Unexpected token: \""+s+"\"";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hscript;
package hscript.behaviours;

// Soon...
interface IHScriptAbstractBehaviour extends IHScriptCustomBehaviour {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hscript;
package hscript.behaviours;

/**
* Same Interface as IHScriptCustomBehaviour but for Property.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hscript;
package hscript.behaviours;

/**
* Special Interface for handling field access behaviour.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hscript;
package hscript.behaviours;

/**
* Special Interface to make a class usable for Custom Classes.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package hscript;
package hscript.behaviours;

/**
* Special Interface for handling new instances of an object.
Expand Down
8 changes: 6 additions & 2 deletions hscript/CustomClass.hx → hscript/expr/CustomClass.hx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package hscript;
package hscript.expr;

import hscript.behaviours.IHScriptCustomClassBehaviour;
import hscript.utils.UnsafeReflect;
import hscript.utils.Tools;
import hscript.Interp;

import haxe.Constraints.Function;

using Lambda;
Expand All @@ -12,7 +16,7 @@ using Lambda;
*
* @author Jamextreme140
*/
@:access(hscript.CustomClassHandler)
@:access(hscript.expr.CustomClassHandler)
class CustomClass implements IHScriptCustomClassBehaviour {
public var className(get, never):String;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package hscript;
package hscript.expr;

import hscript.behaviours.IHScriptCustomAccessBehaviour;
import hscript.behaviours.IHScriptCustomConstructor;
import hscript.behaviours.IHScriptCustomBehaviour;
import hscript.utils.Tools;
import hscript.Interp;

/**
* Provides handlers for static custom class fields and instantiation.
*/
@:access(hscript.Property)
class CustomClassHandler implements IHScriptCustomConstructor implements IHScriptCustomAccessBehaviour{
@:access(hscript.expr.Property)
class CustomClassHandler implements IHScriptCustomConstructor implements IHScriptCustomAccessBehaviour {
public var ogInterp:Interp;
public var name:String;
public var fields:Array<Expr>;
Expand Down
2 changes: 1 addition & 1 deletion hscript/Expr.hx → hscript/expr/Expr.hx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package hscript;
package hscript.expr;

typedef Int8 = #if cpp cpp.Int8 #elseif java java.Int8 #elseif cs cs.Int8 #else Int #end;
typedef Int16 = #if cpp cpp.Int16 #elseif java java.Int16 #elseif cs cs.Int16 #else Int #end;
Expand Down
3 changes: 2 additions & 1 deletion hscript/HEnum.hx → hscript/expr/HEnum.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package hscript;
package hscript.expr;

import hscript.behaviours.IHScriptCustomBehaviour;
import hscript.utils.UnsafeReflect;

/**
Expand Down
4 changes: 2 additions & 2 deletions hscript/Property.hx → hscript/expr/Property.hx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package hscript;
package hscript.expr;

import hscript.utils.UnsafeReflect;
import hscript.Interp;
import hscript.Expr.FieldPropertyAccess;
import hscript.expr.Expr.FieldPropertyAccess;

/**
* Special variable that handles 'getter/setter' function calls
Expand Down
2 changes: 2 additions & 0 deletions hscript/macros/AbstractHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import haxe.macro.Context;
import haxe.macro.Printer;
import haxe.macro.Compiler;

import hscript.Config;

using StringTools;

class AbstractHandler {
Expand Down
36 changes: 19 additions & 17 deletions hscript/macros/ClassExtendMacro.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import haxe.macro.Type.ClassField;
import haxe.macro.Type.VarAccess;
import haxe.macro.*;

import hscript.Config;

using StringTools;

// BIG TODO: make typed classes scriptable
Expand Down Expand Up @@ -339,7 +341,7 @@ class ClassExtendMacro {
pack: cl.pack.copy(),
name: cl.name
}, [
{name: "IHScriptCustomClassBehaviour", pack: ["hscript"]}
{name: "IHScriptCustomClassBehaviour", pack: ["hscript.behaviours"]}
], false, true, false);
shadowClass.name = '${cl.name}$CLASS_SUFFIX';
var imports = Context.getLocalImports().copy();
Expand Down Expand Up @@ -484,17 +486,17 @@ class ClassExtendMacro {
if(__class__fields.contains(name)) {
var v:Dynamic = __interp.variables.get(name);
var ba:Bool = @:privateAccess __interp.isBypassAccessor;
if(v != null && v is hscript.Property)
return cast(v, hscript.Property).get(ba);
if(v != null && v is hscript.expr.Property)
return cast(v, hscript.expr.Property).get(ba);
return v;
}
else @:privateAccess {
var cls:hscript.CustomClass = cast __interp.__customClass.__upperClass;
var cls:hscript.expr.CustomClass = cast __interp.__customClass.__upperClass;
while(cls != null) {
if(cls.hasField(name))
return cls.getField(name);

var prev:hscript.CustomClass = cast cls.__upperClass;
var prev:hscript.expr.CustomClass = cast cls.__upperClass;
if(prev == null)
break;
cls = prev;
Expand All @@ -510,17 +512,17 @@ class ClassExtendMacro {
if(__class__fields.contains(name)) {
var v:Dynamic = __interp.variables.get(name);
var ba:Bool = @:privateAccess __interp.isBypassAccessor;
if(v != null && v is hscript.Property)
return cast(v, hscript.Property).get(ba);
if(v != null && v is hscript.expr.Property)
return cast(v, hscript.expr.Property).get(ba);
return v;
}
else @:privateAccess {
var cls:hscript.CustomClass = cast __interp.__customClass.__upperClass;
var cls:hscript.expr.CustomClass = cast __interp.__customClass.__upperClass;
while(cls != null) {
if(cls.hasField(name))
return cls.getField(name);

var prev:hscript.CustomClass = cast cls.__upperClass;
var prev:hscript.expr.CustomClass = cast cls.__upperClass;
if(prev == null)
break;
cls = prev;
Expand All @@ -538,18 +540,18 @@ class ClassExtendMacro {
if(__class__fields.contains(name)) {
var v:Dynamic = __interp.variables.get(name);
var ba:Bool = @:privateAccess __interp.isBypassAccessor;
if(v != null && v is hscript.Property)
return cast(v, hscript.Property).set(val, ba);
if(v != null && v is hscript.expr.Property)
return cast(v, hscript.expr.Property).set(val, ba);
__interp.variables.set(name, val);
return val;
}
else @:privateAccess {
var cls:hscript.CustomClass = cast __interp.__customClass.__upperClass;
var cls:hscript.expr.CustomClass = cast __interp.__customClass.__upperClass;
while(cls != null) {
if(cls.hasField(name))
return cls.setField(name, val);

var prev:hscript.CustomClass = cast cls.__upperClass;
var prev:hscript.expr.CustomClass = cast cls.__upperClass;
if(prev == null)
break;
cls = prev;
Expand All @@ -569,18 +571,18 @@ class ClassExtendMacro {
if(__class__fields.contains(name)) {
var v:Dynamic = __interp.variables.get(name);
var ba:Bool = @:privateAccess __interp.isBypassAccessor;
if(v != null && v is hscript.Property)
return cast(v, hscript.Property).set(val, ba);
if(v != null && v is hscript.expr.Property)
return cast(v, hscript.expr.Property).set(val, ba);
__interp.variables.set(name, val);
return val;
}
else @:privateAccess {
var cls:hscript.CustomClass = cast __interp.__customClass.__upperClass;
var cls:hscript.expr.CustomClass = cast __interp.__customClass.__upperClass;
while(cls != null) {
if(cls.hasField(name))
return cls.setField(name, val);

var prev:hscript.CustomClass = cast cls.__upperClass;
var prev:hscript.expr.CustomClass = cast cls.__upperClass;
if(prev == null)
break;
cls = prev;
Expand Down
Loading