Page 1 of 3

PBHGEN - PureBasic Header Generator

Posted: Mon Feb 11, 2013 9:51 pm
by Henry00
Description:
Will read a PureBasic source file (*.pb) and generate a header out of it (*.pbi).
This program also works with SpiderBasic.

Image

Usage:
  • Under "Tools" in the PureBasic IDE add a new tool called "PBHGEN".
  • At Commandline select your copy of PBHGEN.exe
  • At Arguments type "%FILE" (with quotes).
  • At Event to trigger the tool select Sourcecode Saved.
  • Ensure you include your headers in the Source using:
  • IncludeFile #PB_Compiler_File + "i" ;- PBHGEN
  • To use automatic header generation in modules also use:
  • Module MyModule
  • IncludeFile #PB_Compiler_File + "i" ;- PBHGEN
  • EndModule
At the moment if you wish to have a procedure with structured List/Array/Map arguments, you will have to put that procedure above the code where you call it from.
This does not apply when using basic types and is a limitation of PureBasic.

Download:
PureBasic V5.73 https://00laboratories.com/wp-content/u ... HGEN573.7z

Source Code:
https://github.com/00laboratories/PBHGEN

Motivation:
PureBasic is a great language but I was always annoyed about the fact I could never choose where I would locate my Procedures, if I wished to use a Procedure somewhere I would have to move it above of the Procedure that was going to call it, the Declare statement allows to tell the compiler specific Procedures are going to exist and to find them but writing them over and over, fixing arguments is not only a pain but makes your source look like a mess. That's the reason I required an automatic header generator for PureBasic. I hope you too will enjoy the new freedom thanks to this little tool!

Official Page: https://00laboratories.com/downloads/so ... -generator

BugFixes: PBHGEN - PureBasic Header Generator

Posted: Thu Mar 21, 2013 6:42 pm
by Henry00
Version 0.2:
Fixed issue with Structure Pointers in Procedure Parameters, transforms to Pointers now.

Version 0.3:
Fixed issue with Structured List/Array/Map in Procedure Parameters.

Version 0.4:
Fixed issue where a *pointer would cause further Procedure Parameters to lose their types.

Re: PBHGEN - PureBasic Header Generator

Posted: Wed Mar 27, 2013 8:12 pm
by Henry00
Version 0.5:
Fixed issue where a *pointer.structure had no default parameter.
Fixed issue with a string as custom parameter, it was not escaped.

Re: PBHGEN - PureBasic Header Generator

Posted: Wed Jul 10, 2013 12:59 pm
by Henry00
Version 0.6:
Fixed issue where array arguments would still have impossible structures.
Added support for structured List/Array/Map arguments with some conditions.
Added support for all basic types when used with List/Array/Map arguments.

Re: PBHGEN - PureBasic Header Generator

Posted: Sat Jul 20, 2013 8:44 pm
by Henry00
Version 0.7:
Stops when encountering the statement seperator ":" or comment ";" operators.

Re: PBHGEN - PureBasic Header Generator

Posted: Sun Sep 15, 2013 5:44 pm
by Henry00
Version 0.8:
Fixed issue with a space in the directory/file path of source file.

Re: PBHGEN - PureBasic Header Generator

Posted: Mon Sep 16, 2013 3:20 am
by flaith
Thanks for your "Tool" Henry00 :)

Re: PBHGEN - PureBasic Header Generator

Posted: Mon Sep 16, 2013 7:58 am
by Henry00
flaith wrote:Thanks for your "Tool" Henry00 :)
No problem, I appreciate your comment! Thanks for letting me know you use and or like it! ^^

Re: PBHGEN - PureBasic Header Generator

Posted: Mon Sep 16, 2013 8:06 am
by flaith
Henry00 wrote:
flaith wrote:Thanks for your "Tool" Henry00 :)
No problem, I appreciate your comment! Thanks for letting me know you use and or like it! ^^
Using it and like it :wink:

Re: PBHGEN - PureBasic Header Generator

Posted: Wed Sep 18, 2013 9:49 am
by Jan2004
Henry00, Flaith: How do you install PBHGEN - tell me exactly step by step. I have followed instruction and nothing appears.

Re: PBHGEN - PureBasic Header Generator

Posted: Wed Sep 18, 2013 5:46 pm
by Henry00
Jan2004 wrote:Henry00, Flaith: How do you install PBHGEN - tell me exactly step by step. I have followed instruction and nothing appears.
You will not see anything other then automatically generated *.pbi files based on the current code you are editing.

Image

The settings should be somewhat like this, make sure to save the file you are working on. If there is no file even after you save then perhaps put %FILE in quotes "%FILE".
I hope this helps, the steps in the first post should be all you need to get it working. There is no user interface.

Re: PBHGEN - PureBasic Header Generator

Posted: Wed Sep 18, 2013 7:32 pm
by Jan2004
Ok. The same name of file is generated now with extension "pbi". Good idea, interesting results.
:D Thanks.
If I good understand: PBHGEN collects all the comments from the source file and place them in .pbi file (with the same name as source file), then creates the declarations (Declare) and also put them in the same .pbi file, after comments, which are transfered earlier. PBHGEN do not automaticaly open newly made the .pbi file: the user should find it in proper directory and open it (by double click in directory for example) to see in PureBasic Editor. Correct me or add your comment, please.

Re: PBHGEN - PureBasic Header Generator

Posted: Fri Sep 20, 2013 9:31 am
by Henry00
PBHGEN collects all the comments from the source file and place them in .pbi file (with the same name as source file), then creates the declarations (Declare) and also put them in the same .pbi file, after comments, which are transfered earlier.
Actually it parses the Source File line by line, comments will only be copied on lines where the first character is a ; (semicolon).

Code: Select all

; This Procedure will cause the application to crash.
Procedure.i Crash()
     N.i = 0
     ; PureBasic would detect / 0 with an error message.
     ProcedureReturn 5 / N
EndProcedure
This was done to ensure other comments that are used inside of procedures aren't copied. Where those comments are mostly for forums or easy reference etc. they don't have any real purpose for the programmer.
PBHGEN do not automatically open newly made the .pbi file: the user should find it in proper directory and open it (by double click in directory for example) to see in PureBasic Editor.
True, and I don't see any reason why you would want to open it, every time you save the source file it builds a new header file. Their main purpose is to allow you to seamlessly write procedures below the calls to them which adds allot of flexibility. You would only get allot of "The file you are editing has been modified, would you like to reload it?" messages.
You have to include the header into your source file using:

Code: Select all

XIncludeFile #PB_Compiler_File + "i" ;- PBHGEN
I hope this answered your questions, if there is anything else I can do feel free to ask!

Re: PBHGEN - PureBasic Header Generator

Posted: Mon Sep 23, 2013 9:47 am
by Jan2004
Of course, I agree with you. My comment was so clear that the other participants in the forum soon realized what is going inside PBHGEN.

Re: PBHGEN - PureBasic Header Generator

Posted: Fri Nov 08, 2013 10:38 pm
by majikeyric
Hi Henry,

This kind of procedure declaration, on several lines, doesn't work :

Code: Select all

Procedure.i execute(	_nbNiveaux.u,
	                        numNiveauDepart.u,
                       	_nbViesDepart.a,
                    	_IAGlobale.b)

; etc...

EndProcedure