Separate objects context and interface
This commit is contained in:
parent
e937d189df
commit
55daf0f303
32 changed files with 362 additions and 384 deletions
|
|
@ -2,11 +2,7 @@
|
|||
#include "ObjectTests.hpp"
|
||||
|
||||
#include "compiler/Functions.hpp"
|
||||
#include "parser/Parser.hpp"
|
||||
#include "core/Object.hpp"
|
||||
#include "interpreter/Interpreter.hpp"
|
||||
#include "primitives/InterpreterObject.hpp"
|
||||
#include "primitives/LinkObject.hpp"
|
||||
#include "primitives/MethodObject.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
|
@ -23,9 +19,9 @@ SUITE(Compiler) {
|
|||
method->mScript->mReadable->val = "print 1 * 20 + 10;";
|
||||
method->compile();
|
||||
|
||||
NDO->destroy(method);
|
||||
objects_api::destroy(method);
|
||||
|
||||
assertNoLeaks();
|
||||
objects_api::assertNoLeaks();
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -35,9 +31,9 @@ SUITE(Compiler) {
|
|||
method->mScript->mReadable->val = "print undefinedVariable;";
|
||||
method->compile();
|
||||
|
||||
NDO->destroy(method);
|
||||
objects_api::destroy(method);
|
||||
|
||||
assertNoLeaks();
|
||||
objects_api::assertNoLeaks();
|
||||
}
|
||||
|
||||
objTestModule.deinitialize();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
|
||||
#include "ObjectTests.hpp"
|
||||
|
||||
#include "core/Object.hpp"
|
||||
|
||||
#include "primitives/IntObject.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
|
@ -17,19 +15,19 @@ SUITE(Core) {
|
|||
|
||||
integer->val = 10;
|
||||
|
||||
printf("%s\n", NDO->toString(integer).c_str());
|
||||
printf("%s\n", objects_api::toString(integer).c_str());
|
||||
|
||||
NDO->save(integer, "tmp.o");
|
||||
auto savedInt = NDO->load("tmp.o");
|
||||
objects_api::save(integer, "tmp.o");
|
||||
auto savedInt = objects_api::load("tmp.o");
|
||||
|
||||
printf("%s\n", NDO->toString(savedInt).c_str());
|
||||
printf("%s\n", objects_api::toString(savedInt).c_str());
|
||||
|
||||
CHECK(NDO->compare(integer, savedInt));
|
||||
CHECK(objects_api::compare(integer, savedInt));
|
||||
CHECK(objects_api::cast<IntObject>(savedInt));
|
||||
CHECK(integer->val == objects_api::cast<IntObject>(savedInt)->val);
|
||||
|
||||
NDO->destroy(integer);
|
||||
NDO->destroy(savedInt);
|
||||
objects_api::destroy(integer);
|
||||
objects_api::destroy(savedInt);
|
||||
}
|
||||
|
||||
objTestModule.deinitialize();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include "ObjectTests.hpp"
|
||||
|
||||
#include "compiler/Functions.hpp"
|
||||
#include "core/Object.hpp"
|
||||
#include "interpreter/Interpreter.hpp"
|
||||
#include "primitives/InterpreterObject.hpp"
|
||||
#include "primitives/LinkObject.hpp"
|
||||
|
|
@ -59,7 +58,7 @@ SUITE(Interpreter) {
|
|||
|
||||
interpreter->exec();
|
||||
|
||||
NDO->destroy(interpreter);
|
||||
objects_api::destroy(interpreter);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
|
@ -81,14 +80,14 @@ SUITE(Interpreter) {
|
|||
|
||||
interpreter->exec();
|
||||
|
||||
NDO->save(interpreter, "interp.o");
|
||||
objects_api::save(interpreter, "interp.o");
|
||||
|
||||
auto interpreterLoaded = objects_api::cast<InterpreterObject>(NDO->load("interp.o"));
|
||||
auto interpreterLoaded = objects_api::cast<InterpreterObject>(objects_api::load("interp.o"));
|
||||
|
||||
interpreterLoaded->exec();
|
||||
|
||||
NDO->destroy(interpreterLoaded);
|
||||
NDO->destroy(interpreter);
|
||||
objects_api::destroy(interpreterLoaded);
|
||||
objects_api::destroy(interpreter);
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
|
@ -100,7 +99,7 @@ SUITE(Interpreter) {
|
|||
objTestModule.initialize();
|
||||
|
||||
{
|
||||
auto compileStartCount = getObjCount();
|
||||
auto compileStartCount = objects_api::getObjCount();
|
||||
|
||||
auto method = objects_api::create<MethodObject>();
|
||||
auto interpreter = objects_api::create<InterpreterObject>();
|
||||
|
|
@ -111,10 +110,10 @@ SUITE(Interpreter) {
|
|||
method->mScript->mReadable->val = script;
|
||||
method->compile();
|
||||
|
||||
auto startCount = getObjCount();
|
||||
auto startCount = objects_api::getObjCount();
|
||||
interpreter->exec();
|
||||
|
||||
if (getObjCount() != startCount) {
|
||||
if (objects_api::getObjCount() != startCount) {
|
||||
CHECK(false && "Mem leaks in interpreter");
|
||||
}
|
||||
|
||||
|
|
@ -129,9 +128,9 @@ SUITE(Interpreter) {
|
|||
exec("var k : int;");
|
||||
exec("var k : int; print k;");
|
||||
|
||||
NDO->destroy(interpreter);
|
||||
objects_api::destroy(interpreter);
|
||||
|
||||
if (getObjCount() != compileStartCount) {
|
||||
if (objects_api::getObjCount() != compileStartCount) {
|
||||
CHECK(false && "Mem leaks in compiler and interpreter");
|
||||
}
|
||||
}
|
||||
|
|
@ -153,7 +152,7 @@ SUITE(Interpreter) {
|
|||
|
||||
interpreter->exec();
|
||||
|
||||
NDO->destroy(interpreter);
|
||||
objects_api::destroy(interpreter);
|
||||
}
|
||||
|
||||
objTestModule.deinitialize();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include "ObjectTests.hpp"
|
||||
|
||||
#include "parser/Parser.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
|
|
|||
|
|
@ -2,10 +2,7 @@
|
|||
#include "ObjectTests.hpp"
|
||||
|
||||
#include "compiler/Functions.hpp"
|
||||
#include "core/Object.hpp"
|
||||
#include "interpreter/Interpreter.hpp"
|
||||
#include "primitives/InterpreterObject.hpp"
|
||||
#include "primitives/LinkObject.hpp"
|
||||
#include "primitives/MethodObject.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
|
@ -23,15 +20,15 @@ SUITE(PrimitiveObjects) {
|
|||
|
||||
dict->put("val", integer);
|
||||
|
||||
NDO->save(dict, "dict.o");
|
||||
objects_api::save(dict, "dict.o");
|
||||
|
||||
auto dictLoaded = objects_api::cast<DictObject>(NDO->load("dict.o"));
|
||||
auto dictLoaded = objects_api::cast<DictObject>(objects_api::load("dict.o"));
|
||||
|
||||
REQUIRE CHECK(dictLoaded->presents("val").isValid());
|
||||
CHECK(objects_api::cast<IntObject>(dictLoaded->get("val"))->val == 10);
|
||||
|
||||
NDO->destroy(dict);
|
||||
NDO->destroy(dictLoaded);
|
||||
objects_api::destroy(dict);
|
||||
objects_api::destroy(dictLoaded);
|
||||
}
|
||||
|
||||
objTestModule.deinitialize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue