Express actions[] in newdb.[ch].
This commit is contained in:
parent
6d123b3fb1
commit
4d21247643
1 changed files with 41 additions and 1 deletions
|
@ -92,6 +92,11 @@ typedef struct {{
|
||||||
const char** words;
|
const char** words;
|
||||||
}} motion_t;
|
}} motion_t;
|
||||||
|
|
||||||
|
typedef struct {{
|
||||||
|
const char** words;
|
||||||
|
const long message;
|
||||||
|
}} action_t;
|
||||||
|
|
||||||
extern const location_t locations[];
|
extern const location_t locations[];
|
||||||
extern const object_t objects[];
|
extern const object_t objects[];
|
||||||
extern const char* arbitrary_messages[];
|
extern const char* arbitrary_messages[];
|
||||||
|
@ -109,7 +114,7 @@ extern const motion_t motions[];
|
||||||
#define NCLASSES {}
|
#define NCLASSES {}
|
||||||
#define NDEATHS {}
|
#define NDEATHS {}
|
||||||
#define NTHRESHOLDS {}
|
#define NTHRESHOLDS {}
|
||||||
#define NVERBS {}
|
#define NACTIONS {}
|
||||||
#define NTRAVEL {}
|
#define NTRAVEL {}
|
||||||
|
|
||||||
enum arbitrary_messages_refs {{
|
enum arbitrary_messages_refs {{
|
||||||
|
@ -128,6 +133,10 @@ enum motion_refs {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
enum action_refs {{
|
||||||
|
{}
|
||||||
|
}};
|
||||||
|
|
||||||
/* State definitions */
|
/* State definitions */
|
||||||
|
|
||||||
{}
|
{}
|
||||||
|
@ -180,6 +189,10 @@ const motion_t motions[] = {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
const action_t actions[] = {{
|
||||||
|
{}
|
||||||
|
}};
|
||||||
|
|
||||||
/* end */
|
/* end */
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -484,6 +497,31 @@ def get_motions(motions):
|
||||||
mot_str += template.format(words_str)
|
mot_str += template.format(words_str)
|
||||||
return mot_str
|
return mot_str
|
||||||
|
|
||||||
|
def get_actions(actions):
|
||||||
|
template = """ {{
|
||||||
|
.words = {},
|
||||||
|
.message = {},
|
||||||
|
}},
|
||||||
|
"""
|
||||||
|
act_str = ""
|
||||||
|
for action in actions:
|
||||||
|
contents = action[1]
|
||||||
|
|
||||||
|
if contents["words"] == None:
|
||||||
|
words_str = "NULL"
|
||||||
|
else:
|
||||||
|
c_words = [make_c_string(s) for s in contents["words"]]
|
||||||
|
words_str = "(const char* []) {" + ", ".join(c_words) + "}"
|
||||||
|
|
||||||
|
if contents["message"] == None:
|
||||||
|
message = "NO_MESSAGE"
|
||||||
|
else:
|
||||||
|
message = contents["message"]
|
||||||
|
|
||||||
|
act_str += template.format(words_str, message)
|
||||||
|
act_str = act_str[:-1] # trim trailing newline
|
||||||
|
return act_str
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
with open(yaml_name, "r") as f:
|
with open(yaml_name, "r") as f:
|
||||||
db = yaml.load(f)
|
db = yaml.load(f)
|
||||||
|
@ -506,6 +544,7 @@ if __name__ == "__main__":
|
||||||
get_condbits(db["locations"]),
|
get_condbits(db["locations"]),
|
||||||
get_actspk(db["actspk"]),
|
get_actspk(db["actspk"]),
|
||||||
get_motions(db["motions"]),
|
get_motions(db["motions"]),
|
||||||
|
get_actions(db["actions"]),
|
||||||
)
|
)
|
||||||
|
|
||||||
h = h_template.format(
|
h = h_template.format(
|
||||||
|
@ -521,6 +560,7 @@ if __name__ == "__main__":
|
||||||
get_refs(db["locations"]),
|
get_refs(db["locations"]),
|
||||||
get_refs(db["objects"]),
|
get_refs(db["objects"]),
|
||||||
get_refs(db["motions"]),
|
get_refs(db["motions"]),
|
||||||
|
get_refs(db["actions"]),
|
||||||
statedefines,
|
statedefines,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue