AS3's arguments.callee equivalent for Haxe

Hello,

I am trying to convert an AS3 code base to haxe. I would like to know how to convert AS3ā€™s arguments.callee into haxe ?

public function set focusPaddingTop(value:Number):void {
            if (this.processStyleRestriction(arguments.callee)) {
                return;
            }
            if (this._focusPaddingTop == value) {
                return;
            }
            this._focusPaddingTop = value;
            this.invalidate(INVALIDATION_FLAG_FOCUS);
        }

protected function processStyleRestriction(key:Object):Boolean {
            var ignore:Boolean = this._ignoreNextStyleRestriction;
            this._ignoreNextStyleRestriction = false;
            //in most cases, the style is not restricted, and we can set it
            if (this._applyingStyles) {
                return this._restrictedStyles !== null &&
                        key in this._restrictedStyles;
            }
            if (ignore) {
                return false;
            }
            if (this._restrictedStyles === null) {
                //only create the object if it is needed
                this._restrictedStyles = new Dictionary();
            }
            this._restrictedStyles[key] = true;
            return false;
        }

Well, arguments.callee is just reference to the current function. You can replace it with reference to that function. Here is example for that: Try Haxe !
There the function myfuncOne(param:String=null,stopCall = false):Void is replaced with (String,Bool)->Void in the function myfuncTwo .

1 Like

I have updated the code for more clarity!

If I understood your example correctly this is how I should be converting MyExample

Also its a setter, will that make any difference ?

Appreciate your support!

For _restrictedStyles you can try to create Map for Functions simuliar to this one : Using functions as map keys in Haxe - Stack Overflow
As key you can set Dynamic->Void .
You should try to use it as
var myvar: FunctionMap<Dynamic -> Void, Bool> = new FunctionMap<Dynamic -> Void, Bool>();
Hope that helps.

1 Like
public function set_focusPaddingTop(value:Float):Float {
		if(this.processStyleRestriction(this.set_focusPaddingTop))
			{
				return get_focusPaddingTop();
		}
		if (this._focusPaddingTop == value) {
			return get_focusPaddingTop();
		}
		this._focusPaddingTop = value;
		this.invalidate(INVALIDATION_FLAG_FOCUS);
		return get_focusPaddingTop();
	}

private function processStyleRestriction(key:Dynamic-> Void):Bool {
		var ignore:Bool = this._ignoreNextStyleRestriction;
		this._ignoreNextStyleRestriction = false;
		// in most cases, the style is not restricted, and we can set it
		if (this._applyingStyles) {
			return this._restrictedStyles != null && this._restrictedStyles.exists(key);
		}
		if (ignore) {
			return false;
		}
		if (this._restrictedStyles == null) {
			// only create the object if it is needed
			this._restrictedStyles = new Map<Dynamic-> Void, Bool>();
		}
		this._restrictedStyles.set(key, true);
		return false;
	}

If I understood you correctly , then this is how it should be right ?

You can check this : Try Haxe !
I did some test , but it failed when choose Hashlink as tartget ( from Options tab on try.haxe.org ) .
Iā€™m not sure is this a bug or not.
You can try to compile to hxcpp target to see the result.

1 Like