Adding support for windows and fixing some errors
This commit is contained in:
parent
7660d58f26
commit
420bb37039
84 changed files with 168 additions and 255 deletions
|
|
@ -2,5 +2,7 @@
|
|||
|
||||
#include "Common.hpp"
|
||||
|
||||
#ifndef ENV_OS_WINDOWS
|
||||
inline void* operator new(std::size_t aSize, void* aWhere) noexcept { return aWhere; }
|
||||
inline void* operator new[](std::size_t aSize, void* aWhere) noexcept { return aWhere; }
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ private:
|
|||
}
|
||||
};
|
||||
|
||||
const ualni size = 1000;
|
||||
const ualni size = 500;
|
||||
|
||||
template <typename Alloc>
|
||||
void testAlloc() {
|
||||
|
|
@ -214,7 +214,7 @@ void testAlloc() {
|
|||
|
||||
TEST_DEF_STATIC(GlobalHeap) { testAlloc<HeapAllocGlobal>(); }
|
||||
|
||||
TEST_DEF_STATIC(Heap) { testAlloc<HeapAlloc>(); }
|
||||
TEST_DEF_STATIC(Heap) { testAlloc<tp::HeapAlloc>(); }
|
||||
|
||||
TEST_DEF_STATIC(Chunk) {
|
||||
testAlloc<ChunkAlloc<TestStruct, size>>();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "CmdLineInterpreter.hpp"
|
||||
|
||||
#define MAX_LINE_LENGTH 1024
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "CommandLine.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "Map.hpp"
|
||||
#include "Tokenizer.hpp"
|
||||
|
||||
|
||||
namespace tp {
|
||||
|
||||
extern ModuleManifest gModuleCommandLine;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Tests.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "CmdLineInterpreter.hpp"
|
||||
#include "Tests.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Tests.hpp"
|
||||
|
||||
int main() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "LocalConnection.hpp"
|
||||
|
||||
#include "bindings/Disk.hpp"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "LocalConnection.hpp"
|
||||
#include "Testing.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Buffer2D.hpp"
|
||||
#include "Testing.hpp"
|
||||
#include "Tests.hpp"
|
||||
|
||||
#include "HeapAllocator.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
const ualni size = 1000;
|
||||
|
||||
TEST_DEF_STATIC(Simple1) {
|
||||
Buffer2D<int, HeapAlloc> buff;
|
||||
Buffer2D<int, tp::HeapAlloc> buff;
|
||||
buff.reserve({ 4, 4 });
|
||||
buff.set({ 2, 2 }, 5);
|
||||
TEST(buff.get({ 2, 2 }) == 5);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Buffer.hpp"
|
||||
#include "Testing.hpp"
|
||||
#include "Tests.hpp"
|
||||
|
|
@ -9,7 +7,7 @@ using namespace tp;
|
|||
const ualni size = 1000;
|
||||
|
||||
TEST_DEF_STATIC(Simple1) {
|
||||
Buffer<TestClass, HeapAlloc> buff;
|
||||
Buffer<TestClass, tp::HeapAlloc> buff;
|
||||
TEST(buff.size() == 0);
|
||||
for (auto i : Range(size * 10)) {
|
||||
buff.append(TestClass(i));
|
||||
|
|
@ -21,7 +19,7 @@ TEST_DEF_STATIC(Simple1) {
|
|||
}
|
||||
|
||||
TEST_DEF_STATIC(Simple2) {
|
||||
Buffer<TestClass, HeapAlloc> buff(size);
|
||||
Buffer<TestClass, tp::HeapAlloc> buff(size);
|
||||
TEST(buff.size() == size);
|
||||
for (auto i : Range(size * 10))
|
||||
buff.append(TestClass(i));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Archiver.hpp"
|
||||
#include "Testing.hpp"
|
||||
#include "Tests.hpp"
|
||||
|
|
@ -7,7 +5,7 @@
|
|||
using namespace tp;
|
||||
|
||||
TEST_DEF_STATIC(SimpleReference) {
|
||||
tp::List<TestClass, HeapAlloc> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
tp::List<TestClass, tp::HeapAlloc> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
|
||||
list.pushBack(TestClass(5));
|
||||
list.pushFront(TestClass(0));
|
||||
|
|
@ -24,7 +22,7 @@ TEST_DEF_STATIC(SimpleReference) {
|
|||
}
|
||||
|
||||
TEST_DEF_STATIC(SimplePointer) {
|
||||
tp::List<TestClass*, HeapAlloc> list = { new TestClass(1), new TestClass(2), new TestClass(3), new TestClass(4) };
|
||||
tp::List<TestClass*, tp::HeapAlloc> list = { new TestClass(1), new TestClass(2), new TestClass(3), new TestClass(4) };
|
||||
|
||||
list.pushBack(new TestClass(5));
|
||||
list.pushFront(new TestClass(0));
|
||||
|
|
@ -45,8 +43,8 @@ TEST_DEF_STATIC(SimplePointer) {
|
|||
}
|
||||
|
||||
TEST_DEF_STATIC(Copy) {
|
||||
tp::List<TestClass, HeapAlloc> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
tp::List<TestClass, HeapAlloc> list2 = list;
|
||||
tp::List<TestClass, tp::HeapAlloc> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
tp::List<TestClass, tp::HeapAlloc> list2 = list;
|
||||
|
||||
TEST_EQUAL(list, list2);
|
||||
|
||||
|
|
@ -55,7 +53,7 @@ TEST_DEF_STATIC(Copy) {
|
|||
}
|
||||
|
||||
TEST_DEF_STATIC(Serialization) {
|
||||
tp::List<TestClass, HeapAlloc> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
tp::List<TestClass, tp::HeapAlloc> list = { TestClass(1), TestClass(2), TestClass(3), TestClass(4) };
|
||||
|
||||
ArchiverExample<1024, false> write;
|
||||
ArchiverExample<1024, true> read;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Archiver.hpp"
|
||||
#include "Map.hpp"
|
||||
#include "Testing.hpp"
|
||||
|
|
@ -8,7 +6,7 @@
|
|||
using namespace tp;
|
||||
|
||||
TEST_DEF_STATIC(SimpleReference) {
|
||||
tp::Map<tp::ualni, TestClass, HeapAlloc> map;
|
||||
tp::Map<tp::ualni, TestClass, tp::HeapAlloc> map;
|
||||
|
||||
for (auto i : Range(1000, 100000)) {
|
||||
map.put(i, TestClass(i));
|
||||
|
|
@ -42,7 +40,7 @@ TEST_DEF_STATIC(SimpleReference) {
|
|||
}
|
||||
|
||||
TEST_DEF_STATIC(SimplePointer) {
|
||||
tp::Map<tp::ualni, TestClass*, HeapAlloc> map;
|
||||
tp::Map<tp::ualni, TestClass*, tp::HeapAlloc> map;
|
||||
|
||||
for (auto i : Range(1000)) {
|
||||
map.put(i, new TestClass(i));
|
||||
|
|
@ -80,13 +78,13 @@ TEST_DEF_STATIC(SimplePointer) {
|
|||
}
|
||||
|
||||
TEST_DEF_STATIC(Copy) {
|
||||
tp::Map<tp::ualni, TestClass, HeapAlloc> map;
|
||||
tp::Map<tp::ualni, TestClass, tp::HeapAlloc> map;
|
||||
|
||||
for (auto i : Range(10)) {
|
||||
map.put(i, TestClass(i));
|
||||
}
|
||||
|
||||
tp::Map<tp::ualni, TestClass, HeapAlloc> map2 = map;
|
||||
tp::Map<tp::ualni, TestClass, tp::HeapAlloc> map2 = map;
|
||||
|
||||
TEST_EQUAL(map, map2);
|
||||
|
||||
|
|
@ -95,7 +93,7 @@ TEST_DEF_STATIC(Copy) {
|
|||
}
|
||||
|
||||
TEST_DEF_STATIC(SaveLoad) {
|
||||
tp::Map<tp::ualni, TestClass, HeapAlloc> map;
|
||||
tp::Map<tp::ualni, TestClass, tp::HeapAlloc> map;
|
||||
|
||||
for (auto i : Range(10)) {
|
||||
map.put(i, TestClass(i));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Testing.hpp"
|
||||
#include "Tests.hpp"
|
||||
#include "Tree.hpp"
|
||||
|
|
@ -7,7 +5,7 @@
|
|||
using namespace tp;
|
||||
|
||||
TEST_DEF_STATIC(Simple) {
|
||||
AvlTree<AvlNumericKey<alni>, TestClass, HeapAlloc> tree;
|
||||
AvlTree<AvlNumericKey<alni>, TestClass, tp::HeapAlloc> tree;
|
||||
|
||||
TEST(tree.size() == 0);
|
||||
TEST(tree.head() == nullptr);
|
||||
|
|
@ -24,7 +22,7 @@ TEST_DEF_STATIC(Simple) {
|
|||
}
|
||||
|
||||
TEST_DEF_STATIC(Persistance) {
|
||||
AvlTree<AvlNumericKey<alni>, TestClass, HeapAlloc> tree;
|
||||
AvlTree<AvlNumericKey<alni>, TestClass, tp::HeapAlloc> tree;
|
||||
|
||||
const auto size = 1000;
|
||||
|
||||
|
|
|
|||
15
Externals/CMakeLists.txt
vendored
15
Externals/CMakeLists.txt
vendored
|
|
@ -1,3 +1,18 @@
|
|||
# find_package(ALSA REQUIRED)
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(CMAKE_PREFIX_PATH "../../ModulesWindowsLibraries/glew-2.1.0")
|
||||
find_package(GLEW REQUIRED)
|
||||
set(GLEW_LIB ${GLEW_STATIC_LIBRARY_RELEASE} opengl32.lib PARENT_SCOPE)
|
||||
|
||||
set(PORTAUDIO_INCLUDE_DIR "../../ModulesWindowsLibraries/portaudio/include" PARENT_SCOPE)
|
||||
set(PORTAUDIO_LIB "../../ModulesWindowsLibraries/portaudio_build/Debug/portaudio" PARENT_SCOPE)
|
||||
else()
|
||||
find_package(GLEW REQUIRED)
|
||||
set(GLEW_LIB ${GLEW_LIBRARIES} GL PARENT_SCOPE)
|
||||
|
||||
set(PORTAUDIO_LIB portaudio PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
#add_subdirectory(glew/build/cmake/)
|
||||
#target_compile_definitions(glew_s PUBLIC GLEW_NO_GLU)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
project(Graphics)
|
||||
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
### ---------------------- Externals --------------------- ###
|
||||
set(BINDINGS_INCLUDE ../Externals/glfw/include ../Externals/glew/include)
|
||||
set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIBRARIES} GL)
|
||||
|
||||
set(BINDINGS_INCLUDE ../Externals/glfw/include ${GLEW_INCLUDE_DIR})
|
||||
set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIB})
|
||||
|
||||
### ---------------------- Static Library --------------------- ###
|
||||
file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp")
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ namespace tp {
|
|||
TAB = 258,
|
||||
BACKSPACE = 259,
|
||||
INSERT = 260,
|
||||
DELETE = 261,
|
||||
DELETE_KEY = 261,
|
||||
RIGHT = 262,
|
||||
LEFT = 263,
|
||||
DOWN = 264,
|
||||
|
|
@ -156,7 +156,7 @@ namespace tp {
|
|||
};
|
||||
|
||||
struct KeyEvent {
|
||||
Keycode code;
|
||||
Keycode code;
|
||||
enum class EventState {
|
||||
RELEASED = 0,
|
||||
PRESSED = 1,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
project(LibraryViewer)
|
||||
|
||||
find_package(ALSA REQUIRED)
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
### ---------------------- Externals --------------------- ###
|
||||
set(BINDINGS_INCLUDE ../Externals/glfw/include ../Externals/glew/include)
|
||||
set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIBRARIES} GL portaudio)
|
||||
set(BINDINGS_INCLUDE ../Externals/glfw/include ${GLEW_INCLUDE_DIR} ${PORTAUDIO_INCLUDE_DIR})
|
||||
set(BINDINGS_LIBS glfw Imgui Nanovg ${GLEW_LIB} ${ALSA_LIBRARY} ${PORTAUDIO_LIB})
|
||||
|
||||
### ---------------------- Static Library --------------------- ###
|
||||
file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp")
|
||||
|
|
@ -22,4 +19,5 @@ file(COPY "applications/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAM
|
|||
|
||||
### -------------------------- Applications -------------------------- ###
|
||||
add_executable(libView ./applications/Entry.cpp)
|
||||
target_link_libraries(libView ${PROJECT_NAME} ${ALSA_LIBRARY})
|
||||
target_link_libraries(libView ${PROJECT_NAME})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Player.hpp"
|
||||
#include "GUI.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
#include "Player.hpp"
|
||||
#include "Buffer.hpp"
|
||||
#include "Multithreading.hpp"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
#include "Streamer.hpp"
|
||||
|
||||
#ifndef ENV_OS_WINDOWS
|
||||
typedef u_int8_t uint8_t;
|
||||
typedef u_int16_t uint16_t;
|
||||
typedef u_int32_t uint32_t;
|
||||
#endif
|
||||
|
||||
#define DR_FLAC_IMPLEMENTATION
|
||||
#include "dr_flac.h"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ file(GLOB SOURCES "./private/*.cpp")
|
|||
file(GLOB HEADERS "./public/*.hpp")
|
||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Utils)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC Allocators)
|
||||
|
||||
### -------------------------- Tests -------------------------- ###
|
||||
enable_testing()
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
/// whoaoao wtf
|
||||
|
||||
#include "MathCommon.hpp"
|
||||
#include "Allocators.hpp"
|
||||
|
||||
#include "ContainersCommon.hpp"
|
||||
|
||||
static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleContainers, nullptr };
|
||||
static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleAllocators, nullptr };
|
||||
|
||||
tp::ModuleManifest tp::gModuleMath = ModuleManifest("Math", nullptr, nullptr, sModuleDependencies);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "Topology.hpp"
|
||||
|
||||
void* operator new(std::size_t, void* in) { return in; }
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using namespace tp;
|
|||
|
||||
TEST_DEF(ComplexNumber) {
|
||||
TEST((ComplexCart{ 3, 4 }.mod() == 5));
|
||||
TEST((ComplexCart{ 1, 1 }.arg() == 0.7853981633974483));
|
||||
TEST((abs(ComplexCart{ 1, 1 }.arg() - 0.7853981633974483) < 0.001));
|
||||
TEST((ComplexCart{ 3, 4 }.norm2() == 25));
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include "compiler/function.h"
|
||||
|
||||
#include "strings.h"
|
||||
#include "Strings.hpp"
|
||||
|
||||
namespace obj {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "Window.hpp"
|
||||
|
||||
#include "GUI.h"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "compiler/constants.h"
|
||||
#include "NewPlacement.hpp"
|
||||
#include "primitives/methodobject.h"
|
||||
#include "primitives/primitives.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "compiler/expression.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace BCgen;
|
||||
|
|
@ -64,30 +63,30 @@ ExpressionFunc::ExpressionFunc(tp::String id) :
|
|||
Expression(Type::FUNC),
|
||||
mFuncId(id) {}
|
||||
ExpressionConst::ExpressionConst(tp::String val) :
|
||||
Expression(Type::CONST),
|
||||
Expression(Type::CONST_EXPR),
|
||||
mConstType(STR),
|
||||
str(val) {}
|
||||
ExpressionConst::ExpressionConst(const char* val) :
|
||||
Expression(Type::CONST),
|
||||
Expression(Type::CONST_EXPR),
|
||||
mConstType(STR),
|
||||
str(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::int4 val) :
|
||||
Expression(Type::CONST),
|
||||
Expression(Type::CONST_EXPR),
|
||||
mConstType(INT),
|
||||
integer(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::flt4 val) :
|
||||
Expression(Type::CONST),
|
||||
Expression(Type::CONST_EXPR),
|
||||
mConstType(FLT),
|
||||
floating(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::alni val) :
|
||||
Expression(Type::CONST),
|
||||
Expression(Type::CONST_EXPR),
|
||||
mConstType(INT),
|
||||
integer(val) {}
|
||||
ExpressionConst::ExpressionConst(tp::alnf val) :
|
||||
Expression(Type::CONST),
|
||||
Expression(Type::CONST_EXPR),
|
||||
mConstType(FLT),
|
||||
floating(val) {}
|
||||
ExpressionConst::ExpressionConst(bool val) :
|
||||
Expression(Type::CONST),
|
||||
Expression(Type::CONST_EXPR),
|
||||
mConstType(BOOL),
|
||||
boolean(val) {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "compiler/function.h"
|
||||
|
||||
#include "primitives/methodobject.h"
|
||||
|
|
@ -305,7 +303,7 @@ void FunctionDefinition::EvalExpr(Expression* expr) {
|
|||
inst(Instruction(OpCode::LOAD_LOCAL, mConstants.get(local->mLocalId)));
|
||||
break;
|
||||
}
|
||||
case Expression::Type::CONST:
|
||||
case Expression::Type::CONST_EXPR:
|
||||
{
|
||||
auto constobj = (ExpressionConst*) expr;
|
||||
switch (constobj->mConstType) {
|
||||
|
|
@ -384,7 +382,7 @@ tp::alni instSize(const Instruction& inst) {
|
|||
out += inst.mParamBytes;
|
||||
return out;
|
||||
}
|
||||
case Instruction::ArgType::CONST:
|
||||
case Instruction::ArgType::CONST_ARG:
|
||||
{
|
||||
out += 2;
|
||||
if (inst.mConstData2) {
|
||||
|
|
@ -516,7 +514,7 @@ void FunctionDefinition::generateByteCode(ByteCode& out) {
|
|||
writeParam(out, idx, (tp::int1*) &inst.mParam, inst.mParamBytes);
|
||||
break;
|
||||
}
|
||||
case Instruction::ArgType::CONST:
|
||||
case Instruction::ArgType::CONST_ARG:
|
||||
{
|
||||
writeConst(out, idx, (tp::uint2) inst.mConstData->mConstIdx);
|
||||
if (inst.mConstData2) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include "compiler/instruction.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
|
|
@ -21,14 +20,14 @@ Instruction::Instruction(ConstObject* constData) :
|
|||
Instruction::Instruction(OpCode op, ConstObject* constData) :
|
||||
mOp(op),
|
||||
mConstData(constData),
|
||||
mArgType(ArgType::CONST),
|
||||
mArgType(ArgType::CONST_ARG),
|
||||
mInstType(InstType::EXEC) {}
|
||||
|
||||
Instruction::Instruction(OpCode op, ConstObject* constData, ConstObject* constData2) :
|
||||
mOp(op),
|
||||
mConstData(constData),
|
||||
mConstData2(constData2),
|
||||
mArgType(ArgType::CONST),
|
||||
mArgType(ArgType::CONST_ARG),
|
||||
mInstType(InstType::EXEC) {}
|
||||
|
||||
Instruction::Instruction(OpCode op, tp::alni param, tp::alni nBytes) :
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "compiler/statement.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace BCgen;
|
||||
|
|
@ -76,7 +75,7 @@ StatementClassDef::StatementClassDef(tp::String class_id, StatementScope* scope)
|
|||
StatementFuncDef* obj::BCgen::StmDefFunc(tp::String id, tp::InitialierList<tp::String> args, tp::InitialierList<Statement*> stms) { return new StatementFuncDef(id, args, stms); }
|
||||
|
||||
StatementLocalDef* obj::BCgen::StmDefLocal(tp::String id, Expression* value) {
|
||||
if (value->mType == Expression::Type::CONST) {
|
||||
if (value->mType == Expression::Type::CONST_EXPR) {
|
||||
return new StatementLocalDef(id, (ExpressionConst*) value);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Tokenizer.hpp"
|
||||
|
||||
#include "compiler/function.h"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "core/object.h"
|
||||
|
||||
#include "primitives/classobject.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "core/object.h"
|
||||
|
||||
#include "primitives/nullobject.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include "HeapAllocatorGlobal.hpp"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "core/scriptsection.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "core/typegroups.h"
|
||||
|
||||
#include "core/object.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "core/typemethods.h"
|
||||
|
||||
#include "primitives/floatobject.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "interpreter/callstack.h"
|
||||
|
||||
#include "interpreter/bytecode.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "interpreter/interpreter.h"
|
||||
|
||||
#include "primitives/primitives.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "interpreter/operandsstack.h"
|
||||
|
||||
using namespace obj;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "interpreter/scopestack.h"
|
||||
|
||||
using namespace obj;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
|
||||
#include "primitives/boolobject.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "primitives/classobject.h"
|
||||
#include "primitives/dictobject.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include "primitives/colorobject.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "primitives/dictobject.h"
|
||||
#include "primitives/stringobject.h"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "primitives/enumobject.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include "primitives/floatobject.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "primitives/interpreterobject.h"
|
||||
#include "primitives/linkobject.h"
|
||||
#include "primitives/methodobject.h"
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "primitives/intobject.h"
|
||||
|
||||
using namespace obj;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "primitives/linkobject.h"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace obj;
|
||||
using namespace tp;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,4 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "primitives/intobject.h"
|
||||
#include "primitives/listobject.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "compiler/function.h"
|
||||
#include "core/scriptsection.h"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "primitives/nullobject.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "primitives/stringobject.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "primitives/typeobject.h"
|
||||
#include "NewPlacement.hpp"
|
||||
#include "primitives/nullobject.h"
|
||||
|
||||
using namespace obj;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@
|
|||
namespace obj {
|
||||
namespace BCgen {
|
||||
|
||||
struct ConstObject {
|
||||
class ConstObject {
|
||||
public:
|
||||
obj::Object* mObj = NULL;
|
||||
tp::alni mConstIdx = 0;
|
||||
|
||||
|
|
@ -16,7 +17,8 @@ namespace obj {
|
|||
};
|
||||
|
||||
|
||||
struct ConstObjectsPool {
|
||||
class ConstObjectsPool {
|
||||
public:
|
||||
tp::Map<tp::String, ConstObject*> mMethods;
|
||||
tp::Map<tp::String, ConstObject*> mStrings;
|
||||
tp::Map<tp::alni, ConstObject*> mIntegers;
|
||||
|
|
@ -36,6 +38,7 @@ namespace obj {
|
|||
ConstObject* registerObject(obj::Object* obj);
|
||||
void save(tp::Buffer<ConstData>& out);
|
||||
|
||||
ConstObjectsPool() = default;
|
||||
~ConstObjectsPool();
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ namespace obj {
|
|||
NONE,
|
||||
NEW,
|
||||
LOCAL,
|
||||
CONST,
|
||||
CONST_EXPR,
|
||||
CHILD,
|
||||
CALL,
|
||||
ARIPHM,
|
||||
|
|
|
|||
|
|
@ -10,16 +10,17 @@
|
|||
namespace obj {
|
||||
namespace BCgen {
|
||||
|
||||
struct ConstObject;
|
||||
class ConstObject;
|
||||
|
||||
struct Instruction {
|
||||
class Instruction {
|
||||
public:
|
||||
|
||||
OpCode mOp = OpCode::NONE;
|
||||
|
||||
enum class ArgType : tp::ualni {
|
||||
NO_ARG,
|
||||
PARAM,
|
||||
CONST,
|
||||
CONST_ARG,
|
||||
} mArgType = ArgType::NO_ARG;
|
||||
|
||||
enum class InstType : tp::ualni {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#pragma once
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "compiler/statement.h"
|
||||
#include "compiler/expression.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "Testing.hpp"
|
||||
|
||||
#include "primitives/primitives.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Testing.hpp"
|
||||
|
||||
#include "core/object.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Testing.hpp"
|
||||
|
||||
#include "compiler/function.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Testing.hpp"
|
||||
|
||||
#include "core/object.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "CommandLine.hpp"
|
||||
#include "Parser.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
#include "CLR.hpp"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include "CfGrammar.hpp"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Timing.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "CfGrammar.hpp"
|
||||
#include "Tokenizer.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
#include "Parser.hpp"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Tokenizer.hpp"
|
||||
|
||||
using namespace tp;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "Parser.hpp"
|
||||
#include "Testing.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "Parser.hpp"
|
||||
#include "Testing.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
#include "Parser.hpp"
|
||||
#include "Testing.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@
|
|||
#define STB_IMAGE_WRITE_IMPLEMENTATION
|
||||
#include "stb_image_write.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
using namespace tp;
|
||||
|
||||
void writeImage(const RayTracer::RenderBuffer& output, const char* name) {
|
||||
|
|
@ -37,22 +41,19 @@ void writeImage(const RayTracer::RenderBuffer& output, const char* name) {
|
|||
}
|
||||
}
|
||||
|
||||
static void* printStatus(void* arg) {
|
||||
auto percentage = (const halnf*) arg;
|
||||
void printStatus(const halnf* percentage) {
|
||||
auto old = *percentage;
|
||||
while (*percentage < 0.99f) {
|
||||
sleep(500);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
if (old != *percentage && (*percentage - old) > 0.01) {
|
||||
printf("Progress - %f\n", (*percentage) * 100);
|
||||
std::cout << "Progress - " << (*percentage) * 100 << std::endl;
|
||||
old = *percentage;
|
||||
}
|
||||
}
|
||||
pthread_exit(NULL);
|
||||
}
|
||||
|
||||
void renderCommand(const String& scenePath) {
|
||||
Scene scene;
|
||||
|
||||
RayTracer::RenderSettings settings;
|
||||
|
||||
loadScene(scene, scenePath, settings);
|
||||
|
|
@ -60,16 +61,9 @@ void renderCommand(const String& scenePath) {
|
|||
RayTracer::OutputBuffers output;
|
||||
RayTracer rayt;
|
||||
|
||||
pthread_t my_thread;
|
||||
int ret;
|
||||
std::thread statusThread(printStatus, &rayt.mProgress.percentage);
|
||||
|
||||
printf("\nStarting Render:\n\n");
|
||||
|
||||
ret = pthread_create(&my_thread, NULL, &printStatus, &rayt.mProgress.percentage);
|
||||
if (ret != 0) {
|
||||
printf("Error: pthread_create() failed\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
std::cout << "\nStarting Render:\n\n";
|
||||
|
||||
auto start = get_time();
|
||||
|
||||
|
|
@ -77,9 +71,9 @@ void renderCommand(const String& scenePath) {
|
|||
|
||||
auto end = get_time();
|
||||
|
||||
pthread_join(my_thread, NULL);
|
||||
statusThread.join();
|
||||
|
||||
printf("\nRender finished with average render time per sample - %i (ms)\n", end - start);
|
||||
std::cout << "\nRender finished with average render time per sample - " << (end - start) << " (ms)\n";
|
||||
|
||||
writeImage(output.normals, "normals.png");
|
||||
writeImage(output.color, "color.png");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
#include "MathCommon.hpp"
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "CommandLine.hpp"
|
||||
#include "Module.hpp"
|
||||
|
|
@ -48,10 +47,10 @@ ModuleManifest* sDependencies[] = { &gModuleMath, &gModuleCommandLine, &gModuleC
|
|||
|
||||
ModuleManifest tp::gModuleRayTracer = ModuleManifest("RayTracer", nullptr, nullptr, sDependencies);
|
||||
|
||||
void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf far) {
|
||||
void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf farVal) {
|
||||
out.hit = false;
|
||||
|
||||
far *= far;
|
||||
farVal *= farVal;
|
||||
|
||||
for (auto obj : mScene->mObjects) {
|
||||
for (auto trig : obj->mCache.TrigCaches) {
|
||||
|
|
@ -60,13 +59,13 @@ void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf far) {
|
|||
|
||||
auto dist = (trig->getHitPos() - ray.pos).length2();
|
||||
|
||||
if (far > dist && dist > EPSILON) {
|
||||
if (farVal > dist && dist > EPSILON) {
|
||||
out.trig = &trig.data();
|
||||
out.hitPos = trig->getHitPos();
|
||||
out.obj = &obj.data();
|
||||
out.hit = true;
|
||||
|
||||
far = dist;
|
||||
farVal = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Logging.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Strings.hpp"
|
||||
#include "Tests.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "StringLogic.hpp"
|
||||
#include "Tests.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@
|
|||
#include "Utils.hpp"
|
||||
#include "Map.hpp"
|
||||
|
||||
#ifdef ENV_OS_WINDOWS
|
||||
#undef min
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
namespace tp {
|
||||
|
||||
extern ModuleManifest gModuleTokenizer;
|
||||
|
|
@ -100,7 +105,7 @@ namespace tp {
|
|||
|
||||
Range<tAlphabetType> getAlphabetRange() const {
|
||||
tAlphabetType start = 0, end = 0;
|
||||
Range<tAlphabetType> all_range = { std::numeric_limits<tAlphabetType>::min(), std::numeric_limits<tAlphabetType>::max() };
|
||||
Range<tAlphabetType> all_range(std::numeric_limits<tAlphabetType>::min(), std::numeric_limits<tAlphabetType>::max());
|
||||
bool first = true;
|
||||
|
||||
for (auto vertex : mVertices) {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
#include "NewPlacement.hpp"
|
||||
// #include "NewPlacement.hpp"
|
||||
|
||||
#include "Testing.hpp"
|
||||
#include "Tokenizer.hpp"
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
#define LOG(val) // std::cout << #val << " "
|
||||
#define LOG(val) std::cout << #val << " "
|
||||
|
||||
using namespace tp;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ void initializeCallStackCapture() { gCSCapture = new (malloc(sizeof(CallStackCap
|
|||
void deinitializeCallStackCapture() {
|
||||
gCSCapture->~CallStackCapture();
|
||||
free(gCSCapture);
|
||||
gCSCapture = nullptr;
|
||||
}
|
||||
|
||||
ualni CallStackCapture::CallStack::getDepth() const {
|
||||
|
|
@ -70,6 +71,8 @@ CallStackCapture::CallStackCapture() {
|
|||
}
|
||||
|
||||
const CallStackCapture::CallStack* CallStackCapture::getSnapshot() {
|
||||
MODULE_SANITY_CHECK(gModuleUtils)
|
||||
|
||||
if (mBuffLoad > mBuffLen) {
|
||||
static CallStack cs;
|
||||
cs.frames[0] = 0;
|
||||
|
|
@ -229,4 +232,10 @@ void CallStackCapture::platformWriteDebugSymbols(FramePointer frame, DebugSymbol
|
|||
std::strcpy(out->file, "unresolved");
|
||||
std::strcpy(out->function, "unresolved");
|
||||
}
|
||||
void CallStackCapture::printSnapshot(const CallStack* snapshot) {
|
||||
printf("CallStack: \n");
|
||||
printf("Call stack debugging is not supported on this platform");
|
||||
printf("\n");
|
||||
}
|
||||
void CallStackCapture::logAll() { printf("Call stack debugging is not supported on this platform"); }
|
||||
#endif
|
||||
|
|
@ -37,7 +37,7 @@ void Testing::reportState() {
|
|||
|
||||
printf("\n");
|
||||
mRootTest.report();
|
||||
}
|
||||
}
|
||||
|
||||
bool Testing::hasFailed() {
|
||||
mRootTest.updateState();
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <pthread.h>
|
||||
#include <mutex>
|
||||
|
||||
namespace tp {
|
||||
class Mutex {
|
||||
pthread_mutex_t mMutex{};
|
||||
std::mutex mMutex;
|
||||
|
||||
public:
|
||||
Mutex() = default;
|
||||
|
||||
void lock() { pthread_mutex_lock(&mMutex); }
|
||||
void lock() { mMutex.lock(); }
|
||||
|
||||
void unlock() { pthread_mutex_unlock(&mMutex); }
|
||||
void unlock() { mMutex.unlock(); }
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue