[fpc-pascal] Next language feature for pas2js...
Ryan Joseph
ryan at thealchemistguild.com
Tue May 1 09:20:12 CEST 2018
> On May 1, 2018, at 2:03 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>
> Of sorts.
> MyClass = Class external name 'my'
> const
> MyConst : integer
> end;
>
> Will emit MyClass.MyConst. The compiler needs to know the type.
I’m confused now. The class is named WebGLRenderingContext in JS (I think that’s what it’s called by JS doesn’t really have classes does it?) so how does it look?
// no external name because the names are the same
type
WebGLRenderingContext = class
procedure clearColor (red, green, blue, alpha: GLfloat);
end;
So constants must be part of the class? In the example below gl.COLOR_BUFFER_BIT is scoped to WebGLRenderingContext so I guess that’s the reason.
Also I mistyped, GLfloat is a type so how do this map to JS, or do I even need to since the names are the same?
How does this JS translate to Pascal then? drawingBufferWidth are read only properties but no type is specified so how does Pascal handle all the untyped variables we see in JS?
var canvas = document.createElement("canvas");
var gl = canvas.getContext("webgl")
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
gl.clearColor(0, 0, 0, 0);
gl.clear(gl.COLOR_BUFFER_BIT);
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list