forked from enigma-dev/enigma-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnigmaPlugin.cpp
142 lines (107 loc) · 3.24 KB
/
EnigmaPlugin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "EnigmaPlugin.hpp"
#include "Main.hpp"
#include "OS_Switchboard.h"
#include "enigma.h"
EnigmaPlugin::EnigmaPlugin()
{
}
int EnigmaPlugin::Load() {
return PLUGIN_SUCCESS;
}
const char* EnigmaPlugin::Init(CallBack *ecb, const char* enigmaRoot) {
return libInit_path(ecb, enigmaRoot);
}
syntax_error* EnigmaPlugin::SetDefinitions(const char* def, const char* yaml) {
return definitionsModified(def, yaml);
}
syntax_error* EnigmaPlugin::SetDefinitions(const char* yaml) {
return definitionsModified("", yaml);
}
syntax_error* EnigmaPlugin::SyntaxCheck(int count, const char** names, const char* code) {
return syntaxCheck(count, names, code);
}
void EnigmaPlugin::HandleGameLaunch() {
ide_handles_game_launch();
}
void EnigmaPlugin::LogMakeToConsole() {
log_make_to_console();
}
int EnigmaPlugin::BuildGame(deprecated::JavaStruct::EnigmaStruct* data,
GameMode mode, const char* fpath) {
return compileEGMf(data, fpath, mode);
}
int EnigmaPlugin::BuildGame(const buffers::Game& data, GameMode mode, const char* fpath)
{
buffers::Project proj;
proj.mutable_game()->CopyFrom(data);
return compileProto(&proj, fpath, mode);
}
const char* EnigmaPlugin::NextResource() {
return next_available_resource();
}
const char* EnigmaPlugin::FirstResource() {
return first_available_resource();
}
bool EnigmaPlugin::ResourceIsFunction() {
return resource_isFunction();
}
int EnigmaPlugin::ResourceArgCountMin() {
return resource_argCountMin();
}
int EnigmaPlugin::ResourceArgCountMax() {
return resource_argCountMax();
}
int EnigmaPlugin::ResourceOverloadCount() {
return resource_overloadCount();
}
const char* EnigmaPlugin::ResourceParameters(int i) {
return resource_parameters(i);
}
int EnigmaPlugin::ResourceIsTypeName() {
return resource_isTypeName();
}
int EnigmaPlugin::ResourceIsGlobal() {
return resource_isGlobal();
}
bool EnigmaPlugin::ResourcesAtEnd() {
return resources_atEnd();
}
void EnigmaPlugin::PrintBuiltins(std::string& fName) {
std::vector<std::string> types;
std::vector<std::string> globals;
std::map<std::string, std::string> functions;
const char* currentResource = FirstResource();
while (!ResourcesAtEnd()) {
if (ResourceIsFunction()) {
//for (int i = 0; i < plugin_ResourceOverloadCount(); i++) // FIXME: JDI can't print overloads
functions[currentResource] = ResourceParameters(0);
}
if (ResourceIsGlobal())
globals.push_back(currentResource);
if (ResourceIsTypeName())
types.push_back(currentResource);
currentResource = NextResource();
}
std::sort(types.begin(), types.end());
std::ostream out(std::cout.rdbuf());
std::filebuf fb;
if (!fName.empty()) {
std::cout << "Writing builtins..." << std::endl;
fb.open(fName.c_str(), std::ios::out);
out.rdbuf(&fb);
}
out << "[Types]" << std::endl;
for (const std::string& t : types)
out << t << std::endl;
std::sort(globals.begin(), globals.end());
out << "[Globals]" << std::endl;
for (const std::string& g : globals)
out << g << std::endl;
out << "[Functions]" << std::endl;
for (const auto& f : functions)
out << f.second << std::endl;
if (!fName.empty()) {
fb.close();
std::cout << "Done writing builtins" << std::endl;
}
}