Commit Graph

73 Commits (0d3b868de79c90d7f4c226927d620a569e7d0b75)

Author SHA1 Message Date
Giel van Schijndel 8344514617 Make sure to use the %prefix and %suffix when declaring pointers to structs
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5524 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-12 21:39:49 +00:00
Giel van Schijndel aad47ff640 Add a new struct level qualifier: %fetchByRow
* User code can use this to provide code that the SQLite code generator can use to get a pointer to some other struct
 * Make it so that you can only declare member fields with a `struct` type when the respective struct has a %fetchByRow directive in it
 * Generate loading code for struct-type fields in the c_sqliteload codegenerator by means of the code provided by the %fetchByRow directive


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5523 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-12 21:30:05 +00:00
Giel van Schijndel b464ee82a5 Don't generate SQL code (that's SQL statements for table definitions as well as SQLite loading code) for fields of type C-only-field
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5520 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-12 20:36:45 +00:00
Giel van Schijndel 9eb61150c0 Add a new datatype to the mini database schema meta language: `struct`
* Allows "linking" in the database to other struct instances
 * Will be represented as a pointer to the target struct in the C datastructures
 * Will be represented as an integer ID in tables


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5519 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-12 19:48:39 +00:00
Giel van Schijndel caa467d9ee * Improve error message generated on type mismatch by code generator c_sqliteload
* Fix a syntax error in code generator sql_tabledef and add and initialize the used variables to produce an error message


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5518 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-12 19:17:08 +00:00
Giel van Schijndel 2e5fab25f8 Attach line numbers to the AST of field declarations, and use it when reporting field-related errors
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5513 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 22:14:09 +00:00
Giel van Schijndel 65dee90e74 Accept all of ([US]D?WORD|[US]BYTE) as "transition" types in the mini database schema meta language
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5511 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 21:53:10 +00:00
Giel van Schijndel e33f083aaf Give errors when encountering unmatched struct-level and enum-level directives
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5510 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 21:48:34 +00:00
Giel van Schijndel 7f75a8f3c7 Add a new %nomacro directive to prevent macro definition of a struct and its children if the parent of that struct has a %macro directive
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5505 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 16:41:59 +00:00
Giel van Schijndel 05bf9bdcd8 Declare UDWORDs as UDWORD in the C code (doh!) not as unsigned int...
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5502 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 15:33:48 +00:00
Giel van Schijndel d8d2ad0dd6 Add a transition type "UDWORD" to the mini database schema meta language
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5501 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 15:30:32 +00:00
Giel van Schijndel 975ecbbb95 Add copies of strings declared with the "string" type in the struct definitions; thus have the structs take ownership of these strings (they're allocated with strdup)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5499 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 14:48:39 +00:00
Giel van Schijndel 8ce0412a28 * Add new %macro, %macroprefix and %macrosuffix directives to the mini database schema meta language
* Generate macro definitions similar to our current "inheritance-like" structure as created by macros when the above %macro directive is used


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5498 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 14:02:17 +00:00
Giel van Schijndel b16526e0a9 Move the code for generating the forward declaration of the SQLite loading function to a separate function of its own: printLoadFunc
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5497 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 13:30:25 +00:00
Giel van Schijndel 4452048964 Don't use a default value for %valprefix when either %valprefix or %valsuffix has been specified
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5495 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 13:06:02 +00:00
Giel van Schijndel 51370fcdbd Add a new enum-level directive: %valsuffix which (similar to %valprefix) adds a suffix to al enum's values
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5491 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 11:17:08 +00:00
Giel van Schijndel 3ca7c41f58 Don't add %valprefix to %max
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5490 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-11 11:13:01 +00:00
Giel van Schijndel dc0aa99fac Allow empty value prefixes as well (using the %valprefix directive)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5486 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 22:23:19 +00:00
Giel van Schijndel b1d12b5a1a * Add a new enum-level qualifier: %valprefix; this changes the default prefix (which is just the enum's name with '_' appended) prefixed to all enum values
* Add a new enum that uses this: COMPONENT_TYPE


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5484 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 21:24:39 +00:00
Giel van Schijndel 87ad15af6a * Add a new struct-level directive: %suffix
- This directive adds a suffix to the names of structs (in the generated C code) and the subclasses that inherit from that struct
 * Use %suffix instead of %prefix in test_code.tpl


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5483 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 21:11:24 +00:00
Giel van Schijndel 2a11247d7e Add a new enum-level directive: %max "param":
* This will add an enumerator to the end of the generated C enum code with "param" as its name (prefixed by the enum's name of course)


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5482 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 21:02:58 +00:00
Giel van Schijndel eb7bd7be49 Update test_code.tpl as well to match r5480's change in syntax
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5481 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 20:52:57 +00:00
Giel van Schijndel 118a83f42a Slight change in syntax to not require (and disallow) a semi-colon after struct-level directives that open a new scope (terminated with "end\;"
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5480 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 20:52:09 +00:00
Giel van Schijndel c7f60d7e7d #include "lib/sqlite3/sqlite3.h" in generated SQLite loading code
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5479 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 20:44:14 +00:00
Giel van Schijndel 82a2aea03f c_structdef_cg.pm: Fix an error where we forgot to use the \{"name"\} member of the hash thus resulting in bad code being generated
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5478 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 20:43:26 +00:00
Giel van Schijndel b5ff9610ea * Remove TODO comment about needing to add an IMD_Model type, because that type already exists
* Add a comment, describing the `flameModel` field


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5465 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 11:03:39 +00:00
Giel van Schijndel a80776b9fa don't use the file header template if it isn't available in the c_structdef code generator
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5464 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-10 10:58:13 +00:00
Giel van Schijndel c5b87954bc Add a new field type to the mini database scheme meta language: C-only-field
* This is a dummy type that causes the rest of the line to be included literally in the struct's definition
 * Use this field type to add ppIMDList (member var of BODY_STATS in statsdef.h)


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5460 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 20:47:17 +00:00
Giel van Schijndel 1170798c66 Add a field to hold a component's body points (COMPONENT now fully matches COMPONENT_STATS from statsdef.h)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5458 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 19:17:19 +00:00
Giel van Schijndel c6c5c981e6 Remove all TECH_LEVEL related cruft from the code as it's read from the stats files but unused throughout the rest of the code.
Read into a temporary dummy variable when loading stats.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5453 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 18:28:37 +00:00
Giel van Schijndel 44f3bf5f69 Only declare the function name of the %loadFunc directive to be declared in the file where the %loadFunc directive is located.
Don't declare the return type and parameter list to originate from the "original" source file.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5452 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 17:55:18 +00:00
Giel van Schijndel be7aef1a17 Convert dashes (-) to undersquores (_) as well in header guards (fixes a syntax error with C's preprocessor)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5451 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 17:45:56 +00:00
Giel van Schijndel db03e5b276 include (perl directive "require") code generators from the same directory as the language parser
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5450 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 17:15:44 +00:00
Giel van Schijndel 2e3280a845 Pass the output file as a command line parameter (and fall back to stdout if none is provided)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5446 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 16:05:41 +00:00
Giel van Schijndel c8dbcd6d2d * Don't refer to a "flame IMD" when loading an IMD_Model, refer to "the IMD for field \"$fieldName\"" instead
* Reference records by their ID number (unique_inheritance_id) instead of some user-code dependent function

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5444 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:30:13 +00:00
Giel van Schijndel 03cf003811 * Add line information to the AST of %preLoadTable and %postLoadRow struct-level directives
* Use these line numbers in the output of the SQLite C loading code generator to produce #line directives

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5443 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:25:46 +00:00
Giel van Schijndel d3c8f34aaf Add function prototypes for the SQLite DB load functions (declared using %loadFunc) to the struct definition header
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5442 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:25:42 +00:00
Giel van Schijndel 052c32e8ec Slightly rework c_structdef_cg.pm's header-template processing code to be more similar to c_sqliteload_cg.pm's header-template processing code
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5441 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:02:10 +00:00
Giel van Schijndel df7b09c6fa Wrap the "header/start/leader" template contents in #line directives for the SQLite C code generator's output
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5440 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 15:01:02 +00:00
Giel van Schijndel f8f4ce0854 Make sure to count __all__ lines, also those who start a new "scope" (anything that finishes with "end")
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5439 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 14:58:04 +00:00
Giel van Schijndel 3b57831282 * Add line numbers to the AST for %loadFunc directives
* Utilize these line numbers to generate #line directives in the output file


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5438 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 14:47:16 +00:00
Giel van Schijndel 1ceafee327 Add line-counting code to the mini database scheme meta language parser
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5437 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 14:36:27 +00:00
Giel van Schijndel 46fc5cc97e * Make it possible to use forward declarations to the generated struct types
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5436 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:59:23 +00:00
Giel van Schijndel 707d5cf718 * Print from a template for the C struct definition code generator as well
* Add a template for the struct definition header; adds some #include directives required to be able to compile the generated header


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5435 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:57:26 +00:00
Giel van Schijndel 2d1b9d8694 Only shift the next parameter from ARGV if there are more than one (1) left in the C SQLite code generator
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5434 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:49:49 +00:00
Giel van Schijndel 74784e3f6e Add two new struct-level directives to the mini database scheme meta language:
* %preLoadTable which specifies a code block to be executed just __before__ loading in all rows in a database
 * %postLoadRow which specifies a code block to be executed after every row has been succesfully loaded in a struct


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5433 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:09:53 +00:00
Giel van Schijndel 2b6b037ade * Rename and modify the SQL SELECT statement code generator to a code generator that produces C code for loading in the contents of database tables
* Add a template file which is used by this new code generator as a file "header"
 * Add a new struct-level directive to the mini database meta scheme language: %loadFunc which specifies that the above code generator should generate a loading function for this type plus what its name should be
 * Add a new entry for this code generator to the Makefile for testing purposes


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5432 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 13:04:10 +00:00
Giel van Schijndel 40742f8d8a Give the code generators the ability to process command line arguments (before the parsing begins)
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5431 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 12:46:53 +00:00
Giel van Schijndel 3f0b1959f2 For struct-fields of an enum type store references to the enum instead of just their name
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5430 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-09 12:16:55 +00:00
Giel van Schijndel 40b6a5acf7 Don't store the name of the struct we inherit from in the "inherit" field, instead store a reference to that struct
git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5419 4a71c877-e1ca-e34f-864e-861f7616d084
2008-07-08 11:37:23 +00:00