PBHGEN - PureBasic Header Generator

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
USCode
Addict
Addict
Posts: 912
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle, USA

Re: PBHGEN - PureBasic Header Generator

Post by USCode »

Very cool. This looks like something I did independently a few years ago as well but only recently released:
http://www.purebasic.fr/english/viewtop ... 40&t=56697
Yours looks more advanced, mine is pretty simple at only 20+ lines of code it only handles simple 1-line declarations. (Source code is provided)
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Version 0.9:
Fixed issue with multiline arguments. Thanks majikeyric for pointing this out.

@majikeyric:
Thanks for the report, I appreciate the feedback and am glad to know others found / use this tool, fixed the issue!

@USCode:
Yes that's exactly the problem I was experiencing, I love building huge projects like game engines and you cannot expect that all the game object routines come first and the actual object manager at the bottom etc. Great to see more interest towards this sort of thing.
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Version 5.31
Now naming version after PureBasic's version when possible.
Added support for Runtime procedure statements.
Added support for case independent keyword detection.
Improved ProcedureDLL and ProcedureCDLL with appropriate DeclareDLL and DeclareCDLL.
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Version 5.31b
Improved parsing engine to comply with latest PureBasic syntax.
Optimized header file content and size.
Now supports any amount of spaces in front of a procedure.
Treats a colon seperator as a new line to allow multiple declarations on a single line.
Added support for module header generation (Edit: The Following Does No Longer Apply: requires additional files and include lines in source code).
Last edited by Henry00 on Thu Mar 19, 2015 9:42 pm, edited 3 times in total.
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Version 5.31c
Using compiler directives to remove the need of multiple files for modules.
  • Module MyModule
  • IncludeFile #PB_Compiler_File + "i" ;- PBHGEN
  • EndModule
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Version 5.31d
Fixed case where the compiler directives failed when a module is declared above global procedures.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: PBHGEN - PureBasic Header Generator

Post by Dude »

Does this tool follow IncludeFiles, to create headers of procedures found in included files?
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Dude wrote:Does this tool follow IncludeFiles, to create headers of procedures found in included files?
No that's not how it works. As mentioned in the instructions when you save say Vector3.pb it will create Vector3.pbi and it's Vector3.pb's responsibility to have the following line at the top of the source code:
  • IncludeFile #PB_Compiler_File + "i" ;- PBHGEN
Which causes Vector3.pbi to be included by PureBasic.
That makes it a matter of copy pasting a single line of code to make use of the header file. The header is always up-to-date as it generates whenever you save the source code so there is no need to generate headers for Vector3.pb each time you save test.pb just because it was included.

I hope that clarifies it, you should give it a try and you will see how seamless it is. :)
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Version 5.31e
Fixed a comment after EndProcedure / EndModule / EndMacro skipping the next procedure declaration.
Now ignoring content between Macro / EndMacro statements.
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Tristano »

Very nice indeed... thanks!

Does it work with PB 5.41?

Any chances you will release the source of PBHGEN?
The PureBASIC Archives: FOSS Resources:
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Hello! I wasn't aware PureBasic 5.41 came out but after reading up and doing some quick tests it doesn't seem like any syntax was changed that would break the parser. Please correct me if I am wrong.

Also I have released the source code here as requested: https://bitbucket.org/Henry00/pbhgen

I must apologize that it's a single file project but I hope it contains what you were looking for. When I update I will continue to use the repository from now on.
Thanks for the feedback, very nice to see people using it!
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Tristano »

Hi @Henry00,
Henry00 wrote:... after reading up and doing some quick tests it doesn't seem like any syntax was changed that would break the parser. Please correct me if I am wrong.
I've just downloaded it from BitBucket. I'll try out tomorrow and let you know!
Henry00 wrote:Also I have released the source code here as requested: https://bitbucket.org/Henry00/pbhgen
Thanks, that was really kind of you. For me is a good way to learn PB, by looking into code (very new to PB, still), and it might open up to new ideas, future maintainance, ecc.
Best regards,
Tristano (Italy)
The PureBASIC Archives: FOSS Resources:
Henry00
User
User
Posts: 88
Joined: Thu Jul 12, 2012 7:00 pm
Location: Germany
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Henry00 »

Version 5.42
Added SpiderBasic header generation support.
yrreti
Enthusiast
Enthusiast
Posts: 546
Joined: Tue Oct 31, 2006 4:34 am

Re: PBHGEN - PureBasic Header Generator

Post by yrreti »

Very Nice program, and thanks for sharing it!
But I found that I needed to add this note to my code: Please correct me if it's wrong:

Code: Select all

;IMPORTANT:
;PBHGEN.exe eliminates the problem of Procedure placements in your program by creating
;a Declare list of all the Procedures in your program.
;(place PBHGEN.exe in PB's home directory)
;PBHGEN.exe must be added to your tools menu, and is run when ever you save your program.
;But after adding the next program line below,
;*** YOU MUST SAVE THIS CODE FIRST!***,
;in order for PBHGEN to first create the file. If you don't, then it will error out on this
;next program line, because the file hadn't been created yet.
;Another important note is, that if you add a new procedure or remove one, you need to save
;again first before running this code, so it enters in all the changes to the generated file.
;Also important, is that the created .pbi name is based on your programs name.
;So if you change the name, you will need to delete the older ones you don't need any more.
IncludeFile #PB_Compiler_File + "i" ;- PBHGEN
Again thank you, because it's very helpful.

yrreti
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Re: PBHGEN - PureBasic Header Generator

Post by Tristano »

Dear @Henry00, thanks a lot for this great tool and for maintaining it.

I need to ask you some more info on how PBHGEN handles modules. From the documentation I haven't understood clearly how it goes about them: does it create separate files (with naming convention filename.modname.pbi)? And how does it handle modules public and private declarations?

Any chance in the future PBHGEN could also auto-magically add its inclusion lines into the source -- possibly, handling modules as well?
The PureBASIC Archives: FOSS Resources:
Post Reply