What does my PreCompiler do?
- Support for OOP
- Creation of Include-Libraries
- When creating DLLs, import files are created
- Creation of a PreProcess, which can be further processed without PreCompiler.
- Original files are not changed.
- Error messages are displayed by the IDE in the correct place
- Runs on Mac and Windows
What are IncludeLlibraries?
Unfortunately, I can't offer any real libraries, this is the closest I can get. The basic structure of a IncludeLibrary corresponds to a DLL. The PreCompiler automatically detects in source code whether this library is needed and automatically adds it.
How does OOP work?
I assume that OOP is known in principle. A class is defined as:
Code: Select all
Interface <Class name>[extends <Parent>]
<method>
EndInterface
Structure s<class name>[extends s<Parent>]
<member>
EndStructure
DeclareClass(<class name>[,<Parent[,AllowNull]])
DefineClass(<class name>[,<Parent[,AllowNull]])
Procedure <class name>_<Methode>(*Self.s<class name> ...)
EndProcedure
Besides the usual methods, there are a number of special cases:
The constructors: If successful, a #True must be returned.
Code: Select all
_Constructor (*self)
ConstructorEx (*self, *para)
<class name> (*self)
<Class name>Ex (*self, *para)
Code: Select all
_Destructor (*self)
De<class name> (*self)
Code: Select all
_CopyConstructor (*self)
An object is created with
Code: Select all
<class name>\new ([*para])
Release goes with
Code: Select all
FreeObject (<Object>)
Code: Select all
CopyObject (<Object>)
Code: Select all
<class name>\IsAccessable (<Object>)
Code: Select all
<class name>\IsClass (<Object>)
There are also two constants
Code: Select all
#<Class name>_NameTable
#<class name>_ParaTable
Unnecessary constants are removed by the PreCompiler, so that they do not create bigger exe.
How do I create a IncludeLibrary?
In principle, you can write a normal DLL with ProcedureDLL etc. The source code for such a library ideally has an extension ". pbLib". The PreCompiler then splits the whole file and saves it. This has to be done for every PureBasic version. There are the following additional commands:
Code: Select all
ResidentExport
...
EndResidentExport
Code: Select all
ExportClass (<class name>)
IMPORTANT!
No Module/EndModule are allowed in IncludeLibraries. PreCompiler will also acknowledge them accordingly with an error message.
IncludeLibraries may use other IncludeLibraries (including their exported classes). If you change a library, you should also rebuild all dependent libraries.
What is the automatic creation of an import file when creating a DLL?
When a DLL is created, a file with an import-endImport block is automatically created. The name is simple "<DLL-name>.imp.pb" .
It is located where the. DLL,. LIB and. EXP (Windows) are located.
What is important to note
Due to the way the PreCompiler works, it is not allowed to use any PreCompiler specific things or IncludeLibraries in the first line of the main file. In the second line there are no problems. If you don't pay attention to this, you get a module error.
IncludePath works with relative information more in the main file. The best thing to do is to avoid this command completely.
The PreCompiler is written for 5.61 and higher and assumes that it is compiled with Unicode.
How to set up the PreCompiler - Automatic version
Simple create the executeable (i recommend a empty directory) and launch it. A Setup should appear. Just
How to set up the PreCompiler - Manual version
First, you should teach the IDE the extension "pbLib". Under "File>Preferences..." add the extension "pbLib" in the area "Editor" "Code file extensions".
Compile the source code for the PreCompiler and enter it in the Tools menu. 4 entries are required.
Entry 1:
It fulfils a dual function. Once the PreCompiler is started here when you run Compile/Run. Second a PreProcess can be created by calling it directly from the menu. A "<FileName>.PreProcess.pb" will then be created.
- Commandline = <Precomiler. exe>
- Arguments = "%FILE" "%COMPILEFILE" "%EXECUTABLE"
- WorkingDirectory = <Directory where the IncludeLibraries are to be stored>
- Name = PreCompiler
- Event to trigger the tool = Before Compile/Run
- Wait until Tools end = Checked
- Commandline = <Precomiler. exe>
- Arguments = "%FILE" "%COMPILEFILE" "%EXECUTABLE"
- WorkingDirectory = <Directory where the IncludeLibraries are to be stored>
- Name = PreCompiler Executable
- Event to trigger the tool = Before Create Executable
- Wait until Tools end = Checked
- Hide Tool from Main Menu = Checked
- Commandline = <Precomiler. exe>
- Arguments = "%FILE" "%COMPILEFILE" "%EXECUTABLE" CreateLib
- WorkingDirectory = <Directory where the IncludeLibraries are to be stored>
- Name = PreCompiler Create Lib
- Event to trigger the tool = Menu or Shortcut
- Commandline = <Precomiler. exe>
- Arguments = "%FILE" "%COMPILEFILE" "%EXECUTABLE" DeleteLib
- WorkingDirectory = <Directory where the IncludeLibraries are to be stored>
- Name = PreCompiler Create Lib
- Event to trigger the tool = Menu or Shortcut
Now you only have to restart the compiler in the compiler menu.
Important to know: The PreCompiler can be 32Bit as well as 64Bit. He can then treat both. You don't have to create your own exe for each bit version. The directory for the IncludeLibraries can be the same for everyone. The names are chosen according to the operating system and the compiler version and do not overlap.