瀏覽代碼

Remove quotes from #error directives

Ole Krüger 10 年之前
父節點
當前提交
70cdd3bdcb
共有 11 個文件被更改,包括 57 次插入84 次删除
  1. 2 0
      .gitignore
  2. 29 0
      examples/Makefile
  3. 5 0
      examples/functions.cc
  4. 0 10
      lib/luwra.h
  5. 10 0
      lib/luwra.hpp
  6. 2 2
      lib/luwra/common.hpp
  7. 2 2
      lib/luwra/stack.hpp
  8. 0 63
      lib/luwra/storage.h
  9. 1 1
      lib/luwra/types.hpp
  10. 3 3
      lib/luwra/userdata.hpp
  11. 3 3
      lib/luwra/wrappers.hpp

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+examples/*.out
+examples/*.d

+ 29 - 0
examples/Makefile

@@ -0,0 +1,29 @@
+# Utilities
+RM              = rm -rf
+EXEC            = exec
+
+# Artifacts
+OBJS            = functions.out
+DEPS            = $(OBJS:%=%.d)
+
+# Compiler
+CXX             ?= clang++
+CXXFLAGS        += -std=c++14 -O2 -fno-exceptions -fno-rtti -fmessage-length=0 -Wall -Wextra \
+                   -pedantic -I../lib
+LDLIBS          += -llua
+
+# Default Targets
+all: $(OBJS)
+
+clean:
+	$(RM) $(DEPS) $(OBJS)
+
+# Objects
+-include $(DEPS)
+
+%.out: %.cc Makefile
+	$(CXX) $(CXXFLAGS) -MMD -MF$(@:%=%.d) -MT$@ -o$@ $< $(LDLIBS)
+	$(EXEC) ./$@
+
+# Phony
+.PHONY: clean

+ 5 - 0
examples/functions.cc

@@ -0,0 +1,5 @@
+#include <luwra.h>
+
+int main() {
+	return 0;
+}

+ 0 - 10
lib/luwra.h

@@ -1,10 +0,0 @@
-#ifndef LUWRA_H_
-#define LUWRA_H_
-
-#include "luwra/common.h"
-#include "luwra/types.h"
-#include "luwra/stack.h"
-#include "luwra/userdata.h"
-#include "luwra/wrappers.h"
-
-#endif

+ 10 - 0
lib/luwra.hpp

@@ -0,0 +1,10 @@
+#ifndef LUWRA_H_
+#define LUWRA_H_
+
+#include "luwra/common.hpp"
+#include "luwra/types.hpp"
+#include "luwra/stack.hpp"
+#include "luwra/userdata.hpp"
+#include "luwra/wrappers.hpp"
+
+#endif

+ 2 - 2
lib/luwra/common.h → lib/luwra/common.hpp

@@ -9,14 +9,14 @@
 
 // Check C++ version
 #if !defined(__cplusplus) || __cplusplus < 201402L
-	#error "You need a C++14 compliant compiler"
+	#error You need a C++14 compliant compiler
 #endif
 
 #include <lua.hpp>
 
 // Check for proper Lua version
 #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 503 || LUA_VERSION_NUM >= 600
-	#error "Luwra has not been tested against your installed version of Lua"
+	#error Luwra has not been tested against your installed version of Lua
 #endif
 
 #define LUWRA_NS_BEGIN namespace luwra {

+ 2 - 2
lib/luwra/stack.h → lib/luwra/stack.hpp

@@ -7,8 +7,8 @@
 #ifndef LUWRA_STACK_H_
 #define LUWRA_STACK_H_
 
-#include "common.h"
-#include "types.h"
+#include "common.hpp"
+#include "types.hpp"
 
 #include <utility>
 #include <functional>

+ 0 - 63
lib/luwra/storage.h

@@ -1,63 +0,0 @@
-/* Luwra
- * Minimal-overhead Lua wrapper for C++
- *
- * Copyright (C) 2015, Ole Krüger <ole@vprsm.de>
- */
-
-#ifndef LUWRA_STORAGE_H_
-#define LUWRA_STORAGE_H_
-
-#include "common.h"
-
-LUWRA_NS_BEGIN
-
-/**
- * A seperate execution stack, which acts as a storage unit.
- */
-struct Storage {
-	State* storage;
-
-	/**
-	 * Create the storage unit.
-	 */
-	inline
-	Storage(State* parent, int capacity = 0) {
-		storage = lua_newthread(parent);
-		lua_pop(parent, 1);
-
-		reserve(capacity);
-	}
-
-	/**
-	 * Make sure at least `n` slots are available.
-	 */
-	inline
-	void reserve(int n) {
-		while (lua_gettop(storage) < n) {
-			lua_pushnil(storage);
-		}
-	}
-
-	/**
-	 * Fill a slot.
-	 */
-	template <typename T> inline
-	void set(int n, T value) {
-		reserve(n);
-		lua_remove(storage, n);
-		Value<T>::push(storage, value);
-		lua_insert(storage, n);
-	}
-
-	/**
-	 * Implicit conversion to a Lua state.
-	 */
-	inline
-	operator State*() {
-		return storage;
-	}
-};
-
-LUWRA_NS_END
-
-#endif

+ 1 - 1
lib/luwra/types.h → lib/luwra/types.hpp

@@ -7,7 +7,7 @@
 #ifndef LUWRA_TYPES_H_
 #define LUWRA_TYPES_H_
 
-#include "common.h"
+#include "common.hpp"
 
 #include <utility>
 #include <tuple>

+ 3 - 3
lib/luwra/userdata.h → lib/luwra/userdata.hpp

@@ -7,9 +7,9 @@
 #ifndef LUWRA_USERDATA_H_
 #define LUWRA_USERDATA_H_
 
-#include "common.h"
-#include "types.h"
-#include "stack.h"
+#include "common.hpp"
+#include "types.hpp"
+#include "stack.hpp"
 
 #include <sstream>
 #include <utility>

+ 3 - 3
lib/luwra/wrappers.h → lib/luwra/wrappers.hpp

@@ -7,9 +7,9 @@
 #ifndef LUWRA_WRAPPERS_H_
 #define LUWRA_WRAPPERS_H_
 
-#include "common.h"
-#include "types.h"
-#include "stack.h"
+#include "common.hpp"
+#include "types.hpp"
+#include "stack.hpp"
 
 LUWRA_NS_BEGIN