115 lines
2.3 KiB
C++
115 lines
2.3 KiB
C++
#include "pip.h"
|
|
/*#ifdef PIP_LUA
|
|
#include "piluaprogram.h"
|
|
|
|
static const char * script
|
|
= "-- script.lua \n"
|
|
"test()\n"
|
|
"testString = \"LuaBridge works ававава!\" \n"
|
|
"number = 42 \n";
|
|
|
|
|
|
void test() {
|
|
piCout << "C function test";
|
|
}
|
|
|
|
int main() {
|
|
PILuaProgram p;
|
|
p.getGlobalNamespace().addFunction("test", test);
|
|
if (!p.load(PIString::fromUTF8(script))) piCout << "error";
|
|
p.prepare();
|
|
luabridge::LuaRef s = p.getGlobal("testString");
|
|
luabridge::LuaRef n = p.getGlobal("number");
|
|
PIString luaString = s.cast<PIString>();
|
|
int answer = n.cast<int>();
|
|
piCout << luaString;
|
|
piCout << "And here's our number:" << answer;
|
|
}
|
|
#else
|
|
int main() {
|
|
return 0;
|
|
}
|
|
#endif
|
|
*/
|
|
class db {
|
|
public:
|
|
db() {
|
|
name = PIStringAscii("sflner;ljner.vjnrevsg;j35m4;gberjg2mnv");
|
|
for (int i=0; i<10000; ++i)
|
|
x << sin(double(i)/180.0);
|
|
//printf("jkfkhg\n");
|
|
}
|
|
PIString name;
|
|
PIVector<double> x;
|
|
};
|
|
|
|
inline PIByteArray & operator <<(PIByteArray & ba, const db & v) {
|
|
PIChunkStream cs;
|
|
cs.add(1, v.name).add(2, v.x);
|
|
ba << cs.data();
|
|
return ba;
|
|
}
|
|
inline PIByteArray & operator >>(PIByteArray & ba, db & v) {
|
|
PIByteArray src; ba >> src; PIChunkStream cs(src);
|
|
while (!cs.atEnd()) {
|
|
switch (cs.read()) {
|
|
case 1: cs.get(v.name); break;
|
|
case 2: cs.get(v.x); break;
|
|
}
|
|
}
|
|
return ba;
|
|
}
|
|
|
|
PIEthernet eth;
|
|
|
|
#include "picodeparser.h"
|
|
int main() {
|
|
//PICodeParser cp;
|
|
//cp.parseFile("SH_plugin_base.h");
|
|
|
|
PIMap<int, PIString> m;
|
|
m[1] = "one";
|
|
m[2] = "two";
|
|
|
|
auto it = m.riterate();
|
|
while (it.next()) {
|
|
//it.next();
|
|
it.valueRef() << "_!";
|
|
piCout << it.key() << it.value();
|
|
}
|
|
|
|
/*eth.__meta_data
|
|
piForeachC (auto & i, cp.enums) {
|
|
i.
|
|
}*/
|
|
|
|
/*piDebug = false;
|
|
double min = -1, max = -1, mean = 0;
|
|
const int iterations = 50;
|
|
db d, d2;
|
|
for (int i = 0; i < iterations; ++i) {
|
|
//PICodeParser cp;
|
|
PITimeMeasurer tm;
|
|
for (int j = 0; j < 100; ++j) {
|
|
PIByteArray ba;
|
|
ba << d;
|
|
}
|
|
//cp.parseFile("SH_plugin_base.h");
|
|
double ms = tm.elapsed_m();
|
|
if (min < 0) min = ms;
|
|
if (max < 0) max = ms;
|
|
min = piMin(min, ms);
|
|
max = piMax(max, ms);
|
|
mean += ms;
|
|
|
|
PIByteArray ba;
|
|
ba << d;
|
|
d2.name.clear();
|
|
d2.x.clear();
|
|
ba >> d2;
|
|
}
|
|
piDebug = true;
|
|
piCout << d2.name << d2.x.size_s();
|
|
piCout << min << (mean / iterations) << max;*/
|
|
}
|