-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Plug the new event reader into the compiler. This kills the crab.
To-do: - Test harness needs to be hooked in instead of being run ad-hoc with a gross makefile. - There's an infinite loop somewhere; testing isn't finding it. - Super check assumptions are wrong; super checks *can* use parameters. Compiler needs to be refactored further around how it treats super checks. - Case insensitivity in param lookup maps. Currently retrieval of "key" will fail because it's called "Key" in the parameter value map. - Need a method like ParamSubst that swaps in parameter names instead of argument spellings. - Tons of migration work to get the whole compiler on the new system. Until then, resource names can't be used in filenames.
- Loading branch information
1 parent
7c03d46
commit 2444968
Showing
21 changed files
with
827 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
CXXFLAGS := -std=c++17 | ||
DEPS := ../../shared/event_reader/event_parser.cpp ../../shared/ProtoYaml/proto-yaml.cpp | ||
INCLUDES := -I../../shared/ -I../../shared/protos/.eobjs/ | ||
LDFLAGS := -Wl,-rpath,../.. -L../.. | ||
LDLIBS := -lEGM -lProtocols -lgtest -lgtest_main -lprotobuf -lyaml-cpp -lpthread | ||
|
||
event-reader-tests: event-reader-tests.cpp $(DEPS) | ||
g++ $(CXXFLAGS) $^ $(INCLUDES) $(LDFLAGS) $(LDLIBS) -o $@ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#include "event_reader/event_parser.h" | ||
#include <gtest/gtest.h> | ||
|
||
#include <sstream> | ||
|
||
constexpr char kTestEvents[] = R"( | ||
Events: | ||
Alarm: | ||
Name: "Alarm %1" | ||
Type: Parameterized | ||
Parameters: | ||
- integer | ||
Group: Alarm | ||
SubCheck: | | ||
{ | ||
alarm[%1] = (int) alarm[%1]; | ||
return alarm[%1] < 0 ? false : !((int)--alarm[%1]); | ||
} | ||
Collision: | ||
Name: "Colision %1" | ||
Description: "Instance is colliding (overlapping) with another object." | ||
Group: "Collisions" | ||
Type: Parameterized | ||
Parameters: | ||
- Object | ||
SuperCheck: | | ||
instance_number(%1) | ||
SubCheck: | | ||
enigma::place_meeting_inst(x,y,%1) | ||
Prefix: "{" | ||
Suffix: "}" | ||
Keyboard: | ||
Name: "Keyboard %1" | ||
Description: "A key was pressed or is being held." | ||
Group: "Input" | ||
Type: Parameterized | ||
Parameters: | ||
- Key | ||
SuperCheck: | | ||
keyboard_check(%1) | ||
Joystick.Button: | ||
Name: "Joystick %1 Button %2" | ||
Description: "A joystick button is pressed or held" | ||
Group: "Input" | ||
Type: Parameterized | ||
Parameters: | ||
- Integer | ||
- JoystickButton | ||
Aliases: | ||
Key: | ||
Left: {value: 37, spelling: "vk_left"} | ||
Right: {value: 39, spelling: "vk_right"} | ||
Up: {value: 38, spelling: "vk_up"} | ||
Down: {value: 40, spelling: "vk_down"} | ||
A: {value: 65, spelling: "'A'"} | ||
B: {value: 66, spelling: "'B'"} | ||
JoystickButton: | ||
Left: {value: 0, spelling: "js_left"} | ||
Right: {value: 1, spelling: "js_right"} | ||
Up: {value: 2, spelling: "js_up"} | ||
Down: {value: 3, spelling: "js_down"} | ||
GameMakerEventMappings: | ||
0: # Instance construct event. | ||
Single: Create | ||
2: # Alarms. GM only supports ten. | ||
Parameterized: Alarm[%1] # Number <1-10> | ||
4: # Collision events. | ||
Parameterized: Collision[%1] # <Object> | ||
5: # Keyboard events. | ||
Parameterized: Keyboard[%1] # <Key> | ||
6: # The "Mouse" group, which somehow inherited joysticks. | ||
Specialized: | ||
Cases: | ||
21: Joystick[1]Button[1] | ||
22: Joystick[1]Button[2] | ||
23: Joystick[1]Button[3] | ||
24: Joystick[1]Button[4] | ||
25: Joystick[1]Button[5] | ||
26: Joystick[1]Button[6] | ||
27: Joystick[1]Button[7] | ||
28: Joystick[1]Button[8] | ||
36: Joystick[2]Button[1] | ||
37: Joystick[2]Button[2] | ||
38: Joystick[2]Button[3] | ||
39: Joystick[2]Button[4] | ||
40: Joystick[2]Button[5] | ||
41: Joystick[2]Button[6] | ||
42: Joystick[2]Button[7] | ||
43: Joystick[2]Button[8] | ||
)"; | ||
|
||
TEST(EventReaderTest, ReadsEventFile) { | ||
std::istringstream str(kTestEvents); | ||
EventData events(ParseEventFile(str)); | ||
Event ev = events.DecodeEventString("Keyboard[Up]"); | ||
EXPECT_EQ(ev.HumanName(), "Keyboard vk_up"); | ||
EXPECT_EQ(ev.IdString(), "Keyboard[Up]"); | ||
EXPECT_EQ(events.reverse_get_event(ev).mid, 5); | ||
EXPECT_EQ(events.reverse_get_event(ev).id, 38); | ||
EXPECT_FALSE(ev.HasSubCheck()); | ||
EXPECT_FALSE(ev.HasSubCheckExpression()); | ||
EXPECT_FALSE(ev.HasSubCheckFunction()); | ||
// EXPECT_TRUE(ev.HasSuperCheck()); | ||
// EXPECT_TRUE(ev.HasSuperCheckExpression()); | ||
// EXPECT_EQ(ev.event->super_check(), "keyboard_check(%1)"); | ||
// EXPECT_EQ(ev.SuperCheckExpression(), "keyboard_check(vk_up)"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.