Dev-Object

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
HeX0R
Addict
Addict
Posts: 1204
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: Dev-Object

Post by HeX0R »

O.k., that was the explanation I was waiting for, many thanks, it's pretty clear now!
You probably should link to that explanation in the first post, otherwise it keeps hiding and things might not get any better.

Unfortunately that means that I am no possible user for your jewel here, because the thing I like most with Purebasic is the procedural paradigm.
If I would like to code OOP-style, I would simply select a different language.
But, that's only my opinion, go on with your Dev-Object, there were enough people crying for OOP implementation to PB since years.
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Denis wrote: Sat Nov 05, 2022 10:03 am My question is the following

Can we create several interfaces and define them as private/public?
If no, may it's a suggestion.

another suggestion:
For the Get/Set functions, it would be nice to define them individually for each member of the interface, which means that all the members could be either Get, or Set, or Get and Set or with no Get/Set, name only without prefix.

Another question
What is the difference between the Clear and Reset functions for you (it's not clear in my head)?
The way Dev-Object work there is only one Public Interface wrapped inside a module. I have not encountered a case where a private interface is needed. I will study the example you provide to see what I can do.

About the Get/Set Methods I understand the problematic and the way I personally deal with it I let the program generate all of them and remove the unwanted ones manually afterward. About the methods with the member name without the Get/Set prefix, same thing I modify them manually.

The difference between the Reset method and the Clear method it's the name, the internal code is the same. That being said I usually modify the Reset internal code with values that are different than zero/empty strings, etc.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Hello everyone,

There is no more a 1.x.x branch of Dev-Object, that particular branch has been replaced by Dev-Object-V2.x.x-All-OS branch. Also the branch 2.x.x available for Linux Only is now the Dev-Object-V2.x.x-Linux branch.

That out of the way, what new for Dev-Object 2.x.x-All OS branch :
  • JSON File support
  • Small correction inside the ReDim methods for Dynamic arrays
  • Corrections and additions to the help files.
  • The default font is now different according to the OS
  • The default rules for the code generator is Integer type
  • The default user informations has been translated (French)
See First post for download link.

What new for Dev-Object 2.x.x-Linux branch :
  • JSON File support
  • Small correction inside the ReDim methods for Dynamic arrays
  • Corrections and additions to the help files.
  • The default rules for the code generator is Integer type
  • The default user informations has been translated (French)
See second post for download link.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Hello everyone,

There is a small bug fixes for both branch of Dev-Object
  • Minor fix in the code generator about the Catch JSON instruction.
  • Minor fix in the case of a HashMap of objects in JSON files.
  • Minor fix in the case of a LinkedList of objects in JSON files.
As always see first or second post for download link. Sorry for the inconvenience. By the way, this will probably be the last bug fixes for 2022.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Hello everyone,

I have a small update for both branch of Dev-Object. What new for Dev-Object 2.x.x-All OS branch :
  • Code generator rules about DisableDebugger / EnableDebugger keywords
See First post for download link.

What new for Dev-Object 2.x.x-Linux branch :
  • Code generator rules about DisableDebugger / EnableDebugger keywords
  • Minor bug correction in the Options Editor
See second post for download link.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Edit : The following post was the response to question about if Dev-Object can be compiled on Mac OS. Apparently the question was posted by a spamming Bot. Never the less this is the answer to that particular question for those you might be interested.

The all OS version might need some adjustment for the MAC OS because as I have said I don't have a Mac Computer to try the compile myself.

The adjustment are about the gadget position inside the the windows (Main, OptionsEditor and maybe the StatsRequester). Another point is where the program preferences file should be saved. Just look inside the code for section of code like this :

Code: Select all

CompilerSelect #PB_Compiler_OS
    
  CompilerCase #PB_OS_Windows 
    
  CompilerCase #PB_OS_Linux
    
  CompilerCase #PB_OS_MacOS
    
CompilerEndSelect
That being said Dev-Object don't use OS Specific code, so it should compile flawlessly under MAC OS using PureBasic version 6.01 LTS

Best regards
StarBootics
Last edited by StarBootics on Mon Apr 03, 2023 7:37 pm, edited 1 time in total.
The Stone Age did not end due to a shortage of stones !
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Dev-Object

Post by Lunasole »

Wished to look at it, but cannot download from that dropbox
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Lunasole wrote: Fri Mar 31, 2023 7:10 pm Wished to look at it, but cannot download from that dropbox
Strange, because many have managed to download it. Something I can consider is to upload the source code on my GitHub account.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Re: Dev-Object

Post by Lunasole »

StarBootics wrote: Fri Mar 31, 2023 7:28 pm Strange, because many have managed to download it. Something I can consider is to upload the source code on my GitHub account.

Best regards
StarBootics
Probably in my case dropbox is somehow blocked in browser (it uses lot of 3-party resources, scripts, etc).
Yes, github is quite more universal.
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Lunasole wrote: Fri Mar 31, 2023 9:16 pm Yes, github is quite more universal.
Just to let you know that Dev-Object-V200-All-OS is up on my GitHub account. (See first post for link) Let me know if you also want the Dev-Object-V200-Linux uploaded on GitHub.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Hello everyone,

I'm posting the following message just to let you know that I have discovered some issues writing code with an OOP approach with PureBasic. When your program has to deal with a large amount of heap memory you are ending up with a highly fragmented memory and your program run slower and slower. This is particularly true when you compose objects with smaller objects. A Trihedron which is consisting of a Position vector, a tangent vector, a normal vector and a binormal vector. So a total of 5 fragments, 1 fragment for the Trihedron that contain the memory addresses of the 4 vectors to represent it.

So I will release a maintenance version of Dev-Object in the coming days since I have discovered some issues with the code generator, that being said no new features will be added.

EDIT : The source code along with support files are now on GitHub : https://github.com/StarBootics/Dev-Object

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
User avatar
StarBootics
Addict
Addict
Posts: 1006
Joined: Sun Jul 07, 2013 11:35 am
Location: Canada

Re: Dev-Object

Post by StarBootics »

Hello everyone,

Just to let everyone know that I have found a solution about how to write OOP code in PureBasic without using Interfaces. The following code is a demo solution of the Trihedron problem I have described in my previous post.

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : OOP without Interface
; File Name : Trihedron.pb
; File version: 1.0.0
; Programming : OK - Demo
; Programmed by : StarBootics
; Date : May 5th, 2024
; Last Update : May 5th, 2024
; PureBasic code : V6.10 LTS
; Platform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

DeclareModule Vec3f
  
  Structure Vec3f
    x.f
    y.f
    z.f
    *vt.Vec3fVirtualTable
  EndStructure
  
  Prototype.f Proto_Vec3f_Get(*This.Vec3f)
  Prototype Proto_Vec3f_Set(*This.Vec3f, x.f)
  Prototype Proto_Vec3f_Update(*This.Vec3f, x.f, y.f, z.f)
  Prototype Proto_Vec3f_Equal(*This.Vec3f, *Other.Vec3f)
  Prototype Proto_Vec3f_Destructor(*to_be_destroyed)
  
  Structure Vec3fVirtualTable
    
    GetX.Proto_Vec3f_Get
    GetY.Proto_Vec3f_Get
    GetZ.Proto_Vec3f_Get
    SetX.Proto_Vec3f_Set
    SetY.Proto_Vec3f_Set
    SetZ.Proto_Vec3f_Set
    Update.Proto_Vec3f_Update
    Equal.Proto_Vec3f_Equal
    Destructor.Proto_Vec3f_Destructor
    
  EndStructure
  
  Declare Destructor(*to_be_destroyed)
  Declare Init(*This.Vec3f, x.f = 0.0, y.f = 0.0, z.f = 0.0)
  Declare.i New(x.f = 0.0, y.f = 0.0, z.f = 0.0)
  
EndDeclareModule

Module Vec3f
  
  Procedure.f Vec3f_GetX(*This.Vec3f)
    
    ProcedureReturn *This\x
  EndProcedure
  
  Procedure.f Vec3f_GetY(*This.Vec3f)
    
    ProcedureReturn *This\y
  EndProcedure
  
  Procedure.f Vec3f_GetZ(*This.Vec3f)
    
    ProcedureReturn *This\z
  EndProcedure
  
  Procedure Vec3f_SetX(*This.Vec3f, x.f)
    
    *This\x = x
    
  EndProcedure
  
  Procedure Vec3f_SetY(*This.Vec3f, y.f)
    
    *This\y = y
    
  EndProcedure
  
  Procedure Vec3f_SetZ(*This.Vec3f, z.f)
    
    *This\z = z
    
  EndProcedure
  
  Procedure Vec3f_Update(*This.Vec3f, x.f, y.f, z.f)
    
    *This\x = x
    *This\y = y
    *This\z = z
    
  EndProcedure
  
  Procedure Vec3f_Equal(*This.Vec3f, *Other.Vec3f)
    
    *This\x = *Other\x
    *This\y = *Other\y
    *This\z = *Other\z
    
  EndProcedure
  
  Procedure Destructor(*to_be_destroyed)
    
    FreeStructure(*to_be_destroyed)
    
  EndProcedure

  Global Vec3fVirtualTable.Vec3fVirtualTable
  
  Vec3fVirtualTable\GetX = @Vec3f_GetX()
  Vec3fVirtualTable\GetY = @Vec3f_GetY()
  Vec3fVirtualTable\GetZ = @Vec3f_GetZ()
  Vec3fVirtualTable\SetX = @Vec3f_SetX()
  Vec3fVirtualTable\SetY = @Vec3f_SetY()
  Vec3fVirtualTable\SetZ = @Vec3f_SetZ()
  Vec3fVirtualTable\Update = @Vec3f_Update()
  Vec3fVirtualTable\Equal = @Vec3f_Equal()
  Vec3fVirtualTable\Destructor = @Destructor()
  
  Procedure Init(*This.Vec3f, x.f = 0.0, y.f = 0.0, z.f = 0.0)
    
    *This\vt = @Vec3fVirtualTable
    *This\x = x
    *This\y = y
    *This\z = z
    
  EndProcedure
  
  Procedure.i New(x.f = 0.0, y.f = 0.0, z.f = 0.0)
    
    *This.Vec3f = AllocateStructure(Vec3f)
    
    If *This = #Null
      End
    EndIf
    
    Init(*This, x, y, z)
    
    ProcedureReturn *This
  EndProcedure
  
EndModule

DeclareModule Trihedron
  
  Structure Trihedron
    
    Position.Vec3f::Vec3f
    Tangent.Vec3f::Vec3f
    Normal.Vec3f::Vec3f
    Binormal.Vec3f::Vec3f
    *vt.TrihedronVirtualTable
    
  EndStructure
  
  Prototype.i Proto_Trihedron_Get(*This.Trihedron)
  Prototype Proto_Trihedron_Set(*This.Trihedron, *Vector.Vec3f::Vec3f)
  Prototype Proto_Trihedron_Reset(*This.Trihedron)
  Prototype Proto_Trihedron_Destructor(*to_be_destroyed)
  
  Structure TrihedronVirtualTable
    
    GetPosition.Proto_Trihedron_Get
    GetTangent.Proto_Trihedron_Get
    GetNormal.Proto_Trihedron_Get
    GetBinormal.Proto_Trihedron_Get
    SetPosition.Proto_Trihedron_Set
    SetTangent.Proto_Trihedron_Set
    SetNormal.Proto_Trihedron_Set
    SetBinormal.Proto_Trihedron_Set
    Reset.Proto_Trihedron_Reset
    Destructor.Proto_Trihedron_Destructor
    
  EndStructure
  
  Declare Destructor(*to_be_destroyed)
  Declare Init(*This.Trihedron, *Position.Vec3f::Vec3f = #Null, *Tangent.Vec3f::Vec3f = #Null, *Normal.Vec3f::Vec3f = #Null, *Binormal.Vec3f::Vec3f = #Null)
  Declare.i New(*Position.Vec3f::Vec3f = #Null, *Tangent.Vec3f::Vec3f = #Null, *Normal.Vec3f::Vec3f = #Null, *Binormal.Vec3f::Vec3f = #Null)
  
EndDeclareModule

Module Trihedron
  
  Procedure.i Trihedron_GetPosition(*This.Trihedron)
  
    ProcedureReturn *This\Position
  EndProcedure
  
  Procedure.i Trihedron_GetTangent(*This.Trihedron)
  
    ProcedureReturn *This\Tangent
  EndProcedure
  
  Procedure.i Trihedron_GetNormal(*This.Trihedron)
  
    ProcedureReturn *This\Normal
  EndProcedure
  
  Procedure.i Trihedron_GetBinormal(*This.Trihedron)
  
    ProcedureReturn *This\Binormal
  EndProcedure
  
  Procedure Trihedron_SetPosition(*This.Trihedron, *Position.Vec3f::Vec3f)
    
    If *Position <> #Null
      *This\Position\vt\Equal(*This\Position, *Position)
    EndIf
    
  EndProcedure
  
  Procedure Trihedron_SetTangent(*This.Trihedron, *Tangent.Vec3f::Vec3f)
    
    If *Tangent <> #Null
      *This\Tangent\vt\Equal(*This\Tangent, *Tangent)
    EndIf
    
  EndProcedure
  
  Procedure Trihedron_SetNormal(*This.Trihedron, *Normal.Vec3f::Vec3f)
    
    If *Normal <> #Null
      *This\Normal\vt\Equal(*This\Normal, *Normal)
    EndIf
    
  EndProcedure
  
  Procedure Trihedron_SetBinormal(*This.Trihedron, *Binormal.Vec3f::Vec3f)
    
    If *Binormal <> #Null
      *This\Binormal\vt\Equal(*This\Binormal, *Binormal)
    EndIf
    
  EndProcedure
  
  Procedure Trihedron_Reset(*This.Trihedron)
    
    *This\Position\vt\Update(*This\Position, 0.0, 0.0, 0.0)
    *This\Tangent\vt\Update(*This\Tangent, 0.0, 0.0, 1.0)
    *This\Normal\vt\Update(*This\Normal, 1.0, 0.0, 0.0)
    *This\Binormal\vt\Update(*This\Binormal, 0.0, 1.0, 0.0)
    
  EndProcedure
  
  Procedure Destructor(*to_be_destroyed)
    
    FreeStructure(*to_be_destroyed)
    
  EndProcedure
  
  Global TrihedronVirtualTable.TrihedronVirtualTable
  
  TrihedronVirtualTable\GetPosition = @Trihedron_GetPosition()
  TrihedronVirtualTable\GetTangent = @Trihedron_GetTangent()
  TrihedronVirtualTable\GetNormal = @Trihedron_GetNormal()
  TrihedronVirtualTable\GetBinormal = @Trihedron_GetBinormal()
  TrihedronVirtualTable\SetPosition = @Trihedron_SetPosition()
  TrihedronVirtualTable\SetTangent = @Trihedron_SetTangent()
  TrihedronVirtualTable\SetNormal = @Trihedron_SetNormal()
  TrihedronVirtualTable\SetBinormal = @Trihedron_SetBinormal()
  TrihedronVirtualTable\Reset = @Trihedron_Reset()
  TrihedronVirtualTable\Destructor = @Destructor()
  
  Procedure Init(*This.Trihedron, *Position.Vec3f::Vec3f = #Null, *Tangent.Vec3f::Vec3f = #Null, *Normal.Vec3f::Vec3f = #Null, *Binormal.Vec3f::Vec3f = #Null)
    
    *This\vt = @TrihedronVirtualTable
    
    Vec3f::Init(*This\Position, 0.0, 0.0, 0.0)
    Vec3f::Init(*This\Tangent, 0.0, 0.0, 1.0)
    Vec3f::Init(*This\Normal, 1.0, 0.0, 0.0)
    Vec3f::Init(*This\Binormal, 0.0, 1.0, 0.0)
    
    If *Position <> #Null
      *This\Position\vt\Equal(*This\Position, *Position)
    EndIf
    
    If *Tangent <> #Null
      *This\Tangent\vt\Equal(*This\Tangent, *Tangent)
    EndIf
    
    If *Normal <> #Null
      *This\Normal\vt\Equal(*This\Normal, *Normal)
    EndIf
    
    If *Binormal <> #Null
      *This\Binormal\vt\Equal(*This\Binormal, *Binormal)
    EndIf
    
  EndProcedure
  
  Procedure.i New(*Position.Vec3f::Vec3f = #Null, *Tangent.Vec3f::Vec3f = #Null, *Normal.Vec3f::Vec3f = #Null, *Binormal.Vec3f::Vec3f = #Null)
    
    *This.Trihedron = AllocateStructure(Trihedron)
    
    If *This = #Null
      End
    EndIf
    
    Init(*This, *Position, *Tangent, *Normal, *Binormal)
    
    ProcedureReturn *This
  EndProcedure
  
EndModule

CompilerIf #PB_Compiler_IsMainFile
  
  Vec3f::Init(MyVector.Vec3f::Vec3f)
  
  MyVector\vt\SetX(MyVector, 2.25)
  MyVector\vt\SetY(MyVector, 3.25)
  MyVector\vt\SetZ(MyVector, 4.25)
  
  Debug MyVector\vt\GetX(MyVector)
  Debug MyVector\vt\GetY(MyVector)
  Debug MyVector\vt\GetZ(MyVector)
  Debug ""
  Debug "-------------------------------"
  Debug ""
  
  *MyOtherVector.Vec3f::Vec3f = Vec3f::New(4.25, 3.75, 2.75)
  Debug *MyOtherVector\vt\GetX(*MyOtherVector)
  Debug *MyOtherVector\vt\GetY(*MyOtherVector)
  Debug *MyOtherVector\vt\GetZ(*MyOtherVector)
  Debug ""
  Debug "-------------------------------"
  Debug ""
  
  *MyOtherVector\vt\Destructor(*MyOtherVector)
  
  NewList Positions.Vec3f::Vec3f()
  
  AddElement(Positions())
  Vec3f::Init(Positions(), 5.50, 6.25, 7.15)
  
  AddElement(Positions())
  Vec3f::Init(Positions(), 6.50, 7.25, 8.75)
  
  ForEach Positions()
    Debug Positions()\vt\GetX(Positions())
    Debug Positions()\vt\GetY(Positions())
    Debug Positions()\vt\GetZ(Positions())
    Debug ""
    Debug "-------------------------------"
    Debug ""
  Next
  
  Trihedron::Init(MyTrihedron.Trihedron::Trihedron)
  *Position.Vec3f::Vec3f = MyTrihedron\vt\GetPosition(MyTrihedron)
  *Tangent.Vec3f::Vec3f = MyTrihedron\vt\GetTangent(MyTrihedron)
  *Normal.Vec3f::Vec3f = MyTrihedron\vt\GetNormal(MyTrihedron)
  *Binormal.Vec3f::Vec3f = MyTrihedron\vt\GetBinormal(MyTrihedron)
  
  Debug *Position\vt\GetX(*Position) 
  Debug *Position\vt\GetY(*Position) 
  Debug *Position\vt\GetZ(*Position) 
  Debug ""
  Debug *Tangent\vt\GetX(*Tangent) 
  Debug *Tangent\vt\GetY(*Tangent) 
  Debug *Tangent\vt\GetZ(*Tangent) 
  Debug ""
  Debug *Normal\vt\GetX(*Normal) 
  Debug *Normal\vt\GetY(*Normal) 
  Debug *Normal\vt\GetZ(*Normal) 
  Debug ""
  Debug *Binormal\vt\GetX(*Binormal) 
  Debug *Binormal\vt\GetY(*Binormal) 
  Debug *Binormal\vt\GetZ(*Binormal) 
  
  Debug ""
  Debug "-------------------------------"
  Debug ""
  
  *MyTrihedron2.Trihedron::Trihedron = Trihedron::New()
  *Position = *MyTrihedron2\vt\GetPosition(*MyTrihedron2)
  *Tangent = *MyTrihedron2\vt\GetTangent(*MyTrihedron2)
  *Normal = *MyTrihedron2\vt\GetNormal(*MyTrihedron2)
  *Binormal = *MyTrihedron2\vt\GetBinormal(*MyTrihedron2)
  
  Debug *Position\vt\GetX(*Position) 
  Debug *Position\vt\GetY(*Position) 
  Debug *Position\vt\GetZ(*Position) 
  Debug ""
  Debug *Tangent\vt\GetX(*Tangent) 
  Debug *Tangent\vt\GetY(*Tangent) 
  Debug *Tangent\vt\GetZ(*Tangent) 
  Debug ""
  Debug *Normal\vt\GetX(*Normal) 
  Debug *Normal\vt\GetY(*Normal) 
  Debug *Normal\vt\GetZ(*Normal) 
  Debug ""
  Debug *Binormal\vt\GetX(*Binormal) 
  Debug *Binormal\vt\GetY(*Binormal) 
  Debug *Binormal\vt\GetZ(*Binormal) 
  
  *MyTrihedron2\vt\Destructor(*MyTrihedron2)
  
CompilerEndIf

; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<
Now, with that out of the way I take the opportunity to tell all of you that I'm not going to update Dev-Object anymore. The reason for that is due to the fact that I'm in the process to create my own programming language. For the moment I'm considering a source to source compiler using C as a backend language and use GCC to compile the source code into a program but who knows maybe I will plunge into LLVM and create a real compiler for it down the road.

Best regards
StarBootics
The Stone Age did not end due to a shortage of stones !
Post Reply