summaryrefslogtreecommitdiff
path: root/tests/cgaltest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/cgaltest.cc')
-rw-r--r--tests/cgaltest.cc52
1 files changed, 11 insertions, 41 deletions
diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc
index 2c83cc8..0b433bf 100644
--- a/tests/cgaltest.cc
+++ b/tests/cgaltest.cc
@@ -1,6 +1,7 @@
/*
- * OpenSCAD (www.openscad.at)
- * Copyright (C) 2009 Clifford Wolf <clifford@clifford.at>
+ * OpenSCAD (www.openscad.org)
+ * Copyright (C) 2009-2011 Clifford Wolf <clifford@clifford.at> and
+ * Marius Kintel <marius@kintel.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,8 +25,8 @@
*/
#include "myqhash.h"
+#include "tests-common.h"
#include "openscad.h"
-#include "handle_dep.h"
#include "node.h"
#include "module.h"
#include "context.h"
@@ -83,8 +84,7 @@ int main(int argc, char **argv)
const char *filename = argv[1];
- initialize_builtin_functions();
- initialize_builtin_modules();
+ Builtins::instance()->initialize();
QApplication app(argc, argv, false);
QDir original_path = QDir::current();
@@ -111,47 +111,17 @@ int main(int argc, char **argv)
}
Context root_ctx;
- root_ctx.functions_p = &builtin_functions;
- root_ctx.modules_p = &builtin_modules;
- root_ctx.set_variable("$fn", Value(0.0));
- root_ctx.set_variable("$fs", Value(1.0));
- root_ctx.set_variable("$fa", Value(12.0));
- root_ctx.set_variable("$t", Value(0.0));
-
- Value zero3;
- zero3.type = Value::VECTOR;
- zero3.append(new Value(0.0));
- zero3.append(new Value(0.0));
- zero3.append(new Value(0.0));
- root_ctx.set_variable("$vpt", zero3);
- root_ctx.set_variable("$vpr", zero3);
-
+ register_builtin(root_ctx);
AbstractModule *root_module;
ModuleInstantiation root_inst;
- QFileInfo fileInfo(filename);
- handle_dep(filename);
- FILE *fp = fopen(filename, "rt");
- if (!fp) {
- fprintf(stderr, "Can't open input file `%s'!\n", filename);
+ root_module = parsefile(filename);
+ if (!root_module) {
exit(1);
- } else {
- std::stringstream text;
- char buffer[513];
- int ret;
- while ((ret = fread(buffer, 1, 512, fp)) > 0) {
- buffer[ret] = 0;
- text << buffer;
- }
- fclose(fp);
- text << commandline_commands;
- root_module = parse(text.str().c_str(), fileInfo.absolutePath().toLocal8Bit(), false);
- if (!root_module) {
- exit(1);
- }
}
+ QFileInfo fileInfo(filename);
QDir::setCurrent(fileInfo.absolutePath());
AbstractNode::resetIndexCounter();
@@ -171,8 +141,8 @@ int main(int argc, char **argv)
if (!N.empty()) {
export_stl(&N, std::cout, NULL);
}
- destroy_builtin_functions();
- destroy_builtin_modules();
+
+ Builtins::instance(true);
return 0;
}
contact: Jan Huwald // Impressum