Skip to content

Commit 1eabb13

Browse files
committed
Remove Vector, because it's no longer needed
1 parent a1ef9c1 commit 1eabb13

5 files changed

Lines changed: 6 additions & 70 deletions

File tree

script.lua

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,14 @@ ec.callbackRespondsToKey = function(key)
1919
return key == "lua"
2020
end
2121

22-
useStrings = true
23-
24-
-- Use strings.
25-
if (useStrings) then
26-
ec.callbackCall = function(key, values)
27-
printValues("Inside normal callback", values)
28-
return values
29-
--return {"Z", "A"}
30-
end
31-
-- Use vector.
32-
else
33-
ec.callbackCallVector = function(key, vector)
34-
printValues("Inside vector callback", vector.values)
35-
v = Vector.new()
36-
v:setValues({"Z", "A"})
37-
return v
38-
end
22+
ec.callbackCall = function(key, values)
23+
printValues("Inside callback", values)
24+
return {"Z", "A"}
3925
end
4026

4127
-- Add ec as Environment client.
4228
env:addClient(ec)
4329

4430
-- Call newly registered module.
4531
values = env:call("lua", {"X", "Y"})
46-
printValues("Values after calling 'lua'", values)
32+
printValues("Calling 'lua'", values)

src/Common.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <vector>
77

88
typedef std::string String;
9-
109
typedef std::vector<String> Strings;
1110

1211
String stringsToString(const Strings &strings)

src/EnvironmentClient.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#define CPP_CALLBACK_SCRIPT_ENVIRONMENT_CLIENT_H
44

55
#include "Common.h"
6-
#include "Vector.h"
76

87
#include <cstdio>
98
#include <functional>
@@ -19,14 +18,9 @@ class EnvironmentClient
1918
typedef std::function<Strings (const String &, const Strings &)> CallbackCall;
2019
CallbackCall callbackCall;
2120

22-
// Callback for 'call' method using Vector.
23-
typedef std::function<Vector (const String &, const Vector &)> CallbackCallVector;
24-
CallbackCallVector callbackCallVector;
25-
2621
EnvironmentClient() :
2722
callbackRespondsToKey(nullptr),
28-
callbackCall(nullptr),
29-
callbackCallVector(nullptr) { }
23+
callbackCall(nullptr) { }
3024
~EnvironmentClient() { }
3125

3226
bool respondsToKey(const String &key)
@@ -40,19 +34,10 @@ class EnvironmentClient
4034
}
4135
Strings call(const String &key, const Strings &values)
4236
{
43-
// Strings version.
4437
if (this->callbackCall)
4538
{
4639
return this->callbackCall(key, values);
4740
}
48-
// Vector version.
49-
else if (this->callbackCallVector)
50-
{
51-
Vector in;
52-
in.values = values;
53-
Vector out = this->callbackCallVector(key, in);
54-
return out.values;
55-
}
5641
printf(
5742
"EnvironmentClient.call(%s, %s). provide callback!\n",
5843
key.c_str(),

src/Vector.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/main.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void runSol(const char *fileName)
7676
}
7777
);
7878

79-
#define REGISTER_PLAIN_CALLBACK
79+
//#define REGISTER_PLAIN_CALLBACK
8080

8181
// Register environment client class.
8282
lua.new_usertype<EnvironmentClient>(
@@ -96,21 +96,9 @@ void runSol(const char *fileName)
9696
};
9797
}),
9898
#endif // REGISTER_PLAIN_CALLBACK
99-
"callbackCallVector", &EnvironmentClient::callbackCallVector,
10099
"callbackRespondsToKey", &EnvironmentClient::callbackRespondsToKey
101100
);
102101

103-
// Register vector class.
104-
lua.new_usertype<Vector>(
105-
"Vector",
106-
"values", &Vector::values,
107-
"setValues",
108-
[](Vector &vector, sol::nested<Strings> values)
109-
{
110-
return vector.setValues(values);
111-
}
112-
);
113-
114102
// Load and execute script.
115103
lua.script_file(fileName);
116104
}

0 commit comments

Comments
 (0)