Skip to content

LoTeK-Zone/purebasic-module-preprocessor-autodeclare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LoTeK PureBasic PreProcessor AutoDeclare

AutoDeclare synchronizes Declare statements with existing Procedure definitions in a PureBasic .pb source file.

Language Platform Platform Platform Version Status License

Overview

AutoDeclare scans one source file, detects procedures and declarations, compares them by scope and type, removes invalid declarations, and generates missing valid ones.

The tool is intended for PureBasic projects that use:

  • global procedures
  • DeclareModule
  • Module
  • CompilerIf #PB_Compiler_IsMainFile

The processed file is overwritten in place.

This project was developed with the assistance of AI tools for research, coding support, and documentation.

Releases

If you do not want to compile the tool yourself, you can download the ready-to-use executable from the latest release.

Windows 64-bit

File: LoTeK_PureBasic_PreProcessor_AutoDeclare_Win64_v0.3.0.exe

Build Environment:

  • Platform: Windows 11 64-bit
  • Built with: PureBasic 6.30
  • Tested on: Windows 11 x64

Download: LoTeK_PureBasic_PreProcessor_AutoDeclare_Win64_v0.3.0.exe

Linux 64-bit

File: LoTeK_PureBasic_PreProcessor_AutoDeclare_Linux64_v0.3.0

Build Environment:

  • Platform: Ubuntu 24.04 LTS 64-bit
  • Built with: PureBasic 6.30
  • Tested on: Ubuntu 24.04 LTS x64

Download: LoTeK_PureBasic_PreProcessor_AutoDeclare_Linux64_v0.3.0

Features

  • generates missing declarations
  • removes obsolete declarations
  • removes duplicate declarations
  • supports DeclareModule
  • supports Module
  • supports compiler scope (CompilerIf #PB_Compiler_IsMainFile)
  • supports multiple modules
  • processes one file at a time

Technical Notes

Scope Model

Recognized scopes:

  • Global
  • DeclareModule
  • Module
  • CompilerIf #PB_Compiler_IsMainFile

Everything outside these blocks is treated as global file scope.

DeclareModule has priority over matching Module declarations when such a DeclareModule declaration already exists.

Processing Rules

AutoDeclare compares declarations and procedures by:

  • name
  • module
  • scope
  • type signature

The tool:

  1. removes wrong declarations
  2. removes obsolete declarations
  3. removes duplicate declarations
  4. inserts missing declarations

Not Supported

  • (X)IncludeFile dependency tracking
  • project-wide scanning
  • ProcedureDLL

Notes

The tool inserts detected Declare statements at a sensible default location:

  • in the global scope at the top of the file
  • inside DeclareModule, Module, or CompilerIf #PB_Compiler_IsMainFile blocks at the top of these sections
  • after EnableExplicit, if present in a scope

Depending on the project structure, it may still be necessary to move generated Declare lines manually afterwards, for example below structure definitions, constants, prototypes, or other project-specific declaration sections.

Installation

PureBasic IDE

Add the executable as a Custom Tool in the PureBasic IDE.

Parameters: %FILE

PureBasic IDE Custom Tool Setup

Usage

Run the tool with a .pb file path as parameter.

Typical workflow:

  1. pass a source file to the tool
  2. declarations are analyzed against procedures
  3. invalid declarations are removed
  4. missing declarations are generated
  5. the file is overwritten

For manual testing, see:

  • tests/TestFile.pb

Repository Structure

Show repository structure
purebasic-module-preprocessor-autodeclare
├── assets
│   └── img
│       └── Installation_PB_IDE_Screenshot_1.png
├── src
│   └── Mod_AutoDeclare.pb
├── tests
│   └── TestFile.pb
├── AGENTS.md
├── CHANGELOG.md
├── LICENSE
└── README.md

Safety Notice

  • the original file is overwritten
  • no automatic backup is created
  • use version control before running it on important files

License

MIT License

See LICENSE.