<commit_before>package hxd;

class Stage {
	
	#if (flash || openfl)
	var stage : flash.display.Stage;
	var fsDelayed : Bool;
	#end
	var resizeEvents : List < Void -> Void > ;
	var eventTargets : List<Event -> Void>;
	
	public var width(get, null) : Float;
	public var height(get, null) : Float;
	public var mouseX(get, null) : Float;
	public var mouseY(get, null) : Float;
	public var mouseLock(get, set) : Bool;
	
	function new() {
		eventTargets = new List();
		resizeEvents = new List();
		#if (flash || openfl)
		stage = flash.Lib.current.stage;
		stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
		stage.addEventListener(flash.events.Event.RESIZE, onResize);
		if( hxd.System.isTouch ) {
			flash.ui.Multitouch.inputMode = flash.ui.MultitouchInputMode.TOUCH_POINT;
			stage.addEventListener(flash.events.TouchEvent.TOUCH_BEGIN, onTouchDown);
			stage.addEventListener(flash.events.TouchEvent.TOUCH_MOVE, onTouchMove);
			stage.addEventListener(flash.events.TouchEvent.TOUCH_END, onTouchUp);
		} else {
			stage.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, onMouseDown);
			stage.addEventListener(flash.events.MouseEvent.MOUSE_MOVE, onMouseMove);
			stage.addEventListener(flash.events.MouseEvent.MOUSE_UP, onMouseUp);
			stage.addEventListener(flash.events.MouseEvent.MOUSE_WHEEL, onMouseWheel);
			stage.addEventListener(flash.events.KeyboardEvent.KEY_DOWN, onKeyDown);
			stage.addEventListener(flash.events.KeyboardEvent.KEY_UP, onKeyUp);
			stage.addEventListener(flash.events.MouseEvent.RIGHT_MOUSE_DOWN, onRMouseDown);
			stage.addEventListener(flash.events.MouseEvent.RIGHT_MOUSE_UP, onRMouseUp);
		}
		#elseif js
		js.Browser.window.addEventListener("mousedown", onMouseDown);
		js.Browser.window.addEventListener("mousemove", onMouseMove);
		js.Browser.window.addEventListener("mouseup", onMouseUp);
		js.Browser.window.addEventListener("mousewheel", onMouseWheel);
		js.Browser.window.addEventListener("keydown", onKeyDown);
		js.Browser.window.addEventListener("keyup", onKeyUp);
		js.Browser.window.addEventListener("resize", onResize);
		#end
		#if flash
		if( untyped hxd.System.isAir() )
			setupOnCloseEvent();
		#end
	}
	
	#if flash
	function setupOnCloseEvent() {
		var nw : flash.events.EventDispatcher = Reflect.field(stage, "nativeWindow");
		nw.addEventListener("closing", function(e:flash.events.Event) {
			if( !onClose() )
				e.preventDefault();
		});
	}<commit_msg>fix null ptr error when compiling on mobile<commit_after>package hxd;

class Stage {
	
	#if (flash || openfl)
	var stage : flash.display.Stage;
	var fsDelayed : Bool;
	#end
	var resizeEvents : List < Void -> Void > ;
	var eventTargets : List<Event -> Void>;
	
	public var width(get, null) : Float;
	public var height(get, null) : Float;
	public var mouseX(get, null) : Float;
	public var mouseY(get, null) : Float;
	public var mouseLock(get, set) : Bool;
	
	function new() {
		eventTargets = new List();
		resizeEvents = new List();
		#if (flash || openfl)
		stage = flash.Lib.current.stage;
		stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
		stage.addEventListener(flash.events.Event.RESIZE, onResize);
		if( hxd.System.isTouch ) {
			flash.ui.Multitouch.inputMode = flash.ui.MultitouchInputMode.TOUCH_POINT;
			stage.addEventListener(flash.events.TouchEvent.TOUCH_BEGIN, onTouchDown);
			stage.addEventListener(flash.events.TouchEvent.TOUCH_MOVE, onTouchMove);
			stage.addEventListener(flash.events.TouchEvent.TOUCH_END, onTouchUp);
		} else {
			stage.addEventListener(flash.events.MouseEvent.MOUSE_DOWN, onMouseDown);
			stage.addEventListener(flash.events.MouseEvent.MOUSE_MOVE, onMouseMove);
			stage.addEventListener(flash.events.MouseEvent.MOUSE_UP, onMouseUp);
			stage.addEventListener(flash.events.MouseEvent.MOUSE_WHEEL, onMouseWheel);
			stage.addEventListener(flash.events.KeyboardEvent.KEY_DOWN, onKeyDown);
			stage.addEventListener(flash.events.KeyboardEvent.KEY_UP, onKeyUp);
			stage.addEventListener(flash.events.MouseEvent.RIGHT_MOUSE_DOWN, onRMouseDown);
			stage.addEventListener(flash.events.MouseEvent.RIGHT_MOUSE_UP, onRMouseUp);
		}
		#elseif js
		js.Browser.window.addEventListener("mousedown", onMouseDown);
		js.Browser.window.addEventListener("mousemove", onMouseMove);
		js.Browser.window.addEventListener("mouseup", onMouseUp);
		js.Browser.window.addEventListener("mousewheel", onMouseWheel);
		js.Browser.window.addEventListener("keydown", onKeyDown);
		js.Browser.window.addEventListener("keyup", onKeyUp);
		js.Browser.window.addEventListener("resize", onResize);
		#end
		#if flash
		if( untyped hxd.System.isAir() )
			setupOnCloseEvent();
		#end
	}
	
	#if flash
	function setupOnCloseEvent() {
		var nw : flash.events.EventDispatcher = Reflect.field(stage, "nativeWindow");
		if( nw == null ) return;
		nw.addEventListener("closing", function(e:flash.events.Event) {
			if( !onClose() )
				e.preventDefault();
		});
	}
{'fraction_non_alphanumeric': 0.12758550071677247, 'fraction_numerical': 0.0, 'mean_word_length': 5.2615384615384615, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '2583232', 'n_tokens_mistral': 1711, 'n_tokens_neox': 1587, 'n_words': 271}