<commit_before>﻿package motion.actuators;


import motion.easing.IEasing;
import motion.Actuate;

@:keepSub


class GenericActuator<T> implements IGenericActuator {
	
	
	private var duration:Float;
	private var id:String;
	private var properties:Dynamic;
	private var target:T;
	private var _autoVisible:Bool;
	private var _delay:Float;
	private var _ease:IEasing;
	private var _onComplete:Dynamic;
	private var _onCompleteParams:Array <Dynamic>;
	private var _onRepeat:Dynamic;
	private var _onRepeatParams:Array <Dynamic>;
	private var _onUpdate:Dynamic;
	private var _onUpdateParams:Array <Dynamic>;
	private var _onResume:Dynamic;
	private var _onResumeParams:Array <Dynamic>;
	private var _onPause:Dynamic;
	private var _onPauseParams:Array <Dynamic>;
	private var _reflect:Bool;
	private var _repeat:Int;
	private var _reverse:Bool;
	private var _smartRotation:Bool;
	private var _snapping:Bool;
	private var special:Bool;
	
	
	public function new (target:T, duration:Float, properties:Dynamic) {
		
		_autoVisible = true;
		_delay = 0;
		_reflect = false;
		_repeat = 0;
		_reverse = false;
		_smartRotation = false;
		_snapping = false;
		special = false;
		
		this.target = target;
		this.properties = properties;
		this.duration = duration;
		
		_ease = Actuate.defaultEase;
		
	}
	
	
	private function apply ():Void {
		
		for (i in Reflect.fields (properties)) {
			
			#if (haxe_209 || haxe3)
			
			if (#if flash false && #end Reflect.hasField (target, i)) {
				
				Reflect.setField (target, i, Reflect.field (properties, i));
				
			} else {
				
				Reflect.setProperty (target, i, Reflect.field (properties, i));
				
			}
			
			#else
			
			Reflect.setField (target, i, Reflect.field (properties, i));
			
			#end
			
		}
		
	}
	
	
	/**
	 * Flash performs faster when objects are set to visible = false rather than only alpha = 0. autoVisible toggles automatically based on alpha values
	 * @param	value		Whether autoVisible should be enabled (Default is true)
	 * @return		The current actuator instance
	 */
	public function autoVisible (?value:Null<Bool>):GenericActuator<T> {
		
		if (value == null) {
			
			value = true;
			
		}
		
		_autoVisible = value;
		
		return this;
		
	}
	
	
	private inline function callMethod (method:Dynamic, params:Array<Dynamic> = null):Dynamic {
		
		if (params == null) {
			
			params = [];
			
		}
		
		#if neko
		
		var diff = untyped ($nargs)(method) - params.length;
		
		if (diff > 0) {
			
			params = params.copy ();
			
			for (i in 0...diff) {
				
				params.push (null);
				
			}
			
		}
		
		#end
		
		return method (params);
		
	}
	
	
	private function change ():Void {
		
		if (_onUpdate != null) {
			
			callMethod (_onUpdate, _onUpdateParams);
			
		}
		
	}
	
	
	private function complete (sendEvent:Bool = true):Void {
		<commit_msg>Revert "Remove Reflect.callMethod" (haha, crashes Neko, that's why)<commit_after>﻿package motion.actuators;


import motion.easing.IEasing;
import motion.Actuate;

@:keepSub


class GenericActuator<T> implements IGenericActuator {
	
	
	private var duration:Float;
	private var id:String;
	private var properties:Dynamic;
	private var target:T;
	private var _autoVisible:Bool;
	private var _delay:Float;
	private var _ease:IEasing;
	private var _onComplete:Dynamic;
	private var _onCompleteParams:Array <Dynamic>;
	private var _onRepeat:Dynamic;
	private var _onRepeatParams:Array <Dynamic>;
	private var _onUpdate:Dynamic;
	private var _onUpdateParams:Array <Dynamic>;
	private var _onResume:Dynamic;
	private var _onResumeParams:Array <Dynamic>;
	private var _onPause:Dynamic;
	private var _onPauseParams:Array <Dynamic>;
	private var _reflect:Bool;
	private var _repeat:Int;
	private var _reverse:Bool;
	private var _smartRotation:Bool;
	private var _snapping:Bool;
	private var special:Bool;
	
	
	public function new (target:T, duration:Float, properties:Dynamic) {
		
		_autoVisible = true;
		_delay = 0;
		_reflect = false;
		_repeat = 0;
		_reverse = false;
		_smartRotation = false;
		_snapping = false;
		special = false;
		
		this.target = target;
		this.properties = properties;
		this.duration = duration;
		
		_ease = Actuate.defaultEase;
		
	}
	
	
	private function apply ():Void {
		
		for (i in Reflect.fields (properties)) {
			
			#if (haxe_209 || haxe3)
			
			if (#if flash false && #end Reflect.hasField (target, i)) {
				
				Reflect.setField (target, i, Reflect.field (properties, i));
				
			} else {
				
				Reflect.setProperty (target, i, Reflect.field (properties, i));
				
			}
			
			#else
			
			Reflect.setField (target, i, Reflect.field (properties, i));
			
			#end
			
		}
		
	}
	
	
	/**
	 * Flash performs faster when objects are set to visible = false rather than only alpha = 0. autoVisible toggles automatically based on alpha values
	 * @param	value		Whether autoVisible should be enabled (Default is true)
	 * @return		The current actuator instance
	 */
	public function autoVisible (?value:Null<Bool>):GenericActuator<T> {
		
		if (value == null) {
			
			value = true;
			
		}
		
		_autoVisible = value;
		
		return this;
		
	}
	
	
	private inline function callMethod (method:Dynamic, params:Array<Dynamic> = null):Dynamic {
		
		if (params == null) {
			
			params = [];
			
		}
		
		#if neko
		
		var diff = untyped ($nargs)(method) - params.length;
		
		if (diff > 0) {
			
			params = params.copy ();
			
			for (i in 0...diff) {
				
				params.push (null);
				
			}
			
		}
		
		#end
		
		return Reflect.callMethod (#if hl null #else method #end, method, params);
		
	}
	
	
	private function change ():Void {
		
		if (_onUpdate != null) {
			
			callMethod (_onUpdate, _onUpdateParams);
			
		}
		
	}
	
	
	private function complete (sendEvent:Bool = true):Void {
		
{'fraction_non_alphanumeric': 0.10228661197416652, 'fraction_numerical': 0.0031419095828242277, 'mean_word_length': 3.1794310722100656, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2964727', 'n_tokens_mistral': 2261, 'n_tokens_neox': 1815, 'n_words': 522}