Skip to content

Commit

Permalink
Replace the Boost preprocessor stuff with a jinja2-template.
Browse files Browse the repository at this point in the history
Is from a time where our templates were not scriptable.
  • Loading branch information
Ghabry committed Nov 26, 2018
1 parent b978235 commit 90de0ca
Show file tree
Hide file tree
Showing 66 changed files with 7,983 additions and 1,745 deletions.
5 changes: 1 addition & 4 deletions Makefile.am
Expand Up @@ -109,10 +109,7 @@ liblcf_la_SOURCES = \
src/generated/lsd_savevehiclelocation.cpp \
src/generated/rpg_chipset.cpp \
src/generated/rpg_enums.cpp \
src/generated/rpg_system.cpp \
src/boost/preprocessor/cat.hpp \
src/boost/preprocessor/stringize.hpp \
src/boost/preprocessor/config/config.hpp
src/generated/rpg_system.cpp
pkginclude_HEADERS = \
src/command_codes.h \
src/data.h \
Expand Down
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -79,6 +79,5 @@ See the file COPYING for copying conditions.

### 3rd party software

liblcf code includes a copy of Boost Preprocessor Cat and Stringize
(Boost Software License 1.0) and a copy of inih (New BSD license).
liblcf code includes a copy of inih (New BSD license).
See the source code comment headers for license details.
10 changes: 5 additions & 5 deletions generator/generate.py
Expand Up @@ -40,14 +40,14 @@
def lcf_type(field, prefix=True):
if field.size == True:
if re.match(r'Count<(.*)>', field.type):
return "COUNT"
return "Count"
else:
return "SIZE"
return "Size"
if field.type == "DatabaseVersion":
return "DATABASE_VERSION"
return "DatabaseVersion"
if field.type == "EmptyBlock":
return "EMPTY"
return "TYPED"
return "Empty"
return "Typed"

def cpp_type(ty, prefix=True):
if ty in cpp_types:
Expand Down
39 changes: 31 additions & 8 deletions generator/templates/reader.tmpl
Expand Up @@ -5,15 +5,38 @@
#include "reader_struct.h"

// Read {{ struct_name }}.
{%- set LCF_CHUNK_SUFFIX = type|upper + "_Reader" %}
{%- set LCF_CURRENT_STRUCT = struct_name %}

#define LCF_CHUNK_SUFFIX {{ type|upper }}_Reader
#define LCF_CURRENT_STRUCT {{ struct_name }}
template <>
char const* const Struct<RPG::{{ LCF_CURRENT_STRUCT }}>::name = "{{ LCF_CURRENT_STRUCT }}";

LCF_STRUCT_FIELDS_BEGIN()
template <>
Field<RPG::{{ LCF_CURRENT_STRUCT }}> const* Struct<RPG::{{ LCF_CURRENT_STRUCT }}>::fields[] = {
{%- for field in fields[struct_name]|field_is_written %}
LCF_STRUCT_{{ field|lcf_type }}_FIELD({{ field.type|cpp_type }}, {{ field.name }}, {{field.presentifdefault}}, {{field.is2k3}}),
{%- if field|lcf_type in ["Typed", "DatabaseVersion"] %}
new {{ field|lcf_type }}Field<RPG::{{ LCF_CURRENT_STRUCT }}, {{ field.type|cpp_type }}>(
&RPG::{{ LCF_CURRENT_STRUCT }}::{{ field.name }},
{{ LCF_CHUNK_SUFFIX }}::Chunk{{ LCF_CURRENT_STRUCT }}::{{ field.name }},
"{{ field.name }}",
{{field.presentifdefault}},
{{field.is2k3}}
),
{%- elif field|lcf_type in ["Empty"] %}
new {{ field|lcf_type }}Field<RPG::{{ LCF_CURRENT_STRUCT }}>(
{{ LCF_CHUNK_SUFFIX }}::Chunk{{ LCF_CURRENT_STRUCT }}::{{ field.name }},
"{{ field.name }}",
{{field.presentifdefault}},
{{field.is2k3}}
),
{%- elif field|lcf_type in ["Size", "Count"] %}
new {{ field|lcf_type }}Field<RPG::{{ LCF_CURRENT_STRUCT }}, {{ field.type|cpp_type }}>(
&RPG::{{ LCF_CURRENT_STRUCT }}::{{ field.name }},
{{ LCF_CHUNK_SUFFIX }}::Chunk{{ LCF_CURRENT_STRUCT }}::{{ field.name }}_size,
{{field.presentifdefault}},
{{field.is2k3}}
),
{%- endif %}
{%- endfor %}
LCF_STRUCT_FIELDS_END()

#undef LCF_CURRENT_STRUCT
#undef LCF_CHUNK_SUFFIX
NULL
};
35 changes: 0 additions & 35 deletions src/boost/preprocessor/cat.hpp

This file was deleted.

104 changes: 0 additions & 104 deletions src/boost/preprocessor/config/config.hpp

This file was deleted.

33 changes: 0 additions & 33 deletions src/boost/preprocessor/stringize.hpp

This file was deleted.

0 comments on commit 90de0ca

Please sign in to comment.