Skip to content

Commit 7e204a2

Browse files
committed
refactor: Adjust generated code to the style changes in cpp-sc2
Signed-off-by: Alexander Kurbatov <sir.alkurbatov@yandex.ru>
1 parent 475e5cd commit 7e204a2

File tree

2 files changed

+50756
-25419
lines changed

2 files changed

+50756
-25419
lines changed

src/cpp.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ function dumpSwitch(src, enumName, dst) {
1515
fs.appendFileSync(dst, ` switch ((${enumName})id) {\n`)
1616

1717
src.forEach(({ name }) => {
18-
fs.appendFileSync(dst, ` case ${enumName}::${name}: return "${name}";\n`)
18+
fs.appendFileSync(dst, ` case ${enumName}::${name}:\n return "${name}";\n`)
1919
})
2020

21-
fs.appendFileSync(dst, ' default: return "UNKNOWN";\n }\n')
21+
fs.appendFileSync(dst, ' default:\n return "UNKNOWN";\n }\n')
2222
}
2323

2424
function dumpHeader({ units, abilities, upgrades, buffs, effects }) {
@@ -36,7 +36,7 @@ utility located at https://github.com/cpp-sc2/codegen
3636
3737
#pragma once
3838
39-
#include "sc2api/sc2_types.h"
39+
#include "sc2_types.h"
4040
4141
namespace sc2 {
4242
enum class UNIT_TYPEID;
@@ -45,11 +45,11 @@ enum class UPGRADE_ID;
4545
enum class BUFF_ID;
4646
enum class EFFECT_ID;
4747
48-
typedef SC2Type<UNIT_TYPEID> UnitTypeID;
49-
typedef SC2Type<ABILITY_ID> AbilityID;
50-
typedef SC2Type<UPGRADE_ID> UpgradeID;
51-
typedef SC2Type<BUFF_ID> BuffID;
52-
typedef SC2Type<EFFECT_ID> EffectID;
48+
using UnitTypeID = SC2Type<UNIT_TYPEID>;
49+
using AbilityID = SC2Type<ABILITY_ID>;
50+
using UpgradeID = SC2Type<UPGRADE_ID>;
51+
using BuffID = SC2Type<BUFF_ID>;
52+
using EffectID = SC2Type<EFFECT_ID>;
5353
5454
`
5555
)
@@ -62,8 +62,7 @@ typedef SC2Type<EFFECT_ID> EffectID;
6262

6363
fs.appendFileSync(
6464
dst,
65-
`
66-
//! Converts a UNIT_TYPEID into a string of the same name.
65+
`//! Converts a UNIT_TYPEID into a string of the same name.
6766
const char* UnitTypeToName(UnitTypeID id);
6867
6968
//! Converts a ABILITY_ID into a string of the same name.
@@ -94,7 +93,7 @@ Helper converter functions provided for your convenience.
9493
Entries in it are generated by a custom utility located at https://github.com/cpp-sc2/codegen
9594
*/
9695
97-
#include "sc2api/sc2_typeenums.h"
96+
#include "sc2_typeenums.h"
9897
9998
namespace sc2 {
10099
`

0 commit comments

Comments
 (0)