Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph
> On May 2, 2018, at 1:24 PM, Michael Van Canneyt > wrote: > > It will only work with trunk. trunk of what? Do mean the entire fpc sources? cd /Users/ryanjoseph/Downloads/pas2js ls Makefilecompilerfpmake.pp utils Makefile.fpcdemopackages Regards,

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt
On Wed, 2 May 2018, Ryan Joseph wrote: On May 2, 2018, at 8:18 AM, Ryan Joseph wrote: On Mac cd’ing to the directory and using make gives this error: /usr/local/bin/ppc386 fpmake.pp -n Fatal: Can't find unit system used by fpmake Fatal: Compilation aborted make: *** [fpmake] Error 1

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph
> On May 2, 2018, at 8:18 AM, Ryan Joseph wrote: > > On Mac cd’ing to the directory and using make gives this error: > > /usr/local/bin/ppc386 fpmake.pp -n > Fatal: Can't find unit system used by fpmake > Fatal: Compilation aborted > make: *** [fpmake] Error 1 Sorry that was the wrong dire

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph
So how do you actually build the parser? I downloaded the source but I don’t see a binary. On Mac cd’ing to the directory and using make gives this error: /usr/local/bin/ppc386 fpmake.pp -n Fatal: Can't find unit system used by fpmake Fatal: Compilation aborted make: *** [fpmake] Error 1 Re

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread wkitty42
On 05/01/2018 07:09 AM, Ryan Joseph wrote: In PHP I always just load the file into string and loop over it line by line using regex to cut out the parts I need. I like it because it’s so easy to write and gets the job done. What ever I would make it Pascal would be 10x larger probably. FWIW: yo

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 9:56 PM, Michael Van Canneyt wrote: You must do gl := TJSWebGLRenderingContext(canvas.getContext('webgl')); because getContext can return various classes depending on the argument. Ok so getContext is method of TJSElement I gue

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michalis Kamburelis
Ryan Joseph wrote: > > > > On May 1, 2018, at 9:56 PM, Michael Van Canneyt > wrote: > > > > You must do > > gl := TJSWebGLRenderingContext(canvas.getContext('webgl')); > > > > because getContext can return various classes depending on the argument. > > Ok so getContext is method of TJSElement I

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 9:56 PM, Michael Van Canneyt > wrote: > > You must do > gl := TJSWebGLRenderingContext(canvas.getContext('webgl')); > > because getContext can return various classes depending on the argument. Ok so getContext is method of TJSElement I guess. Btw I’ve been reading and

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 8:28 PM, Michael Van Canneyt wrote: Check the canvas demo (demo/rtl/democanvas2d.pas) something like this? var canvas: TJSElement; // What type should this be? gl: TJSWebGLRenderingContext; begin canvas := document.createElem

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 8:28 PM, Michael Van Canneyt > wrote: > > Check the canvas demo (demo/rtl/democanvas2d.pas) something like this? var canvas: TJSElement; // What type should this be? gl: TJSWebGLRenderingContext; begin canvas := document.createElement('canvas'); document.body.app

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 15:28:45 +0200 (CEST) Michael Van Canneyt wrote: >[...] > The "new web project" wizard will make the HTML file for you, if you > installed the pas2js_dsgn.lpk package in Lazarus. I think it is available > with the distributed latest lazarus, No. It was added in 1.9. Mattias _

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 7:49 PM, Michael Van Canneyt wrote: I didn't. Some Regexps in an editor did the job handsomely... By hand. Hardcore. ;) Because I don’t see it on the wiki can post a minimal example/template of how to get a canvas started? Ch

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 7:49 PM, Michael Van Canneyt > wrote: > > I didn't. Some Regexps in an editor did the job handsomely... By hand. Hardcore. ;) Because I don’t see it on the wiki can post a minimal example/template of how to get a canvas started? Basically I want that but it references

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 7:40 PM, Michael Van Canneyt wrote: Hi, See subject. Rev 83 in pas2js subversion. I have no experience with webgl, so if someone could provide several examples which I can include in the demo folder of pas2js, please post on the

