fsw wrote:The longer I think about this my conclusion is: Not needed...
This is because the parser looks at every beginning of a line anyhow if he finds something to work with, like Class or EnableOOP.
So every line is parsed, you can't skip a single one.
Or am I missing something?
Nope, afterwards makes absolutely sense to me.
Ok, Datasections do make it easier, but why that NewArray Way?
Can be changed back to DIM.
Thought that for PB users it would make sense because there is already NewList for Linked Lists and with NewObject beeing used for Class Objects
No, you didn't understand me, I meant why do u use for defining the object ..
Code: Select all
...
EndDataSection : Global NewArray MYOBJECT_Self.MYOBJECT(0)
; End of class
; Define Object
ReDim MYOBJECT_Self.MYOBJECT(0) : MYOBJECT_Self(0)\VTable = ?MYOBJECT_VTable : Global MYTHING.MYOBJECT_Methods = MYOBJECT_Self(0) ;THIS IS A COMMENT
instead of a Constructor like in the code I did post above:
Code: Select all
Procedure.l New_MYOBJECT()
Protected *obj.cMYOBJECT
*obj = AllocateMemory(SizeOf(cMYOBJECT))
*obj\VTable = ?MYOBJECT_VTable
ProcedureReturn *obj
EndProcedure
So ... you dont need the new object to be in a global state at all.
So its up to the user if he writes
NewObject MYTHING.iMYOBJECT or
NewObject *MYTHING.iMYOBJECT or
Global NewObject MYTHING.iMYOBJECT
inc. wrote:
What about this?
; Example 1: A single obj
Code: Select all
MYTHING.iMYOBJECT = New_MYOBJECT()
Don't see a benefit over this:
Wanted to keep the code as close to PB as possible.
...
Excuse my ignorace, but why would somebody need that?
Explain please.
Again a misunderstanding

These examples above where used in the native PB syntax approach.
For shure in your Parser the syntax should be kept as it is:
NewObject MYTHING.iMYOBJECT
And for an Array of objects you could ad an option for supporting this:
NewObject MYTHING.iMYOBJECT(5)
The idea is .... if your parser founds an "NewObject Mything.iMYOBJECT" he automatically ads to the "resulted PB-native output-code" the call of the constructor when defining the object like I posted some lines further above

like ... NewObject MYTHING.iMYOBJECT will be interpreted by the parser as MYTHING.iMYOBJECT = New_MYOBJECT() ; calling the constructor
and NewObject MYTHING.iMYOBJECT(5) will become in the resulted PB-native code ...
Code: Select all
Dim MYTHING.iMYOBJECT(5)
For i = 0 To 5
MYTHING(i) = New_MYOBJECT()
Next i
Im talking about this option as beside other things I sometimes do convert small C++ Source-Parts to PB and the last one was a WaveFilePlayer where in the C++ Sources a WaveBuffer object was defined as
cWaveBuffer * myWaveBuffer = new cWaveBuffer[5]
PS: Also it would be a personal little "gusto" id such a parser could support a simple stringreplacement from "->" to "" (in non quoted parts

) so the user could decide if he uses
Procedure Classname:MethodName(a.l)
*this\res = *this\b + a
Endprocedure
or
Procedure Classname:MethodName(a.l)
*this->res = *this->b + a
Endprocedure
I dont want to change PB to a C++ like syntax noooo, but in this case of OOP support its just a little addon.