Skip to content

Commit

Permalink
Compile fixes for gcc and clang (#3)
Browse files Browse the repository at this point in the history
* fix missing includes

* remove dead code, update to newest wren

* fix missing cstdint include

* makefile uses linux shell commands
  • Loading branch information
Nelarius committed May 21, 2016
1 parent 5fefb95 commit af3de70
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Expand Up @@ -25,7 +25,7 @@ wrenly.mk
wrenly.txt

# Project files/folders
build/
build/vs*
build.sh
*.cc
bin/
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Expand Up @@ -32,8 +32,8 @@ install:
- bash build-wren.sh
- CPLUS_INCLUDE_PATH=$PWD/wren-master/src/include
- export CPLUS_INCLUDE_PATH
- LD_LIBRARY_PATH=$PWD/wren-master/lib
- export LD_LIBRARY_PATH
- LIBRARY_PATH=$LIBRARY_PATH:$PWD/wren-master/lib
- export LIBRARY_PATH

script:
- cd build/gmake
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -14,7 +14,7 @@ Current deficiencies:
- Wren++ has no concept of const-ness. When you pass an object via const-pointer to Wren, the resulting Wren foreign object will happily call the non-const methods of the object -- yikes!
- Wren access from C++ is rather minimal

Currently developing against `wren:master@18b638b`. This project is being developed to serve the needs of my [game engine](https://github.com/nelarius/playground) project.
Currently developing against `wren:master@0a060a9`. This project is being developed to serve the needs of my [game engine](https://github.com/nelarius/playground) project.

## Table of contents
* [Build](#build)
Expand Down
2 changes: 1 addition & 1 deletion build-wren.sh
@@ -1,6 +1,6 @@
#!/bin/sh

wget https://github.com/munificent/wren/archive/master.zip -O wren-master.zip
unzip wren-master.zip
unzip -q wren-master.zip
cd wren-master
make vm
4 changes: 2 additions & 2 deletions build/gmake/lib.make
Expand Up @@ -13,7 +13,7 @@ endif
ifeq ($(config),debug)
RESCOMP = windres
TARGETDIR = ../../lib
TARGET = $(TARGETDIR)/wrenpp.lib
TARGET = $(TARGETDIR)/libwrenpp.a
OBJDIR = obj/Debug/lib
DEFINES += -DDEBUG
INCLUDES += -I../../src
Expand All @@ -40,7 +40,7 @@ endif
ifeq ($(config),release)
RESCOMP = windres
TARGETDIR = ../../lib
TARGET = $(TARGETDIR)/wrenpp.lib
TARGET = $(TARGETDIR)/libwrenpp.a
OBJDIR = obj/Release/lib
DEFINES += -DNDEBUG
INCLUDES += -I../../src
Expand Down
24 changes: 12 additions & 12 deletions build/gmake/test.make
Expand Up @@ -13,7 +13,7 @@ endif
ifeq ($(config),debug)
RESCOMP = windres
TARGETDIR = ../../bin
TARGET = $(TARGETDIR)/test.exe
TARGET = $(TARGETDIR)/test
OBJDIR = obj/Debug/test
DEFINES += -DDEBUG
INCLUDES += -I../../src -I../../test
Expand All @@ -40,7 +40,7 @@ endif
ifeq ($(config),release)
RESCOMP = windres
TARGETDIR = ../../bin
TARGET = $(TARGETDIR)/test.exe
TARGET = $(TARGETDIR)/test
OBJDIR = obj/Release/test
DEFINES += -DNDEBUG
INCLUDES += -I../../src -I../../test
Expand Down Expand Up @@ -149,52 +149,52 @@ $(OBJDIR)/Test.o: ../../test/Test.cpp
ifeq ($(config),debug)
../../../../bin/assert.wren: ../../test/assert.wren
@echo "Building ../../test/assert.wren"
$(SILENT) IF EXIST ..\..\test\assert.wren\ (xcopy /Q /E /Y /I ..\..\test\assert.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\assert.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/assert.wren ../../bin
endif
ifeq ($(config),release)
../../../../bin/assert.wren: ../../test/assert.wren
@echo "Building ../../test/assert.wren"
$(SILENT) IF EXIST ..\..\test\assert.wren\ (xcopy /Q /E /Y /I ..\..\test\assert.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\assert.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/assert.wren ../../bin
endif
ifeq ($(config),debug)
../../../../bin/test.wren: ../../test/test.wren
@echo "Building ../../test/test.wren"
$(SILENT) IF EXIST ..\..\test\test.wren\ (xcopy /Q /E /Y /I ..\..\test\test.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\test.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/test.wren ../../bin
endif
ifeq ($(config),release)
../../../../bin/test.wren: ../../test/test.wren
@echo "Building ../../test/test.wren"
$(SILENT) IF EXIST ..\..\test\test.wren\ (xcopy /Q /E /Y /I ..\..\test\test.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\test.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/test.wren ../../bin
endif
ifeq ($(config),debug)
../../../../bin/test_method.wren: ../../test/test_method.wren
@echo "Building ../../test/test_method.wren"
$(SILENT) IF EXIST ..\..\test\test_method.wren\ (xcopy /Q /E /Y /I ..\..\test\test_method.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\test_method.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/test_method.wren ../../bin
endif
ifeq ($(config),release)
../../../../bin/test_method.wren: ../../test/test_method.wren
@echo "Building ../../test/test_method.wren"
$(SILENT) IF EXIST ..\..\test\test_method.wren\ (xcopy /Q /E /Y /I ..\..\test\test_method.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\test_method.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/test_method.wren ../../bin
endif
ifeq ($(config),debug)
../../../../bin/test_vector.wren: ../../test/test_vector.wren
@echo "Building ../../test/test_vector.wren"
$(SILENT) IF EXIST ..\..\test\test_vector.wren\ (xcopy /Q /E /Y /I ..\..\test\test_vector.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\test_vector.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/test_vector.wren ../../bin
endif
ifeq ($(config),release)
../../../../bin/test_vector.wren: ../../test/test_vector.wren
@echo "Building ../../test/test_vector.wren"
$(SILENT) IF EXIST ..\..\test\test_vector.wren\ (xcopy /Q /E /Y /I ..\..\test\test_vector.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\test_vector.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/test_vector.wren ../../bin
endif
ifeq ($(config),debug)
../../../../bin/vector.wren: ../../test/vector.wren
@echo "Building ../../test/vector.wren"
$(SILENT) IF EXIST ..\..\test\vector.wren\ (xcopy /Q /E /Y /I ..\..\test\vector.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\vector.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/vector.wren ../../bin
endif
ifeq ($(config),release)
../../../../bin/vector.wren: ../../test/vector.wren
@echo "Building ../../test/vector.wren"
$(SILENT) IF EXIST ..\..\test\vector.wren\ (xcopy /Q /E /Y /I ..\..\test\vector.wren ..\..\bin > nul) ELSE (xcopy /Q /Y /I ..\..\test\vector.wren ..\..\bin > nul)
$(SILENT) cp -rf ../../test/vector.wren ../../bin
endif

-include $(OBJECTS:%.o=%.d)
Expand Down
10 changes: 5 additions & 5 deletions src/Wren++.cpp
Expand Up @@ -79,7 +79,7 @@ void registerClass(const std::string& mod, std::string cName, WrenForeignClassMe

}

Method::Method(VM* vm, WrenValue* variable, WrenValue* method)
Method::Method(VM* vm, WrenHandle* variable, WrenHandle* method)
: vm_(vm),
method_(method),
variable_(variable),
Expand Down Expand Up @@ -143,8 +143,8 @@ void Method::release_() {
*refCount_ -= 1u;
if (*refCount_ == 0u) {
vm_->setState_(); // wrenReelaseValue will cause wren to free memory
wrenReleaseValue(vm_->vm(), method_);
wrenReleaseValue(vm_->vm(), variable_);
wrenReleaseHandle(vm_->vm(), method_);
wrenReleaseHandle(vm_->vm(), variable_);
delete refCount_;
refCount_ = nullptr;
}
Expand Down Expand Up @@ -309,8 +309,8 @@ Method VM::method(
setState_();
wrenEnsureSlots( vm_, 1 );
wrenGetVariable( vm_, mod.c_str(), var.c_str(), 0 );
WrenValue* variable = wrenGetSlotValue( vm_, 0 );
WrenValue* handle = wrenMakeCallHandle(vm_, sig.c_str());
WrenHandle* variable = wrenGetSlotHandle( vm_, 0 );
WrenHandle* handle = wrenMakeCallHandle(vm_, sig.c_str());
return Method( this, variable, handle );
}

Expand Down
15 changes: 8 additions & 7 deletions src/Wren++.h
@@ -1,20 +1,21 @@
#ifndef WRENPP_H_INCLUDED
#define WRENPP_H_INCLUDED

extern "C" {
#include <wren.h>
}
#include "detail/ForeignMethod.h"
#include "detail/ForeignClass.h"
#include "detail/ForeignMethod.h"
#include "detail/ForeignObject.h"
#include "detail/ForeignProperty.h"
#include "detail/ChunkAllocator.h"
extern "C" {
#include <wren.h>
}
#include <string>
#include <functional> // for std::hash
#include <cassert>
#include <cstdint>
#include <cstdlib> // for std::size_t
#include <cstring> // for memcpy, strcpy
#include <unordered_map>

namespace wrenpp {
Expand Down Expand Up @@ -115,7 +116,7 @@ inline const char* Value::as<const char*>() const {
*/
class Method {
public:
Method( VM*, WrenValue* variable, WrenValue* method );
Method( VM*, WrenHandle* variable, WrenHandle* method );
Method() = delete;
Method( const Method& );
Method( Method&& );
Expand All @@ -133,8 +134,8 @@ class Method {
void release_();

mutable VM* vm_; // this pointer is not managed here
mutable WrenValue* method_;
mutable WrenValue* variable_;
mutable WrenHandle* method_;
mutable WrenHandle* variable_;
unsigned* refCount_;
};

Expand Down Expand Up @@ -255,7 +256,7 @@ Value Method::operator()( Args... args ) const {
vm_->setState_();
constexpr const std::size_t Arity = sizeof...( Args );
wrenEnsureSlots( vm_->vm(), Arity + 1u );
wrenSetSlotValue(vm_->vm(), 0, variable_);
wrenSetSlotHandle(vm_->vm(), 0, variable_);

std::tuple<Args...> tuple = std::make_tuple( args... );
detail::passArgumentsToWren( vm_->vm(), tuple, std::make_index_sequence<Arity> {} );
Expand Down
1 change: 0 additions & 1 deletion src/detail/ChunkAllocator.cpp
@@ -1,6 +1,5 @@
#include "detail/ChunkAllocator.h"
#include "Wren++.h"
#include <cstdint>
#include <cstring>
#include <limits>

Expand Down
1 change: 1 addition & 0 deletions src/detail/ChunkAllocator.h
Expand Up @@ -2,6 +2,7 @@
#define CHUNKALLOCATOR_H_INCLUDED

#include <vector>
#include <cstdint>
#include <cstdlib>
#include <cassert>

Expand Down
6 changes: 1 addition & 5 deletions src/detail/ForeignMethod.h
@@ -1,10 +1,10 @@
#ifndef FOREIGNMETHOD_H_INCLUDED
#define FOREIGNMETHOD_H_INCLUDED

#include "ForeignObject.h"
extern "C" {
#include <wren.h>
}
#include "ForeignObject.h"
#include <string>
#include <tuple>
#include <type_traits>
Expand Down Expand Up @@ -222,10 +222,6 @@ struct WrenReturnValue {
static void set(WrenVM* vm, T val) {
ForeignObjectValue<T>::setInSlot(vm, 0, val);
}

static T& get(WrenVM* vm) {
return *getSlotForeign<T>(vm, 0);
}
};

template<typename T>
Expand Down
1 change: 1 addition & 0 deletions src/detail/ForeignObject.h
Expand Up @@ -10,6 +10,7 @@ extern "C" {
#include <cassert>
#include <vector>
#include <type_traits>
#include <string>

namespace wrenpp {
namespace detail {
Expand Down

0 comments on commit af3de70

Please sign in to comment.