Skip to content

Commit

Permalink
Add definitions of constants
Browse files Browse the repository at this point in the history
  • Loading branch information
mateofio committed Dec 6, 2018
1 parent bbde6be commit 6cd8e2d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ add_library(lcf
src/generated/lsd_savevehiclelocation.cpp
src/generated/rpg_chipset.cpp
src/generated/rpg_enums.cpp
src/generated/rpg_savepartylocation.cpp
src/generated/rpg_state.cpp
src/generated/rpg_system.cpp
)

Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ liblcf_la_SOURCES = \
src/generated/lsd_savevehiclelocation.cpp \
src/generated/rpg_chipset.cpp \
src/generated/rpg_enums.cpp \
src/generated/rpg_savepartylocation.cpp \
src/generated/rpg_state.cpp \
src/generated/rpg_system.cpp
pkginclude_HEADERS = \
src/command_codes.h \
Expand Down
2 changes: 2 additions & 0 deletions builds/vs2015/liblcf.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@
<ClCompile Include="..\..\src\generated\lsd_savetitle.cpp" />
<ClCompile Include="..\..\src\generated\lsd_savevehiclelocation.cpp" />
<ClCompile Include="..\..\src\generated\rpg_chipset.cpp" />
<ClCompile Include="..\..\src\generated\rpg_savepartylocation.cpp" />
<ClCompile Include="..\..\src\generated\rpg_state.cpp" />
<ClCompile Include="..\..\src\generated\rpg_system.cpp" />
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion generator/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ def generate():
type=filetype
))

if needs_ctor(struct.name):
if needs_ctor(struct.name) or struct.name in constants:
filepath = os.path.join(tmp_dir, 'rpg_%s.cpp' % filename)
with open(filepath, 'w') as f:
f.write(rpg_source_tmpl.render(
Expand Down
8 changes: 7 additions & 1 deletion generator/templates/rpg_source.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
{% include "copyright.tmpl" %}
// Headers
#include "rpg_{{ filename }}.h"

{% if struct_name in constants -%}
{%- for name, type, value, comment in constants[struct_name] %}
constexpr {{ type }} RPG::{{ struct_name }}::{{ name }};
{%- endfor %}
{%- endif %}
{% if struct_name is needs_ctor -%}
/**
* Constructor.
*/
RPG::{{ struct_name }}::{{ struct_name }}() {
Init();
}
{%- endif %}
17 changes: 17 additions & 0 deletions src/generated/rpg_savepartylocation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* !!!! GENERATED FILE - DO NOT EDIT !!!!
* --------------------------------------
*
* This file is part of liblcf. Copyright (c) 2018 liblcf authors.
* https://github.com/EasyRPG/liblcf - https://easyrpg.org
*
* liblcf is Free/Libre Open Source Software, released under the MIT License.
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code.
*/

// Headers
#include "rpg_savepartylocation.h"

constexpr int RPG::SavePartyLocation::kPanXDefault;
constexpr int RPG::SavePartyLocation::kPanYDefault;

16 changes: 16 additions & 0 deletions src/generated/rpg_state.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* !!!! GENERATED FILE - DO NOT EDIT !!!!
* --------------------------------------
*
* This file is part of liblcf. Copyright (c) 2018 liblcf authors.
* https://github.com/EasyRPG/liblcf - https://easyrpg.org
*
* liblcf is Free/Libre Open Source Software, released under the MIT License.
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code.
*/

// Headers
#include "rpg_state.h"

constexpr int RPG::State::kDeathID;

0 comments on commit 6cd8e2d

Please sign in to comment.