[Tool/Web/Other] Header file generator - generate .inc file from your gamemode
#1

Yesterday I came up with a script to extract all function headers from gamemode and put them into an .inc file.
You can use this to get auto completion working for all your gamemode functions!

Attached are 2 scripts:
functions - outputs list of all function headers from given .pwn file
generate_headers - gets headers from functions script and saves them into given .inc file in includes/ folder

You have to put both files in your sa-mp directory and run in a bash shell (git's MingW works fine) and type this:
Code:
generate_headers gamemodes/convoy.pwn a_convoy.inc
put your gamemode name instead of "convoy".

Run this every time you add new functions. All of your functions should appear in the panel on the right, additionally, Pawno will suggest function names and parameters when you press CTRL+SPACE.

You can add this to your build script (if you have one) to generate headers every time you build the gamemode - it's a good idea to have a build script when you use git for version control, or instead of using pawno's compile to have your warnings in errors visible in a secondary window.

DO NOT INCLUDE THE .inc FILE IN YOUR SCRIPT - just having it in includes/ directory should work for you.

Here's how the script works:

Code:
cat $input | grep '^\(\|public \|stock \)\(\|[A-Za-z][a-z]*[:]\)[a-zA-Z0-9_]*([^\(\)]*)[^;]*$' | sed -e 's/public //' -e 's/stock //' -e 's/^/native /'
The cat $input bit prints contents of the, then | (pipe) symbol sends output to the next commands as input - it's used multiple times.

grep '^\(\|public \|stock \)\(\|[A-Za-z][a-z]*[:]\)[a-zA-Z0-9_]*([^\(\)]*)[^;]*$' uses regex to match the string lines to get only functions that start at the beginning of the line (stock, public, and other functions).

Lastly, sed -e 's/public //' -e 's/stock //' -e 's/^/native / strips all lines from 'public ' and 'stock ', and adds 'native' to each line.

The generate_headers script just dumps all this into an .inc file and adds comments.
Reply


Messages In This Thread
Header file generator - generate .inc file from your gamemode - by mick88 - 26.11.2013, 13:14
Re: Header file generator - generate .inc file from your gamemode - by iPrivate - 27.11.2013, 19:44

Forum Jump:


Users browsing this thread: 1 Guest(s)