Add some ES5 getter/setters

This commit is contained in:
Joshua Granick
2017-12-06 14:56:15 -08:00
parent 54eb5c195e
commit de98a6a39b
7 changed files with 102 additions and 2 deletions

View File

@@ -83,8 +83,16 @@ class Application extends Module {
private static function __init__ () {
var init = ApplicationBackend;
#if (js && html5)
untyped Object.defineProperty (Application.prototype, "window", { get: Application.prototype.get_window });
#if (js && html5 && es5get)
var p = untyped Application.prototype;
untyped Object.defineProperties (p, {
"frameRate": { get: p.get_frameRate, set: p.set_frameRate },
"preloader": { get: p.get_preloader },
"renderer": { get: p.get_renderer },
"renderers": { get: p.get_renderers },
"window": { get: p.get_window },
"windows": { get: p.get_windows }
});
#end
}

View File

@@ -18,6 +18,19 @@ class Promise<T> {
public var isError (get, null):Bool;
#if (js && html5 && es5get)
private static function __init__ () {
var p = untyped Promise.prototype;
untyped Object.defineProperties (p, {
"isComplete": { get: p.get_isComplete },
"isError": { get: p.get_isError }
});
}
#end
public function new () {
future = new Future<T> ();

View File

@@ -110,6 +110,24 @@ class Image {
public var y:Float;
#if (js && html5 && es5get)
private static function __init__ () {
var p = untyped Image.prototype;
untyped Object.defineProperties (p, {
"data": { get: p.get_data, set: p.set_data },
"format": { get: p.get_format, set: p.set_format },
"powerOfTwo": { get: p.get_powerOfTwo, set: p.set_powerOfTwo },
"premultiplied": { get: p.get_premultiplied, set: p.set_premultiplied },
"rect": { get: p.get_rect },
"src": { get: p.get_src, set: p.set_src },
"transparent": { get: p.get_transparent, set: p.set_transparent }
});
}
#end
public function new (buffer:ImageBuffer = null, offsetX:Int = 0, offsetY:Int = 0, width:Int = -1, height:Int = -1, color:Null<Int> = null, type:ImageType = null) {
this.offsetX = offsetX;

View File

@@ -46,6 +46,19 @@ class ImageBuffer {
@:noCompletion private var __srcImageData:#if (js && html5) ImageData #else Dynamic #end;
#if (js && html5 && es5get)
private static function __init__ () {
var p = untyped ImageBuffer.prototype;
untyped Object.defineProperties (p, {
"src": { get: p.get_src, set: p.set_src },
"stride": { get: p.get_stride }
});
}
#end
public function new (data:UInt8Array = null, width:Int = 0, height:Int = 0, bitsPerPixel:Int = 32, format:PixelFormat = null) {
this.data = data;

View File

@@ -661,6 +661,18 @@ class GL {
private static var __currentProgram:GLProgram;
#if (js && html5 && es5get)
private static function __init__ () {
untyped Object.defineProperties (GL, {
"type": { get: GL.get_type },
"version": { get: GL.get_version }
});
}
#end
public static inline function activeTexture (texture:Int):Void {
context.activeTexture (texture);

View File

@@ -54,6 +54,18 @@ class AudioBuffer {
@:noCompletion private var __srcVorbisFile:#if lime_vorbis VorbisFile #else Dynamic #end;
#if (js && html5 && es5get)
private static function __init__ () {
var p = untyped AudioBuffer.prototype;
untyped Object.defineProperties (p, {
"src": { get: p.get_src, set: p.set_src }
});
}
#end
public function new () {

View File

@@ -83,6 +83,30 @@ class Window {
@:noCompletion private var __y:Int;
#if (js && html5 && es5get)
private static function __init__ () {
var p = untyped Window.prototype;
untyped Object.defineProperties (p, {
"borderless": { get: p.get_borderless, set: p.set_borderless },
"display": { get: p.get_display },
"displayMode": { get: p.get_displayMode, set: p.set_displayMode },
"enableTextEvents": { get: p.get_enableTextEvents, set: p.set_enableTextEvents },
"fullscreen": { get: p.get_fullscreen, set: p.set_fullscreen },
"height": { get: p.get_height, set: p.set_height },
"maximized": { get: p.get_maximized, set: p.set_maximized },
"resizable": { get: p.get_resizable, set: p.set_resizable },
"scale": { get: p.get_scale },
"title": { get: p.get_title, set: p.set_title },
"width": { get: p.get_width, set: p.set_width },
"x": { get: p.get_x, set: p.set_y },
"y": { get: p.get_x, set: p.set_y }
});
}
#end
public function new (config:WindowConfig = null) {
this.config = config;