Re: [fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 7:40 PM, Michael Van Canneyt > wrote: > > > Hi, > > See subject. Rev 83 in pas2js subversion. > > I have no experience with webgl, so if someone could provide several > examples which I can include in the demo folder of pas2js, please post on > the pas2js mailing list o

[fpc-pascal] pas2js Webgl unit committed

2018-05-01 Thread Michael Van Canneyt
Hi, See subject. Rev 83 in pas2js subversion. I have no experience with webgl, so if someone could provide several examples which I can include in the demo folder of pas2js, please post on the pas2js mailing list or send them to me in private. They would be highly appreciated. Obviously, if y

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 5:55 PM, Marco van de Voort wrote: > > I already stumbled on regex :_) Anyone feel free to make a good example of a token parser in Pascal so I can see how it looks. I never an actual good parser that understands syntax so I don’t have any good examples to go by. In PHP

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Marco van de Voort
In our previous episode, Michael Van Canneyt said: > >> If you have access to the underlying API spec in the form of an IDL, then > >> we > >> could make a tool that parses the IDL and dumps the API in the form of > >> "external" declarations. > > > > There it is. A parser needs to be made I guess

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 4:37 PM, Michael Van Canneyt wrote: What's wrong with the above code ? It obviously works well enough, otherwise they wouldn't have made the API so. The float32 array is a Javascript type that encapsulates a memory buffer. I assu

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 10:52:32 +0200 (CEST) Michael Van Canneyt wrote: >[...] > > Note that the 'var' is a workaround till eventually pas2js supports > > external 'const' without expression. > > Well, I specially did not mention this, because I consider it a dirty hack. > a var doesn't protect yo

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 4:37 PM, Michael Van Canneyt > wrote: > > What's wrong with the above code ? > > It obviously works well enough, otherwise they wouldn't have made the API so. > > The float32 array is a Javascript type that encapsulates a memory buffer. > I assu It’s difficult to work w

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ingemar Ragnemalm wrote: Den 2018-05-01 kl. 09:50, Ryan Joseph wrote: On Apr 25, 2018, at 9:43 PM, Michael Van Canneyt wrote: Ah, webgl... I had a look at this some time ago, and got depressed. Quickly closed the browser and didn't look back. Same for webaudio:( I’m

[fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ingemar Ragnemalm
Den 2018-05-01 kl. 09:50, Ryan Joseph wrote: On Apr 25, 2018, at 9:43 PM, Michael Van Canneyt wrote: Ah, webgl... I had a look at this some time ago, and got depressed. Quickly closed the browser and didn't look back. Same for webaudio:( I’m actually a little curious about this myself beca

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 4:10 PM, Mattias Gaertner wrote: In pas2js it will probably look similar to this: var vertices: array of glfloat = (-0.5, 0.5, -0.5, -0.5, 0.0, -0.5); var vertex_buffer: TInsertNameHere; begin // Create a new buffer object verte

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 4:10 PM, Mattias Gaertner > wrote: > > In pas2js it will probably look similar to this: > > var vertices: array of glfloat = (-0.5, 0.5, -0.5, -0.5, 0.0, -0.5); > var vertex_buffer: TInsertNameHere; > begin > // Create a new buffer object > vertex_buffer = gl.createBuff

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 4:12 PM, Michael Van Canneyt wrote: If you have access to the underlying API spec in the form of an IDL, then we could make a tool that parses the IDL and dumps the API in the form of "external" declarations. There it is. A parse

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 4:12 PM, Michael Van Canneyt > wrote: > > If you have access to the underlying API spec in the form of an IDL, then we > could make a tool that parses the IDL and dumps the API in the form of > "external" declarations. There it is. A parser needs to be made I guess. You c

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Mattias Gaertner wrote: On Tue, 1 May 2018 15:23:25 +0700 Ryan Joseph wrote: [...] what do we do for records then? We often need to pass arrays of specific types for functions such as glBufferData. type TVec2f = record x, y: GLfloat; end; type TVec2b = recor

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: The above would be Type WebGLActiveInfo = class external name 'WebGLActiveInfo' Private fSize : GLint; external name 'size'; ftype: GLEnum; external name 'type'; fName : DOMString ; external name 'name'; Public Property size : GLInt Read

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 15:23:25 +0700 Ryan Joseph wrote: >[...] > what do we do for records then? We often need to pass arrays of specific > types for functions such as glBufferData. > > type > TVec2f = record > x, y: GLfloat; > end; > > type > TVec2b = record > x, y: GLubyte; > en

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 3:17 PM, Mattias Gaertner wrote: JS only knows double for numbers. At compile time you can use almost all the normal types: byte, word, longint, etc. pas2js has an alias single, but because internally it is a double this gives war

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 3:50 PM, Michael Van Canneyt > wrote: > > > As far as I know, all consts in Javascript are scoped ? > > If this is not the case, then of course we should allow it. I think they added const. In the past I’ve seen using “let” but I don’t think that’s a real const if that

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 15:36:59 +0700 Ryan Joseph wrote: >[...] > > Constants without expression can only exist in an external class. > > Just curious but why can’t you declare a const anywhere for any reasons? You can. > >> Also I mistyped, GLfloat is a type so how do this map to JS, or do I e

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 3:17 PM, Mattias Gaertner > wrote: > > JS only knows double for numbers. > > At compile time you can use almost all the normal types: byte, > word, longint, etc. > pas2js has an alias single, but because internally it is a double this > gives warnings. what do we do for

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Mattias Gaertner wrote: On Tue, 1 May 2018 14:20:12 +0700 Ryan Joseph wrote: > On May 1, 2018, at 2:03 PM, Michael Van Canneyt wrote: > > Of sorts. > MyClass = Class external name 'my' > const >MyConst : integer > end; > > Will emit MyClass.MyConst. The compi

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 3:17 PM, Michael Van Canneyt wrote: 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. Yes. Constants without expression can only

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 3:17 PM, Michael Van Canneyt > wrote: > >> 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. > > Yes. > > Constants without expression can only exist in an external cl

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 14:20:12 +0700 Ryan Joseph wrote: > > On May 1, 2018, at 2:03 PM, Michael Van Canneyt > > wrote: > > > > Of sorts. > > MyClass = Class external name 'my' > > const > >MyConst : integer > > end; > > > > Will emit MyClass.MyConst. The compiler needs to know the type.

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 2:03 PM, Michael Van Canneyt 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 WebGLRende

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 15:03:30 +0700 Ryan Joseph wrote: > > On May 1, 2018, at 2:55 PM, Mattias Gaertner > > wrote: > > > > GLFloat is a type, not a const. > > > > type GLFloat = double; > > Yeah I mistyped. We shouldn’t be redefining GLfloat though (I doubt it’s a > double in OpenGLES/WebGL

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 2:55 PM, Mattias Gaertner > wrote: > > GLFloat is a type, not a const. > > type GLFloat = double; Yeah I mistyped. We shouldn’t be redefining GLfloat though (I doubt it’s a double in OpenGLES/WebGL either) so how does this (or other types) translate for the parser? Re

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Mattias Gaertner
On Tue, 1 May 2018 12:11:37 +0700 Ryan Joseph wrote: >[...] > const > GLfloat = MAP_TO_SOMETHING; // do we have external consts? GLFloat is a type, not a const. type GLFloat = double; Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Ryan Joseph
> On May 1, 2018, at 2:03 PM, Michael Van Canneyt > 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

Re: [fpc-pascal] Next language feature for pas2js...

2018-05-01 Thread Michael Van Canneyt
On Tue, 1 May 2018, Ryan Joseph wrote: On May 1, 2018, at 11:27 AM, Michalis Kamburelis wrote: I suspect that we will have a unit like WebGL in pas2js that exposes the necessary JS functions for Pascal applications. Sure but how does the porting process look? I’m reading the wiki and i