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
43 changes: 43 additions & 0 deletions hscript/TemplateClass.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package hscript;

import hscript.behaviours.IHScriptCustomAccessBehaviour;
import hscript.behaviours.IHScriptCustomBehaviour;
import hscript.Interp;

/**
* This is for backwards compatibility with old hscript-improved, since some scripts use it
**/
@:dox(hide)
@:keep
class TemplateClass implements IHScriptCustomBehaviour implements IHScriptCustomAccessBehaviour {
public var __interp:Interp;
public var __allowSetGet:Bool = true;

public function hset(name:String, val:Dynamic):Dynamic {
var variables = __interp.variables;
if(__allowSetGet && variables.exists("set_" + name))
return __callSetter(name, val);
variables.set(name, val);
return val;
}
public function hget(name:String):Dynamic {
var variables = __interp.variables;
if(__allowSetGet && variables.exists("get_" + name))
return __callGetter(name);
return variables.get(name);
}

public function __callGetter(name:String):Dynamic {
__allowSetGet = false;
var v = __interp.variables.get("get_" + name)();
__allowSetGet = true;
return v;
}

public function __callSetter(name:String, val:Dynamic):Dynamic {
__allowSetGet = false;
var v = __interp.variables.get("set_" + name)(val);
__allowSetGet = true;
return v;
}
}
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 Expand Up @@ -148,42 +154,3 @@ class CustomClassHandler implements IHScriptCustomConstructor implements IHScrip
return name;
}
}


/**
* This is for backwards compatibility with old hscript-improved, since some scripts use it
**/
@:dox(hide)
@:keep
class TemplateClass implements IHScriptCustomBehaviour implements IHScriptCustomAccessBehaviour {
public var __interp:Interp;
public var __allowSetGet:Bool = true;

public function hset(name:String, val:Dynamic):Dynamic {
var variables = __interp.variables;
if(__allowSetGet && variables.exists("set_" + name))
return __callSetter(name, val);
variables.set(name, val);
return val;
}
public function hget(name:String):Dynamic {
var variables = __interp.variables;
if(__allowSetGet && variables.exists("get_" + name))
return __callGetter(name);
return variables.get(name);
}

public function __callGetter(name:String):Dynamic {
__allowSetGet = false;
var v = __interp.variables.get("get_" + name)();
__allowSetGet = true;
return v;
}

public function __callSetter(name:String, val:Dynamic):Dynamic {
__allowSetGet = false;
var v = __interp.variables.get("set_" + name)(val);
__allowSetGet = true;
return v;
}
}
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
Loading