├── test ├── doFileTest.lua ├── .gitignore ├── main.cpp └── Makefile ├── samples ├── abstraction │ ├── error_message │ │ ├── sample.lua │ │ ├── .gitignore │ │ ├── Makefile │ │ └── error_message.cpp │ ├── class │ │ ├── .gitignore │ │ └── Makefile │ ├── global │ │ ├── .gitignore │ │ ├── Makefile │ │ └── global.cpp │ ├── pusher │ │ ├── .gitignore │ │ ├── Makefile │ │ └── pusher.cpp │ ├── state │ │ ├── .gitignore │ │ ├── sample.lua │ │ └── Makefile │ ├── table │ │ ├── .gitignore │ │ └── Makefile │ ├── function │ │ ├── .gitignore │ │ └── Makefile │ ├── optional │ │ ├── .gitignore │ │ └── Makefile │ ├── reference │ │ ├── .gitignore │ │ └── Makefile │ ├── inheritance │ │ ├── .gitignore │ │ └── Makefile │ ├── function_call │ │ ├── .gitignore │ │ └── Makefile │ ├── polymorphism │ │ ├── .gitignore │ │ └── Makefile │ ├── default_argument │ │ ├── .gitignore │ │ └── Makefile │ ├── ignored_argument │ │ ├── .gitignore │ │ ├── Makefile │ │ └── ignored_argument.cpp │ ├── table_conversion │ │ ├── .gitignore │ │ └── Makefile │ ├── lua_function_argument │ │ ├── .gitignore │ │ └── Makefile │ ├── synthetic_inheritance │ │ ├── .gitignore │ │ └── Makefile │ ├── reference_wrapper_and_shared_ptr │ │ ├── .gitignore │ │ └── Makefile │ └── Makefile ├── core │ ├── embedded │ │ ├── .gitignore │ │ ├── Makefile │ │ └── embedded.cpp │ ├── function_caller │ │ ├── .gitignore │ │ └── Makefile │ ├── reference_wrapper │ │ ├── .gitignore │ │ ├── Makefile │ │ └── reference_wrapper.cpp │ ├── Makefile │ ├── hello │ │ ├── hello.lua │ │ ├── Makefile │ │ └── hello.cpp │ ├── regex │ │ ├── SubMatch.cpp │ │ ├── Makefile │ │ ├── Match.cpp │ │ ├── SubMatch.hpp │ │ ├── regex.lua │ │ └── Match.hpp │ ├── optional │ │ ├── optional.lua │ │ ├── Makefile │ │ └── library.cpp │ ├── shared_ptr │ │ ├── shared_ptr.lua │ │ └── Makefile │ ├── inheritance │ │ ├── inheritance.lua │ │ └── Makefile │ ├── class │ │ ├── Makefile │ │ └── class.lua │ ├── error_handling │ │ ├── Makefile │ │ └── error_handling.lua │ ├── luafunction │ │ ├── Makefile │ │ └── luafunction.lua │ ├── adaptors_functions │ │ ├── Makefile │ │ └── adaptors_functions.lua │ ├── default_argument │ │ ├── Makefile │ │ └── default_argument.lua │ ├── function_on_stack │ │ ├── Makefile │ │ └── function_on_stack.lua │ ├── rtti_polymorphism │ │ ├── Makefile │ │ └── rtti_polymorphism.lua │ ├── type_function │ │ ├── Makefile │ │ └── type_function.lua │ ├── ignored_argument │ │ ├── Makefile │ │ ├── ignored_argument.lua │ │ └── VectorOfDoubles.cpp │ ├── luafunction_argument │ │ ├── Makefile │ │ ├── luafunction_argument.lua │ │ └── algorithm.cpp │ ├── showcase │ │ ├── otherlib │ │ │ ├── Makefile │ │ │ └── otherlib.cpp │ │ └── Makefile │ ├── table_conversion │ │ └── Makefile │ └── synthetic_inheritance │ │ ├── Makefile │ │ └── synthetic_inheritance.lua └── Makefile ├── .gitmodules ├── .gitignore ├── LICENSE ├── lib └── integral │ ├── Makefile │ ├── ArgumentTag.hpp │ ├── MultipleInheritancePack.hpp │ ├── LuaFunctionArgument.cpp │ ├── integral.hpp │ ├── FunctionSignature.hpp │ ├── IsStringLiteral.hpp │ ├── basic.cpp │ ├── Adaptor.hpp │ ├── IsTemplateClass.hpp │ ├── ConversionFunctionTraits.hpp │ ├── State.hpp │ ├── UserDataWrapperBase.hpp │ ├── State.cpp │ ├── UnexpectedStackException.cpp │ ├── UserDataWrapperBase.cpp │ ├── Getter.hpp │ ├── Setter.hpp │ ├── UserDataWrapper.hpp │ ├── GlobalReference.hpp │ ├── generic.hpp │ ├── GlobalBase.hpp │ ├── utility.hpp │ ├── Global.hpp │ ├── UnexpectedStackException.hpp │ ├── Table.hpp │ ├── DefaultArgument.hpp │ ├── LuaIgnoredArgument.hpp │ ├── ReferenceValue.hpp │ ├── FunctorTraits.hpp │ ├── DefaultArgumentManagerContainer.hpp │ └── ClassMetatable.hpp ├── NOTES.md ├── Makefile └── common.mk /test/doFileTest.lua: -------------------------------------------------------------------------------- 1 | assert(42 == 42) 2 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | integral_test 3 | -------------------------------------------------------------------------------- /samples/abstraction/error_message/sample.lua: -------------------------------------------------------------------------------- 1 | throwException() 2 | -------------------------------------------------------------------------------- /samples/abstraction/class/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | class 3 | -------------------------------------------------------------------------------- /samples/abstraction/global/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | global 3 | -------------------------------------------------------------------------------- /samples/abstraction/pusher/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | pusher 3 | -------------------------------------------------------------------------------- /samples/abstraction/state/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | state 3 | -------------------------------------------------------------------------------- /samples/abstraction/table/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | table 3 | -------------------------------------------------------------------------------- /samples/core/embedded/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | embedded 3 | -------------------------------------------------------------------------------- /samples/abstraction/function/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | function 3 | -------------------------------------------------------------------------------- /samples/abstraction/optional/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | optional 3 | -------------------------------------------------------------------------------- /samples/abstraction/reference/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | reference 3 | -------------------------------------------------------------------------------- /samples/abstraction/inheritance/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | inheritance 3 | -------------------------------------------------------------------------------- /samples/abstraction/state/sample.lua: -------------------------------------------------------------------------------- 1 | print("hello from lua file sample code") 2 | -------------------------------------------------------------------------------- /samples/core/function_caller/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | function_caller 3 | -------------------------------------------------------------------------------- /samples/abstraction/error_message/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | error_message 3 | -------------------------------------------------------------------------------- /samples/abstraction/function_call/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | function_call 3 | -------------------------------------------------------------------------------- /samples/abstraction/polymorphism/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | polymorphism 3 | -------------------------------------------------------------------------------- /samples/core/reference_wrapper/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | reference_wrapper 3 | -------------------------------------------------------------------------------- /samples/abstraction/default_argument/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | default_argument 3 | -------------------------------------------------------------------------------- /samples/abstraction/ignored_argument/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | ignored_argument 3 | -------------------------------------------------------------------------------- /samples/abstraction/table_conversion/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | table_conversion 3 | -------------------------------------------------------------------------------- /samples/abstraction/lua_function_argument/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | lua_function_argument 3 | -------------------------------------------------------------------------------- /samples/abstraction/synthetic_inheritance/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | synthetic_inheritance 3 | -------------------------------------------------------------------------------- /samples/abstraction/reference_wrapper_and_shared_ptr/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore executable 2 | reference_wrapper_and_shared_ptr 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "dependencies/exception"] 2 | path = dependencies/exception 3 | url = https://github.com/aphenriques/exception.git 4 | [submodule "dependencies/Catch2"] 5 | path = dependencies/Catch2 6 | url = https://github.com/catchorg/Catch2.git 7 | -------------------------------------------------------------------------------- /samples/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: abstraction core all clean 2 | 3 | abstraction: 4 | cd abstraction && $(MAKE) all 5 | 6 | core: 7 | cd core && $(MAKE) all 8 | 9 | all: abstraction core 10 | 11 | clean: 12 | cd abstraction && $(MAKE) $@ 13 | cd core && $(MAKE) $@ 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Vim temporary files # 2 | ####################### 3 | *~ 4 | *.swp 5 | *.swo 6 | 7 | # Build files # 8 | ####################### 9 | *.d 10 | *.o 11 | *.so 12 | *.dylib 13 | *.a 14 | 15 | # OS generated files # 16 | ###################### 17 | .DS_Store 18 | .DS_Store? 19 | ._* 20 | .Spotlight-V100 21 | .Trashes 22 | ehthumbs.db 23 | Thumbs.db 24 | 25 | # utility files and folders # 26 | ###################### 27 | xcode 28 | -------------------------------------------------------------------------------- /samples/core/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | # http://stackoverflow.com/a/11206700 6 | 7 | SUBDIRS:=$(wildcard */.) 8 | TARGETS:=all clean # must not contain '/' 9 | 10 | SUBDIRS_TARGETS:=$(foreach t,$(TARGETS),$(addsuffix $t,$(SUBDIRS))) 11 | 12 | .PHONY: $(TARGETS) $(SUBDIRS_TARGETS) lib 13 | 14 | $(TARGETS): % : $(addsuffix %,$(SUBDIRS)) 15 | @echo 'Done "$*" target' 16 | 17 | $(SUBDIRS_TARGETS): 18 | $(MAKE) -C $(@D) $(@F:.%=%) 19 | 20 | # lib as prerequisite so that make -j all won't invoke make lib in parallel in each subdir 21 | $(addsuffix all,$(SUBDIRS)): lib 22 | 23 | lib: 24 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 25 | -------------------------------------------------------------------------------- /samples/abstraction/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | # http://stackoverflow.com/a/11206700 6 | 7 | SUBDIRS:=$(wildcard */.) 8 | TARGETS:=all clean # must not contain '/' 9 | 10 | SUBDIRS_TARGETS:=$(foreach t,$(TARGETS),$(addsuffix $t,$(SUBDIRS))) 11 | 12 | .PHONY: $(TARGETS) $(SUBDIRS_TARGETS) lib 13 | 14 | $(TARGETS): % : $(addsuffix %,$(SUBDIRS)) 15 | @echo 'Done "$*" target' 16 | 17 | $(SUBDIRS_TARGETS): 18 | $(MAKE) -C $(@D) $(@F:.%=%) 19 | 20 | # lib as prerequisite so that make -j all won't invoke make lib in parallel in each subdir 21 | $(addsuffix all,$(SUBDIRS)): lib 22 | 23 | lib: 24 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 25 | -------------------------------------------------------------------------------- /test/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // main.cpp 3 | // integral 4 | // 5 | // Copyright (C) 2016 André Pereira Henriques 6 | // aphenriques (at) outlook (dot) com 7 | // 8 | // This file is part of integral. 9 | // 10 | // integral is free software: you can redistribute it and/or modify 11 | // it under the terms of the GNU General Public License as published by 12 | // the Free Software Foundation, either version 3 of the License, or 13 | // (at your option) any later version. 14 | // 15 | // integral is distributed in the hope that it will be useful, 16 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | // GNU General Public License for more details. 19 | // 20 | // You should have received a copy of the GNU General Public License 21 | // along with integral. If not, see . 22 | // 23 | 24 | #define CATCH_CONFIG_MAIN 25 | #include 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2013-2023 André Pereira Henriques (aphenriques (at) outlook (dot) com) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /samples/core/hello/hello.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- hello.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2013, 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | require("libhello").printHello() 31 | -------------------------------------------------------------------------------- /samples/core/regex/SubMatch.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // SubMatch.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include "SubMatch.hpp" 28 | #include "Match.hpp" 29 | 30 | SubMatch::SubMatch(const Match &match, unsigned index) : std::csub_match(match[index]), sharedData_(match.getSharedData()) {} 31 | -------------------------------------------------------------------------------- /samples/core/optional/optional.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- library.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | library = require("liblibrary") 31 | 32 | print(library.getIdentity(42)); 33 | print(library.getIdentity(nil)); 34 | -------------------------------------------------------------------------------- /samples/core/shared_ptr/shared_ptr.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- shared_ptr.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | Object = require("libObject") 31 | 32 | sharedObject = Object.getShared() 33 | 34 | sharedObject:print() 35 | -------------------------------------------------------------------------------- /lib/integral/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | SRC_DIRS:=. $(wildcard */.) 6 | FILTER_OUT:= 7 | INCLUDE_DIRS:= 8 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 9 | LIB_DIRS:= 10 | 11 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 12 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 13 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 14 | ARFLAGS:=rcs 15 | 16 | ################################################################################ 17 | 18 | STATIC_LIB:=$(INTEGRAL_STATIC_LIB) 19 | SHARED_LIB:=$(INTEGRAL_SHARED_LIB) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all static shared clean 27 | 28 | all: static shared 29 | 30 | static: $(STATIC_LIB) 31 | 32 | shared: $(SHARED_LIB) 33 | 34 | $(STATIC_LIB): $(OBJS) 35 | $(AR) $(ARFLAGS) $@ $(OBJS) 36 | 37 | $(SHARED_LIB): $(OBJS) 38 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 39 | 40 | clean: 41 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(STATIC_LIB) $(SHARED_LIB) 42 | # rm -f $(DEPS) $(OBJS) $(STATIC_LIB) $(SHARED_LIB) 43 | 44 | %.d: %.cpp 45 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 46 | 47 | ifneq ($(MAKECMDGOALS),clean) 48 | -include $(DEPS) 49 | endif 50 | -------------------------------------------------------------------------------- /lib/integral/ArgumentTag.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ArgumentTag.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_ArgumentTag_hpp 28 | #define integral_ArgumentTag_hpp 29 | 30 | #include 31 | 32 | namespace integral { 33 | namespace detail { 34 | template 35 | class ArgumentTag {}; 36 | } 37 | } 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /samples/core/inheritance/inheritance.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- inheritance.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | Derived = require("libDerived") 31 | 32 | derived = Derived.new() 33 | derived:base1Method() 34 | derived:base2Method() 35 | derived:baseOfBase1Method() 36 | derived:derivedMethod() 37 | -------------------------------------------------------------------------------- /samples/core/class/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Object 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/hello/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=hello 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/regex/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Regex 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/optional/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=library 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/shared_ptr/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Object 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /lib/integral/MultipleInheritancePack.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // MultipleInheritancePack.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_MultipleInheritancePack_hpp 28 | #define integral_MultipleInheritancePack_hpp 29 | 30 | namespace integral { 31 | namespace detail { 32 | template 33 | class MultipleInheritancePack : public T... {}; 34 | } 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /samples/abstraction/class/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=class 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/global/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=global 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/pusher/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=pusher 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/state/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=state 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/table/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=table 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/core/embedded/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=embedded 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/core/error_handling/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Object 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/inheritance/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Derived 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/luafunction/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Object 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/abstraction/function/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=function 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/optional/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=optional 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/core/adaptors_functions/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=library 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/default_argument/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Object 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/function_on_stack/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=library 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/rtti_polymorphism/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Derived 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/type_function/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=Container 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/abstraction/inheritance/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=inheritance 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/reference/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=reference 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/core/ignored_argument/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=VectorOfDoubles 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/luafunction_argument/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=algorithm 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/core/showcase/otherlib/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=otherlib 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/abstraction/error_message/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=error_message 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/function_call/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=function_call 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/polymorphism/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=polymorphism 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/core/function_caller/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=function_caller 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/core/reference_wrapper/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=reference_wrapper 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/core/table_conversion/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=table_conversion 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/abstraction/default_argument/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=default_argument 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/ignored_argument/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=ignored_argument 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/table_conversion/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=table_conversion 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/core/synthetic_inheritance/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=SyntheticallyDerived 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 30 | $(MAKE) $(SHARED_LIB) 31 | 32 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 33 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 34 | 35 | clean: 36 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 37 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 38 | 39 | %.d: %.cpp 40 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 41 | 42 | ifneq ($(MAKECMDGOALS),clean) 43 | -include $(DEPS) 44 | endif 45 | -------------------------------------------------------------------------------- /samples/abstraction/lua_function_argument/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=lua_function_argument 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/synthetic_inheritance/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=synthetic_inheritance 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /samples/abstraction/reference_wrapper_and_shared_ptr/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=reference_wrapper_and_shared_ptr 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /test/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=integral_test 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_DEPENDENCIES_DIR)/Catch2/single_include 10 | LIB_DIRS:=$(LUA_LIB_DIR) 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) $(LUA_LDLIB) -ldl 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_EXECUTABLE_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 20 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 21 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 22 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 23 | 24 | .PHONY: all run clean 25 | 26 | all: 27 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 28 | $(MAKE) $(TARGET) 29 | 30 | run: all 31 | ./$(TARGET) 32 | 33 | $(TARGET): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(TARGET) 38 | # rm -f $(DEPS) $(OBJS) $(TARGET) 39 | 40 | %.d: %.cpp 41 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 42 | 43 | ifneq ($(MAKECMDGOALS),clean) 44 | -include $(DEPS) 45 | endif 46 | -------------------------------------------------------------------------------- /lib/integral/LuaFunctionArgument.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // LuaFunctionArgument.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include "LuaFunctionArgument.hpp" 28 | #include 29 | #include "lua_compatibility.hpp" 30 | 31 | namespace integral { 32 | namespace detail { 33 | LuaFunctionArgument::LuaFunctionArgument(lua_State *luaState, int index) : luaState_(luaState), luaAbsoluteStackIndex_(lua_compatibility::absindex(luaState, index)) {} 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/core/showcase/Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=../../.. 2 | 3 | include $(INTEGRAL_ROOT_DIR)/common.mk 4 | 5 | TARGET:=showcase 6 | SRC_DIRS:=. $(wildcard */.) 7 | FILTER_OUT:= 8 | INCLUDE_DIRS:=$(INTEGRAL_STATIC_LIB_INCLUDE_DIR) 9 | SYSTEM_INCLUDE_DIRS:=$(LUA_INCLUDE_DIR) $(INTEGRAL_EXCEPTION_INCLUDE_DIR) 10 | LIB_DIRS:= 11 | LDLIBS:=$(INTEGRAL_STATIC_LIB_LDLIB) 12 | 13 | # '-isystem ' supress warnings from included headers in . These headers are also excluded from dependency generation 14 | CXXFLAGS:=$(INTEGRAL_CXXFLAGS) $(addprefix -I, $(INCLUDE_DIRS)) $(addprefix -isystem , $(SYSTEM_INCLUDE_DIRS)) 15 | LDFLAGS:=$(INTEGRAL_SHARED_LDFLAGS) $(addprefix -L, $(LIB_DIRS)) 16 | 17 | ################################################################################ 18 | 19 | SHARED_LIB:=lib$(TARGET).$(SHARED_LIB_EXTENSION) 20 | 21 | SRC_DIRS:=$(subst /.,,$(SRC_DIRS)) 22 | SRCS:=$(filter-out $(FILTER_OUT), $(wildcard $(addsuffix /*.cpp, $(SRC_DIRS)))) 23 | OBJS:=$(addsuffix .o, $(basename $(SRCS))) 24 | DEPS:=$(addsuffix .d, $(basename $(SRCS))) 25 | 26 | .PHONY: all clean 27 | 28 | all: 29 | cd otherlib && $(MAKE) all 30 | cd $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR) && $(MAKE) static 31 | $(MAKE) $(SHARED_LIB) 32 | 33 | $(SHARED_LIB): $(OBJS) $(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 34 | $(CXX) -o $@ $(OBJS) $(LDFLAGS) $(LDLIBS) 35 | 36 | clean: 37 | cd otherlib && $(MAKE) clean 38 | rm -f $(addsuffix /*.d, $(SRC_DIRS)) $(addsuffix /*.o, $(SRC_DIRS)) $(SHARED_LIB) 39 | # rm -f $(DEPS) $(OBJS) $(SHARED_LIB) 40 | 41 | %.d: %.cpp 42 | $(CXX) $(CXXFLAGS) -MP -MM -MF $@ -MT '$@ $(addsuffix .o, $(basename $<))' $< 43 | 44 | ifneq ($(MAKECMDGOALS),clean) 45 | -include $(DEPS) 46 | endif 47 | -------------------------------------------------------------------------------- /samples/core/ignored_argument/ignored_argument.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- ignored_argument.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2015, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | VectorOfDoubles = require("libVectorOfDoubles") 31 | 32 | v = VectorOfDoubles.new() 33 | print("#v: " .. #v) 34 | print("v:pushBack(42)") 35 | v:pushBack(42) 36 | print("#v: " .. #v) 37 | print("v:pushBack(42)") 38 | v:pushBack(42) 39 | print("#v: " .. #v) 40 | -------------------------------------------------------------------------------- /samples/core/luafunction_argument/luafunction_argument.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- luafunction_argument.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | local algorithm = require("libalgorithm") 31 | local vector = {1, 2, 3} 32 | local doubleVector = algorithm.getTransformed(vector, function(element) return 2*element end) 33 | for i, v in ipairs(doubleVector) do 34 | print("[" .. i .. "]", v) 35 | end 36 | -------------------------------------------------------------------------------- /samples/core/rtti_polymorphism/rtti_polymorphism.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- rtti_polymorphism.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | Derived = require("libDerived") 31 | 32 | derived = Derived.new() 33 | derived:base1Method() 34 | derived:base2Method() 35 | derived:baseOfBase1Method() 36 | derived:derivedMethod() 37 | print("callAllTypes:") 38 | Derived.callAllTypes(derived, derived, derived, derived) 39 | -------------------------------------------------------------------------------- /lib/integral/integral.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // integral.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_integral_hpp 28 | #define integral_integral_hpp 29 | 30 | #include "Adaptor.hpp" 31 | #include "ArgumentException.hpp" 32 | #include "ClassMetatable.hpp" 33 | #include "core.hpp" 34 | #include "DefaultArgument.hpp" 35 | #include "Global.hpp" 36 | #include "Pusher.hpp" 37 | #include "State.hpp" 38 | #include "StateView.hpp" 39 | #include "Table.hpp" 40 | #include "UnexpectedStackException.hpp" 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/integral/FunctionSignature.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // FunctionSignature.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_FunctionSignature_hpp 28 | #define integral_FunctionSignature_hpp 29 | 30 | namespace integral { 31 | namespace detail { 32 | template 33 | class FunctionSignature; 34 | 35 | template 36 | class FunctionSignature { 37 | public: 38 | using Signature = R(A...); 39 | }; 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/integral/IsStringLiteral.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IsStringLiteral.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_IsStringLiteral_hpp 28 | #define integral_IsStringLiteral_hpp 29 | 30 | #include 31 | #include 32 | 33 | namespace integral { 34 | namespace detail { 35 | template 36 | class IsStringLiteral : public std::false_type {}; 37 | 38 | template 39 | class IsStringLiteral : public std::true_type {}; 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /samples/core/adaptors_functions/adaptors_functions.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- adaptors_functions.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2015, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | local library = require("liblibrary") 31 | 32 | local constructObject = library.getObjectConstructor() 33 | local object = constructObject("name") 34 | print(object:getName()) 35 | 36 | print("library.getInverse(2) = " .. library.getInverse(2)) 37 | 38 | local getConstant = library.getConstantFunction(42) 39 | print("getConstant() = " .. getConstant()) 40 | -------------------------------------------------------------------------------- /lib/integral/basic.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // basic.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include "basic.hpp" 28 | 29 | namespace integral { 30 | namespace detail { 31 | namespace basic { 32 | void setLuaFunction(lua_State *luaState, const char *name, lua_CFunction function, int nUpValues) { 33 | lua_pushcclosure(luaState, function, nUpValues); 34 | lua_pushstring(luaState, name); 35 | lua_insert(luaState, -2); 36 | lua_rawset(luaState, -3); 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/integral/Adaptor.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Adaptor.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_Adaptor_hpp 28 | #define integral_Adaptor_hpp 29 | 30 | #include 31 | 32 | namespace integral { 33 | template 34 | class Adaptor : public T { 35 | public: 36 | template 37 | inline Adaptor(A &&...arguments); 38 | }; 39 | 40 | //-- 41 | 42 | template 43 | template 44 | inline Adaptor::Adaptor(A &&...arguments) : T(std::forward(arguments)...) {} 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/integral/IsTemplateClass.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // IsTemplateClass.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_IsTemplateClass_hpp 28 | #define integral_IsTemplateClass_hpp 29 | 30 | #include 31 | 32 | namespace integral { 33 | namespace detail { 34 | template class T, typename U> 35 | class IsTemplateClass : public std::false_type {}; 36 | 37 | template class T, typename ...P> 38 | class IsTemplateClass> : public std::true_type {}; 39 | } 40 | } 41 | 42 | #endif /* integral_IsTemplateClass_hpp */ 43 | -------------------------------------------------------------------------------- /lib/integral/ConversionFunctionTraits.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ConversionFunctionTraits.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_ConversionFunctionTraits_hpp 28 | #define integral_ConversionFunctionTraits_hpp 29 | 30 | namespace integral { 31 | namespace detail { 32 | template 33 | class ConversionFunctionTraits; 34 | 35 | template 36 | class ConversionFunctionTraits { 37 | public: 38 | using ConversionType = U; 39 | using OriginalType = T; 40 | }; 41 | } 42 | } 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /samples/core/class/class.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- class.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | Object = require("libObject") 31 | 32 | object = Object.new("string", 42) 33 | persistence = object:getPersistence() 34 | object:setStringAndNumber("new string", 421) 35 | print(object:toString()) 36 | object:setStringAndNumberFromPersistence(persistence) 37 | print(object:toString()) 38 | object:setNumber(84) 39 | print(object:getNumber()) 40 | otherObject = Object.newFromPersistence(persistence) 41 | print(otherObject:toString()) 42 | -------------------------------------------------------------------------------- /samples/core/regex/Match.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Match.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include "Match.hpp" 28 | 29 | Match::Match(const char * string, const std::regex &pattern, Mode mode) : sharedData_(new std::string(string)) { 30 | std::cmatch match; 31 | switch (mode) { 32 | case Mode::EXACT: 33 | std::regex_match(sharedData_->c_str(), match, pattern); 34 | break; 35 | case Mode::PARTIAL: 36 | std::regex_search(sharedData_->c_str(), match, pattern); 37 | break; 38 | } 39 | std::cmatch::operator=(std::move(match)); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /samples/core/regex/SubMatch.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // SubMatch.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef SubMatch_hpp 28 | #define SubMatch_hpp 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | // Forward declaration 35 | class Match; 36 | 37 | class SubMatch : public std::csub_match { 38 | public: 39 | SubMatch(const Match &match, unsigned index); 40 | 41 | private: 42 | // the matching string data must be stored because std::csub_match and std::cmatch rely on it, and there is no guarantee that it would be kept in the lua stack 43 | const std::shared_ptr sharedData_; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /samples/core/synthetic_inheritance/synthetic_inheritance.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- synthetic_inheritance.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | SyntheticallyDerived = require("libSyntheticallyDerived") 31 | 32 | syntheticallyDerived = SyntheticallyDerived.new() 33 | print("-> syntheticallyDerived:baseOfSyntheticBaseMethod():") 34 | syntheticallyDerived:baseOfSyntheticBaseMethod() 35 | print("-> syntheticallyDerived:syntheticBaseMethod():") 36 | syntheticallyDerived:syntheticBaseMethod() 37 | print("-> syntheticallyDerived:syntheticallyDerivedMethod():") 38 | syntheticallyDerived:syntheticallyDerivedMethod() 39 | -------------------------------------------------------------------------------- /lib/integral/State.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // State.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_State_hpp 28 | #define integral_State_hpp 29 | 30 | 31 | #include 32 | #include "StateView.hpp" 33 | 34 | namespace integral { 35 | // State owns de luaState_ it creates 36 | class State : public StateView { 37 | public: 38 | // non-copyable 39 | State(const State &) = delete; 40 | State & operator=(const State &) = delete; 41 | 42 | // throws exception::RuntimeException if cannot create lua state 43 | State(); 44 | 45 | // moveable 46 | State(State &&state); 47 | 48 | ~State(); 49 | }; 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /lib/integral/UserDataWrapperBase.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // UserDataWrapperBase.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_UserDataWrapperBase_hpp 28 | #define integral_UserDataWrapperBase_hpp 29 | 30 | namespace integral { 31 | namespace detail { 32 | class UserDataWrapperBase { 33 | public: 34 | // non-copyable 35 | UserDataWrapperBase(const UserDataWrapperBase &) = delete; 36 | UserDataWrapperBase & operator=(const UserDataWrapperBase &) = delete; 37 | 38 | virtual ~UserDataWrapperBase(); 39 | 40 | protected: 41 | UserDataWrapperBase() = default; 42 | 43 | }; 44 | } 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /samples/core/function_on_stack/function_on_stack.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- function_on_stack.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2015, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | local library = require("liblibrary") 31 | 32 | local getPrefixed = library.getPrefixFunction("prefix-") 33 | print(getPrefixed("word")) 34 | 35 | local getSuffixed1 = library.getSuffixFunction1("-suffix1") 36 | print(getSuffixed1("palavra")) 37 | 38 | -- getSuffixFunction2 does the same as getSuffixFunction 39 | local getSuffixed2 = library.getSuffixFunction2("-suffix2") 40 | print(getSuffixed2("palavra")) 41 | 42 | local object = library.newObject("object") 43 | print(object) 44 | -------------------------------------------------------------------------------- /samples/core/type_function/type_function.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- type_function.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | Container = require("libContainer") 31 | 32 | container = Container.new(42.1) 33 | print("Container.getNumberFromId(container):", Container.getNumberFromId(container)) -- Container type conversion to Id 34 | print("container:getNumberFromId():", container:getNumberFromId()) -- alternative construct 35 | print("Container.getNegativeNumber(container):", Container.getNegativeNumber(container)) -- Container type conversion to double 36 | print("container:getNegativeNumber():", container:getNegativeNumber()) -- alternative construct 37 | -------------------------------------------------------------------------------- /lib/integral/State.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // State.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include "State.hpp" 28 | #include 29 | #include 30 | #include 31 | 32 | namespace integral { 33 | State::State() try : StateView(luaL_newstate()) { 34 | } catch (const StateException &stateException) { 35 | throw exception::RuntimeException(__FILE__, __LINE__, __func__, std::string("[integral] failed to create new lua state: { ") + stateException.what() + " }"); 36 | } 37 | 38 | State::State(State &&state) : StateView(std::move(state)) {} 39 | 40 | State::~State() { 41 | if (getLuaState() != nullptr) { 42 | lua_close(getLuaState()); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/integral/UnexpectedStackException.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UnexpectedStackException.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include "UnexpectedStackException.hpp" 28 | 29 | namespace integral { 30 | // If a class is defined in a header file and has a vtable (either it has virtual methods or it derives from classes with virtual methods), it must always have at least one out-of-line virtual method in the class. Without this, the compiler will copy the vtable and RTTI into every .o file that #includes the header, bloating .o file sizes and increasing link times. 31 | // source: http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers 32 | UnexpectedStackException::~UnexpectedStackException() {} 33 | 34 | } 35 | -------------------------------------------------------------------------------- /NOTES.md: -------------------------------------------------------------------------------- 1 | ## TODO 2 | * compile_flags 3 | * c++2b 4 | * updated exception 5 | * nested namespaces 6 | * SFINAE -> concepts 7 | * static_assert -> concepts 8 | * function traits -> standard library traits or concepts 9 | * update catch 10 | * intel compiler 11 | * coverity 12 | * compare performance with other binding libraries 13 | * frequent 14 | * check FIXME 15 | * run test 16 | * build all samples 17 | * check inlines 18 | * check includes (alphabetical order; necessity) 19 | * check memory leakage 20 | * check copyright notices 21 | * check compatibility with lua 5.1, 5.2 and 5.3 and luaJIT 22 | * update compatibility information on README.md and lua wiki 23 | 24 | ## Rationales 25 | * placement new is done on adjusted userdata allocated space to avoid constructor call on misaligned address 26 | * see basic::pushAlignedObject 27 | * removing occurrences of exchanger::Exchanger outside of exchanger.h is not possible because LuaFunctionArgument.h includes Caller.h which includes exchanger.h (cyclic dependency due to LuaFunctionArgument::call) 28 | * thought overload functions implementation methods result in high performance overhead and inconsistent behaviour with c++ overload mechanism 29 | * LuaPack (multiple return) adds complexity spread out through too much code (high maintence). Adaptors such as LuaTuple offers similar functionality 30 | * safety, robustness and clarity must be prioritized over performance: 31 | * shrinking integral reserved names string size decreases clarity (and it had little performance impact on preliminary tests) 32 | * usage 33 | * monitoring 34 | * configuration 35 | * adjustments 36 | * prototyping 37 | 38 | ## Problems 39 | * Xcode migh emmit a linker warning in the form: 40 | * "Direct access in function ..." 41 | * To fix this, on target (not project) settings set: 42 | * Inline Methods Hidden > No 43 | * error using -flto compiler flag: "ar: .o: plugin needed to handle lto object" 44 | * define: 45 | * AR=gcc-ar 46 | -------------------------------------------------------------------------------- /lib/integral/UserDataWrapperBase.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UserDataWrapperBase.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include "UserDataWrapperBase.hpp" 28 | 29 | namespace integral { 30 | namespace detail { 31 | // If a class is defined in a header file and has a vtable (either it has virtual methods or it derives from classes with virtual methods), it must always have at least one out-of-line virtual method in the class. Without this, the compiler will copy the vtable and RTTI into every .o file that #includes the header, bloating .o file sizes and increasing link times. 32 | // source: http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-for-classes-in-headers 33 | UserDataWrapperBase::~UserDataWrapperBase() {} 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /samples/core/luafunction/luafunction.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- luafunction.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | Object = require("libObject") 31 | 32 | o1 = Object.new("prefix") 33 | print(o1:getString()) 34 | o2 = o1:createSuffixedObjectLuaFunction("_suffix") 35 | print(o2:getString()) 36 | o2:addSuffixLuaFunction("_end") 37 | print(o2:getString()) 38 | 39 | print("--") 40 | -- argument checking is performed by integral::get 41 | print("wrong parameters handling", pcall(function() Object.createSuffixedObjectLuaFunction("wrong parameters") end)) 42 | 43 | print("--") 44 | Object.printUpvalue() 45 | printer = Object.getPrinter("object_printer") 46 | printer() 47 | 48 | print("--") 49 | Object.printMessage() 50 | 51 | print("--") 52 | Object.printStack(); 53 | -------------------------------------------------------------------------------- /lib/integral/Getter.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Getter.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2017, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_Getter_hpp 28 | #define integral_Getter_hpp 29 | 30 | namespace integral { 31 | namespace detail { 32 | template 33 | class Getter { 34 | public: 35 | inline Getter(R T::* attribute); 36 | 37 | inline R operator()(const T &object) const; 38 | 39 | private: 40 | R T::* const attribute_; 41 | }; 42 | 43 | //-- 44 | 45 | template 46 | inline Getter::Getter(R T::* attribute) : attribute_(attribute) {} 47 | 48 | template 49 | inline R Getter::operator()(const T &object) const { 50 | return object.*attribute_; 51 | } 52 | } 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lib/integral/Setter.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Setter.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_Setter_hpp 28 | #define integral_Setter_hpp 29 | 30 | namespace integral { 31 | namespace detail { 32 | template 33 | class Setter { 34 | public: 35 | inline Setter(R T::* attribute); 36 | 37 | inline void operator()(T &object, const R &value) const; 38 | 39 | private: 40 | R T::* const attribute_; 41 | }; 42 | 43 | //-- 44 | 45 | template 46 | inline Setter::Setter(R T::* attribute) : attribute_(attribute) {} 47 | 48 | template 49 | inline void Setter::operator()(T &object, const R &value) const { 50 | object.*attribute_ = value; 51 | } 52 | } 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lib/integral/UserDataWrapper.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // UserDataWrapper.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_UserDataWrapper_hpp 28 | #define integral_UserDataWrapper_hpp 29 | 30 | #include 31 | #include "UserDataWrapperBase.hpp" 32 | 33 | namespace integral { 34 | namespace detail { 35 | template 36 | class UserDataWrapper : public UserDataWrapperBase, public T { 37 | public: 38 | template 39 | inline UserDataWrapper(A &&...arguments); 40 | 41 | inline ~UserDataWrapper() override; 42 | }; 43 | 44 | //-- 45 | 46 | template 47 | template 48 | inline UserDataWrapper::UserDataWrapper(A &&...arguments) : T(std::forward(arguments)...) {} 49 | 50 | template 51 | inline UserDataWrapper::~UserDataWrapper() {} 52 | } 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /samples/abstraction/pusher/pusher.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // pusher.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | void pushModule(lua_State *luaState) { 33 | integral::push(luaState); 34 | integral::setFunction( 35 | luaState, 36 | "printHello", 37 | [] { 38 | std::cout << "Hello!" << std::endl; 39 | } 40 | ); 41 | } 42 | 43 | int main() { 44 | try { 45 | integral::State luaState; 46 | luaState["module"] = integral::Pusher(pushModule); 47 | luaState.doString("module.printHello()"); 48 | return EXIT_SUCCESS; 49 | } catch (const std::exception &exception) { 50 | std::cerr << "[pusher] " << exception.what() << std::endl; 51 | } catch (...) { 52 | std::cerr << "unknown exception thrown" << std::endl; 53 | } 54 | return EXIT_FAILURE; 55 | } 56 | -------------------------------------------------------------------------------- /lib/integral/GlobalReference.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // GlobalReference.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2017, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_GlobalReference_hpp 28 | #define integral_GlobalReference_hpp 29 | 30 | #include "GlobalBase.hpp" 31 | 32 | namespace integral::detail { 33 | class GlobalReference : public GlobalBase { 34 | public: 35 | GlobalReference(GlobalReference &&) = default; 36 | 37 | inline GlobalReference(lua_State *luaState); 38 | 39 | inline lua_State * getLuaState() const; 40 | inline void push() const; 41 | 42 | private: 43 | lua_State *luaState_; 44 | }; 45 | 46 | //-- 47 | 48 | inline GlobalReference::GlobalReference(lua_State *luaState) : luaState_(luaState) {} 49 | 50 | inline lua_State * GlobalReference::getLuaState() const { 51 | return luaState_; 52 | } 53 | 54 | inline void GlobalReference::push() const { 55 | GlobalBase::push(getLuaState()); 56 | } 57 | } 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /samples/core/optional/library.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // library.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | extern "C" { 33 | LUALIB_API int luaopen_liblibrary(lua_State *luaState) { 34 | try { 35 | integral::push(luaState); 36 | integral::setFunction(luaState, "getIdentity", [](std::optional x) { 37 | return x; 38 | }); 39 | return 1; 40 | } catch (const std::exception &exception) { 41 | lua_pushstring(luaState, (std::string("[optional sample setup] ") + exception.what()).c_str()); 42 | } catch (...) { 43 | lua_pushstring(luaState, "[shared_ptr sample setup] unknown exception thrown"); 44 | } 45 | // Error return outside catch scope so that the exception destructor can be called 46 | return lua_error(luaState); 47 | } 48 | } 49 | 50 | -------------------------------------------------------------------------------- /samples/core/hello/hello.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // hello.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | void printHello() { 32 | std::cout << "Hello!" << std::endl; 33 | } 34 | 35 | extern "C" { 36 | LUALIB_API int luaopen_libhello(lua_State *luaState) { 37 | try { 38 | lua_newtable(luaState); 39 | // module table 40 | 41 | integral::setFunction(luaState, "printHello", printHello); 42 | 43 | return 1; 44 | } catch (const std::exception &exception) { 45 | lua_pushstring(luaState, (std::string("[hello sample setup] ") + exception.what()).c_str()); 46 | } catch (...) { 47 | lua_pushstring(luaState, "[hello sample setup] unknown exception thrown"); 48 | } 49 | // Error return outside catch scope so that the exception destructor can be called 50 | return lua_error(luaState); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/integral/generic.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // generic.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_generic_hpp 28 | #define integral_generic_hpp 29 | 30 | #include 31 | 32 | namespace integral { 33 | namespace detail { 34 | namespace generic { 35 | template 36 | inline void expandDummyTemplatePack(T...); 37 | 38 | constexpr bool getLogicalOr(); 39 | 40 | template 41 | constexpr bool getLogicalOr(bool i, B... j); 42 | 43 | //-- 44 | 45 | template 46 | inline void expandDummyTemplatePack(T...) {} 47 | 48 | 49 | constexpr bool getLogicalOr() { 50 | return false; 51 | } 52 | 53 | template 54 | constexpr bool getLogicalOr(bool i, B... j) { 55 | return i | getLogicalOr(j...); 56 | } 57 | } 58 | } 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /samples/core/default_argument/default_argument.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- default_argument.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | Object = require("libObject") 31 | 32 | object = Object.new() 33 | print("object = Object.new() -- default constructor") 34 | print("object:getString():") 35 | print(object:getString()) 36 | print("--") 37 | object = Object.new("object_string") 38 | print([[object = Object.new("object_string")]]) 39 | print("object:getString():") 40 | print(object:getString()) 41 | print("--") 42 | print("Object.testDefault(nil, nil):") 43 | Object.testDefault(nil, nil) 44 | print("object:testDefault():") 45 | object:testDefault() 46 | print("object:testDefault(4):") 47 | object:testDefault(4) 48 | print("Object.testDefault(nil, 2):") 49 | Object.testDefault(nil, 2) 50 | print("--") 51 | print("Object.testDefault2(nil, \"testDefault2 string argument\"):") 52 | Object.testDefault2(nil, "testDefault2 string argument") 53 | -------------------------------------------------------------------------------- /lib/integral/GlobalBase.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // GlobalBase.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_GlobalBase_hpp 28 | #define integral_GlobalBase_hpp 29 | 30 | #include 31 | #include 32 | #include "lua_compatibility.hpp" 33 | 34 | namespace integral { 35 | class GlobalBase { 36 | public: 37 | // non-copyable 38 | GlobalBase(const GlobalBase &) = delete; 39 | GlobalBase & operator=(const GlobalBase &) = delete; 40 | 41 | GlobalBase(GlobalBase &&) = default; 42 | GlobalBase() = default; 43 | 44 | inline std::string getReferenceString() const; 45 | 46 | protected: 47 | inline void push(lua_State *luaState) const; 48 | }; 49 | 50 | //-- 51 | 52 | inline std::string GlobalBase::getReferenceString() const { 53 | return "_G"; 54 | } 55 | 56 | inline void GlobalBase::push(lua_State *luaState) const { 57 | detail::lua_compatibility::pushglobaltable(luaState); 58 | } 59 | } 60 | 61 | #endif 62 | 63 | -------------------------------------------------------------------------------- /samples/core/regex/regex.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- regex.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2013, 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | local Regex = require("libRegex") 31 | 32 | local pattern = Regex.new([[(.)\.(.)]]) -- literal string to avoid dealing with escape characters 33 | local matches = pattern:match("4.2") 34 | print("matches:", matches) 35 | if matches then 36 | print("matches:getSize():", matches:getSize()) 37 | for i = 0, matches:getSize() - 1 do 38 | print("matches("..i.."):", matches(i)) 39 | end 40 | end 41 | 42 | print("---") 43 | 44 | pattern = Regex.new("(.)") 45 | matches = pattern:search("42") 46 | print("matches:", matches) 47 | -- maybe matches == nil. c++ std::regex implementation may be incomplete 48 | if matches then 49 | print("matches:getSize():", matches:getSize()) 50 | for i = 0, matches:getSize() - 1 do 51 | print("matches("..i.."):", matches(i)) 52 | end 53 | end 54 | 55 | print("---") 56 | 57 | -- should be nil 58 | print("matches:", pattern:match("42")) 59 | -------------------------------------------------------------------------------- /samples/abstraction/global/global.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // global.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | int main() { 32 | try { 33 | integral::State luaState; 34 | luaState.openLibs(); 35 | luaState["x"] = 42; 36 | luaState["y"] = integral::Global()["x"]; // equivalent to "y = x" in lua 37 | luaState.doString("print(y)"); // prints "42" 38 | luaState["global"] = integral::Global(); // equivalent to "global = _G" in lua 39 | luaState.doString("print(global.y)"); // prints "42" 40 | luaState["t"] = integral::Table().set("x", integral::Global()["global"]["y"]); // equivalent to "t = {x = global.y}" in lua 41 | luaState.doString("print(t.x)"); // prints "42" 42 | return EXIT_SUCCESS; 43 | } catch (const std::exception &exception) { 44 | std::cerr << "[global] " << exception.what() << std::endl; 45 | } catch (...) { 46 | std::cerr << "unknown exception thrown" << std::endl; 47 | } 48 | return EXIT_FAILURE; 49 | } 50 | -------------------------------------------------------------------------------- /samples/core/regex/Match.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Match.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef Match_hpp 28 | #define Match_hpp 29 | 30 | #include 31 | #include 32 | #include 33 | #include "SubMatch.hpp" 34 | 35 | class Match : public std::cmatch { 36 | public: 37 | enum class Mode { 38 | EXACT, 39 | PARTIAL 40 | }; 41 | 42 | Match(const char * string, const std::regex &pattern, Mode mode); 43 | inline SubMatch getSubMatch(unsigned index) const; 44 | inline const std::shared_ptr & getSharedData() const; 45 | 46 | private: 47 | // the matching string data must be stored because std::csub_match and std::cmatch rely on it, and there is no guarantee that lua would not collect it 48 | const std::shared_ptr sharedData_; 49 | }; 50 | 51 | //- 52 | 53 | inline SubMatch Match::getSubMatch(unsigned index) const { 54 | return SubMatch(*this, index); 55 | } 56 | 57 | inline const std::shared_ptr & Match::getSharedData() const { 58 | return sharedData_; 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | INTEGRAL_ROOT_DIR:=. 2 | 3 | include common.mk 4 | 5 | INSTALL_TOP:=/usr/local 6 | INSTALL_INC:=$(INSTALL_TOP)/include/$(INTEGRAL) 7 | INSTALL_LIB:=$(INSTALL_TOP)/lib 8 | 9 | .PHONY: all static static_release shared shared_release samples test install_exception uninstall_exception install_static install uninstall clean 10 | 11 | # Any of the following make rules can be executed with the `-j` option (`make -j`) for parallel compilation 12 | 13 | all: 14 | cd $(INTEGRAL_LIB_DIR) && $(MAKE) $@ 15 | 16 | static: 17 | cd $(INTEGRAL_LIB_DIR) && $(MAKE) $@ 18 | 19 | # attention! the object files (.o) are generated without -fPIC, so it is necessary to clean the project in order to build shared targets (and most sample/core targets) which require -fPIC 20 | static_release: clean 21 | cd $(INTEGRAL_LIB_DIR) && $(MAKE) static OPTIMIZED=y WITH_FPIC=n 22 | 23 | shared: 24 | cd $(INTEGRAL_LIB_DIR) && $(MAKE) $@ 25 | 26 | shared_release: 27 | cd $(INTEGRAL_LIB_DIR) && $(MAKE) shared OPTIMIZED=y 28 | 29 | samples: static 30 | cd $(INTEGRAL_BIN_DIR) && $(MAKE) all 31 | 32 | test: static 33 | cd $(INTEGRAL_TEST_DIR) && $(MAKE) run 34 | 35 | install_exception: 36 | cd $(INTEGRAL_DEPENDENCIES_DIR)/exception && $(MAKE) install 37 | 38 | uninstall_exception: 39 | cd $(INTEGRAL_DEPENDENCIES_DIR)/exception && $(MAKE) uninstall 40 | 41 | install_static: install_exception 42 | mkdir -p $(INSTALL_INC) $(INSTALL_LIB) 43 | install -p -m 0644 $(INTEGRAL_LIB_DIR)/*.hpp $(INSTALL_INC) 44 | install -p -m 0644 $(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) $(INSTALL_LIB) 45 | 46 | install_shared: install_exception 47 | mkdir -p $(INSTALL_INC) $(INSTALL_LIB) 48 | install -p -m 0644 $(INTEGRAL_LIB_DIR)/*.hpp $(INSTALL_INC) 49 | install -p -m 0644 $(INTEGRAL_LIB_DIR)/$(INTEGRAL_SHARED_LIB) $(INSTALL_LIB) 50 | 51 | install: install_exception 52 | mkdir -p $(INSTALL_INC) $(INSTALL_LIB) 53 | install -p -m 0644 $(INTEGRAL_LIB_DIR)/*.hpp $(INSTALL_INC) 54 | install -p -m 0644 $(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) $(INTEGRAL_LIB_DIR)/$(INTEGRAL_SHARED_LIB) $(INSTALL_LIB) 55 | 56 | uninstall: uninstall_exception 57 | $(RM) -R $(INSTALL_INC) 58 | $(RM) $(INSTALL_LIB)/$(INTEGRAL_STATIC_LIB) $(INSTALL_LIB)/$(INTEGRAL_SHARED_LIB) 59 | 60 | clean: 61 | cd $(INTEGRAL_LIB_DIR) && $(MAKE) $@ 62 | cd $(INTEGRAL_BIN_DIR) && $(MAKE) $@ 63 | cd $(INTEGRAL_TEST_DIR) && $(MAKE) $@ 64 | -------------------------------------------------------------------------------- /lib/integral/utility.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // utility.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_utility_hpp 28 | #define integral_utility_hpp 29 | 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace integral { 39 | namespace utility { 40 | std::string getStackString(lua_State *luaState); 41 | 42 | int printStack(lua_State *luaState); 43 | 44 | // stack argument: table 45 | void setHelp(lua_State *luaState, const char *field, const char *fieldDescription); 46 | 47 | // stack argument: table | ? 48 | void setWithHelp(lua_State *luaState, const char *field, const char *fieldDescription); 49 | 50 | void pushNameAndValueList(lua_State *luaState, std::initializer_list> nameAndValueList); 51 | 52 | // stack argument: table 53 | void setNameAndValueListWithHelp(lua_State *luaState, const char *field, std::initializer_list> nameAndValueList); 54 | } 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /samples/core/error_handling/error_handling.lua: -------------------------------------------------------------------------------- 1 | -- 2 | -- error_handling.lua 3 | -- integral 4 | -- 5 | -- MIT License 6 | -- 7 | -- Copyright (c) 2014, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | -- 9 | -- Permission is hereby granted, free of charge, to any person obtaining a copy 10 | -- of this software and associated documentation files (the "Software"), to deal 11 | -- in the Software without restriction, including without limitation the rights 12 | -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | -- copies of the Software, and to permit persons to whom the Software is 14 | -- furnished to do so, subject to the following conditions: 15 | -- 16 | -- The above copyright notice and this permission notice shall be included in all 17 | -- copies or substantial portions of the Software. 18 | -- 19 | -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | -- SOFTWARE. 26 | 27 | -- MacOX specific shared library extension 28 | package.cpath = package.cpath .. ";?.dylib" 29 | 30 | local Object = require("libObject") 31 | 32 | local _, message = pcall(function() Object.new("prefix", 42) end) 33 | print("Constructor argument error message (1): ", message) 34 | local _, message = pcall(function() Object.new() end) 35 | print("Constructor argument error message (2): ", message) 36 | -- correct expression: 37 | local o1 = Object.new("o1_string") 38 | 39 | local _, message = pcall(function() o1.getString(42) end) 40 | print("Function argument error message (1): ", message) 41 | local _, message = pcall(function() o1:getString(42) end) 42 | print("Function argument error message (2): ", message) 43 | -- correct expression: 44 | o1:getString() 45 | 46 | local _, message = pcall(function() o1:createSuffixedObjectLuaFunction(o1) end) 47 | print("Lua Function argument error message: ", message) 48 | -- correct expression: 49 | o1:createSuffixedObjectLuaFunction("_suffix") 50 | 51 | local _, message = pcall(function() Object.throwCppException() end) 52 | print("Thrown exception message: ", message) 53 | -------------------------------------------------------------------------------- /samples/abstraction/error_message/error_message.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // error_message.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | int main() { 34 | try { 35 | const integral::State luaState; 36 | luaState.openLibs(); 37 | luaState["throwException"].setFunction( 38 | [] { 39 | throw std::runtime_error("exception!"); 40 | } 41 | ); 42 | try { 43 | luaState.doFile("sample.lua"); 44 | } catch (const integral::StateException &stateException) { 45 | std::cout << "expected exception: {" << stateException.what() << "}\n"; 46 | } 47 | try { 48 | luaState.doString("throwException()"); 49 | } catch (const integral::StateException &stateException) { 50 | std::cout << "expected exception: {" << stateException.what() << "}\n"; 51 | } 52 | return EXIT_SUCCESS; 53 | } catch (const std::exception &exception) { 54 | std::cerr << "[state] " << exception.what() << std::endl; 55 | } catch (...) { 56 | std::cerr << "unknown exception thrown" << std::endl; 57 | } 58 | return EXIT_FAILURE; 59 | } 60 | -------------------------------------------------------------------------------- /lib/integral/Global.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Global.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_Global_hpp 28 | #define integral_Global_hpp 29 | 30 | #include "GlobalBase.hpp" 31 | #include "ReferenceValue.hpp" 32 | 33 | namespace integral { 34 | class Global : public GlobalBase { 35 | public: 36 | using GlobalBase::push; 37 | 38 | template 39 | detail::ReferenceValue, Global> operator[](K &&key) &&; 40 | }; 41 | 42 | namespace detail::exchanger { 43 | template<> 44 | class Exchanger { 45 | public: 46 | inline static void push(lua_State *luaState, const Global &global); 47 | inline static void push(lua_State *luaState); 48 | }; 49 | } 50 | 51 | //-- 52 | 53 | template 54 | detail::ReferenceValue, Global> Global::operator[](K &&key) && { 55 | return {std::forward(key), std::move(*this)}; 56 | } 57 | 58 | namespace detail::exchanger { 59 | inline void Exchanger::push(lua_State *luaState, const Global &global) { 60 | global.push(luaState); 61 | } 62 | 63 | inline void Exchanger::push(lua_State *luaState) { 64 | Global().push(luaState); 65 | } 66 | } 67 | } 68 | 69 | #endif 70 | 71 | -------------------------------------------------------------------------------- /samples/core/embedded/embedded.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // embedded.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2013, 2014, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | class Object { 32 | public: 33 | void printMessage() const { 34 | std::cout << "Object " << this << " message!" << std::endl; 35 | } 36 | }; 37 | 38 | int main() { 39 | lua_State *luaState = nullptr; 40 | 41 | try { 42 | luaState = luaL_newstate(); 43 | if (luaState == nullptr) { 44 | return 1; 45 | } 46 | 47 | integral::pushClassMetatable(luaState); 48 | integral::setConstructor(luaState, "new"); 49 | // lua function name need not be the same as the C++ function name 50 | integral::setFunction(luaState, "print", &Object::printMessage); 51 | lua_setglobal(luaState, "Object"); 52 | 53 | luaL_dostring(luaState, "local object = Object.new()\n" 54 | "object:print()"); 55 | 56 | lua_close(luaState); 57 | return 0; 58 | } catch (const std::exception &exception) { 59 | std::cout << "[embedded sample] " << exception.what() << std::endl; 60 | } catch (...) { 61 | std::cout << "unknown exception thrown" << std::endl; 62 | } 63 | 64 | lua_close(luaState); 65 | return 1; 66 | } 67 | -------------------------------------------------------------------------------- /lib/integral/UnexpectedStackException.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // UnexpectedStackException.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_UnexpectedStackException_hpp 28 | #define integral_UnexpectedStackException_hpp 29 | 30 | #include 31 | #include 32 | #include "utility.hpp" 33 | 34 | namespace integral { 35 | class UnexpectedStackException : public exception::LogicException { 36 | public: 37 | template 38 | UnexpectedStackException(lua_State *luaState, const char *fileName, int lineNumber, const char *functionName, const A &...messageParts); 39 | 40 | ~UnexpectedStackException(); 41 | }; 42 | 43 | //-- 44 | 45 | template 46 | UnexpectedStackException::UnexpectedStackException( 47 | lua_State *luaState, 48 | const char *fileName, 49 | int lineNumber, 50 | const char *functionName, 51 | const A &...messageParts 52 | ) : 53 | ::exception::LogicException( 54 | fileName, 55 | lineNumber, 56 | functionName, 57 | "[integral] invalid Lua stack: ", 58 | messageParts..., 59 | ". lua stack: { ", 60 | utility::getStackString(luaState), 61 | " }" 62 | ) 63 | {} 64 | } 65 | 66 | #endif /* integral_UnexpectedStackException_hpp */ 67 | -------------------------------------------------------------------------------- /lib/integral/Table.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // Table.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_Table_hpp 28 | #define integral_Table_hpp 29 | 30 | #include 31 | #include 32 | #include 33 | #include "table_composite.hpp" 34 | #include "exchanger.hpp" 35 | 36 | namespace integral { 37 | class Table : public detail::table_composite::TableCompositeInterface { 38 | public: 39 | // non-copyable 40 | Table(const Table &) = delete; 41 | Table & operator=(const Table &) = delete; 42 | 43 | Table(Table &&) = default; 44 | Table() = default; 45 | }; 46 | 47 | namespace detail { 48 | namespace exchanger { 49 | template<> 50 | class Exchanger
{ 51 | public: 52 | inline static void push(lua_State *luaState); 53 | inline static void push(lua_State *luaState, const Table &); 54 | }; 55 | } 56 | } 57 | 58 | //-- 59 | 60 | namespace detail { 61 | namespace exchanger { 62 | inline void Exchanger
::push(lua_State *luaState) { 63 | lua_newtable(luaState); 64 | } 65 | 66 | inline void Exchanger
::push(lua_State *luaState, const Table &) { 67 | push(luaState); 68 | } 69 | } 70 | } 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /samples/core/showcase/otherlib/otherlib.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // otherlib.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2015, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | class DummyObject {}; 34 | 35 | extern "C" { 36 | LUALIB_API int luaopen_libotherlib(lua_State *luaState) { 37 | try { 38 | lua_newtable(luaState); 39 | // stack: table (module table) 40 | 41 | integral::setFunction(luaState, "getMessage", []() -> std::string { 42 | return "message from otherlib"; 43 | }); 44 | 45 | // DummyObject is automatically registered 46 | integral::setFunction(luaState, "getDummyObject", []() -> DummyObject { 47 | return DummyObject(); 48 | }); 49 | 50 | // Do not forget the return value (number of values to be returned from stack)! 51 | return 1; 52 | } catch (const std::exception &exception) { 53 | lua_pushstring(luaState, (std::string("[otherlib sample setup] ") + exception.what()).c_str()); 54 | } catch (...) { 55 | lua_pushstring(luaState, "[otherlib sample setup] unknown exception thrown"); 56 | } 57 | // Error return outside catch scope so that the exception destructor can be called 58 | return lua_error(luaState); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /common.mk: -------------------------------------------------------------------------------- 1 | INTEGRAL:=integral 2 | 3 | INTEGRAL_LIB_ROOT_DIR:=lib 4 | INTEGRAL_LIB_DIR:=$(INTEGRAL_LIB_ROOT_DIR)/$(INTEGRAL) 5 | INTEGRAL_BIN_DIR:=samples 6 | INTEGRAL_TEST_DIR:=test 7 | INTEGRAL_DEPENDENCIES_DIR:=dependencies 8 | INTEGRAL_STATIC_LIB:=lib$(INTEGRAL).a 9 | 10 | # INTEGRAL_ROOT_DIR is defined later. That's why = is used instead of := 11 | INTEGRAL_EXCEPTION_INCLUDE_DIR=$(INTEGRAL_ROOT_DIR)/$(INTEGRAL_DEPENDENCIES_DIR)/exception/include 12 | INTEGRAL_STATIC_LIB_INCLUDE_DIR=$(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_ROOT_DIR) 13 | INTEGRAL_STATIC_LIB_LDLIB=$(INTEGRAL_ROOT_DIR)/$(INTEGRAL_LIB_DIR)/$(INTEGRAL_STATIC_LIB) 14 | 15 | # LUA_LIB_DIR, LUA_INCLUDE_DIR and LUA_LDLIB may be changed here or in make invocation. E.g: make LUA_LIB_DIR=/path/to/lua/lib 16 | LUA_LIB_DIR:=/usr/local/lib 17 | 18 | ifeq ($(WITH_LUAJIT), y) 19 | LUA_INCLUDE_DIR:=/usr/local/include/luajit-2.0 20 | LUA_LDLIB:=-lluajit-5.1 21 | else ifeq ($(or $(WITH_LUAJIT), n), n) 22 | LUA_INCLUDE_DIR:=/usr/local/include 23 | LUA_LDLIB:=-llua 24 | else 25 | $(error Invalid parameter value) 26 | endif 27 | 28 | ifeq ($(OPTIMIZED), y) 29 | OPTIMIZATION_FLAGS:=-O3 -march=native -flto 30 | else ifeq ($(or $(OPTIMIZED), n), n) 31 | OPTIMIZATION_FLAGS:=-O0 -g 32 | else 33 | $(error Invalid parameter value) 34 | endif 35 | 36 | ifeq ($(SANITIZED), y) 37 | ifneq ($(OPTIMIZED), y) 38 | SANITIZE_FLAGS:=-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined 39 | else 40 | $(error Cannot have SANITIZED=y and OPTIMIZED=y) 41 | endif 42 | else ifneq ($(or $(SANITIZED), n), n) 43 | $(error Invalid parameter value) 44 | endif 45 | 46 | ifeq ($(WITH_FPIC), n) 47 | FPIC_FLAG:= 48 | else ifeq ($(or $(WITH_FPIC), y), y) 49 | FPIC_FLAG:=-fPIC 50 | else 51 | $(error Invalid parameter value) 52 | endif 53 | 54 | ifeq ($(shell uname -s), Darwin) 55 | SHARED_LIB_EXTENSION:=dylib 56 | # INTEGRAL_SHARED_LIB is defined later. That's why = is used instead of := 57 | INTEGRAL_DARWIN_SHARED_LDFLAGS=-undefined dynamic_lookup -install_name '@rpath/$(INTEGRAL_SHARED_LIB)' 58 | ifdef WITH_LUAJIT 59 | INTEGRAL_DARWIN_LUAJIT_EXECUTABLE_LDFLAGS:=-pagezero_size 10000 -image_base 100000000 60 | endif 61 | else 62 | SHARED_LIB_EXTENSION:=so 63 | endif 64 | 65 | INTEGRAL_SHARED_LIB:=lib$(INTEGRAL).$(SHARED_LIB_EXTENSION) 66 | 67 | INTEGRAL_CXXFLAGS:=$(EXTRA_CXXFLAGS) -std=c++17 -Werror -Wall -Wextra -Wshadow -Wnon-virtual-dtor -pedantic $(OPTIMIZATION_FLAGS) $(SANITIZE_FLAGS) $(FPIC_FLAG) 68 | 69 | INTEGRAL_COMMON_LDFLAGS:=$(EXTRA_LDFLAGS) $(OPTIMIZATION_FLAGS) $(SANITIZE_FLAGS) 70 | INTEGRAL_SHARED_LDFLAGS:=$(INTEGRAL_COMMON_LDFLAGS) -shared $(INTEGRAL_DARWIN_SHARED_LDFLAGS) 71 | INTEGRAL_EXECUTABLE_LDFLAGS:=$(INTEGRAL_COMMON_LDFLAGS) $(INTEGRAL_DARWIN_LUAJIT_EXECUTABLE_LDFLAGS) 72 | -------------------------------------------------------------------------------- /lib/integral/DefaultArgument.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultArgument.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_DefaultArgument_hpp 28 | #define integral_DefaultArgument_hpp 29 | 30 | #include 31 | #include 32 | #include "ArgumentTag.hpp" 33 | 34 | namespace integral { 35 | // "T": type of default argument 36 | // "I": lua index (starts with 1) of the default argument 37 | template 38 | class DefaultArgument { 39 | public: 40 | using ArgumentTag = detail::ArgumentTag; 41 | 42 | // Arguments are forwarded to typename T constructor 43 | template 44 | inline DefaultArgument(A &&...arguments); 45 | 46 | // Avoids template constructor ambiguity 47 | DefaultArgument(const DefaultArgument &) = default; 48 | DefaultArgument(DefaultArgument &) = default; 49 | DefaultArgument(DefaultArgument &&) = default; 50 | 51 | inline const T & getArgument() const; 52 | 53 | private: 54 | T argument_; 55 | }; 56 | 57 | //-- 58 | 59 | template 60 | template 61 | inline DefaultArgument::DefaultArgument(A &&...arguments) : argument_(std::forward(arguments)...) {} 62 | 63 | template 64 | inline const T & DefaultArgument::getArgument() const { 65 | return argument_; 66 | } 67 | 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /lib/integral/LuaIgnoredArgument.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // LuaIgnoredArgument.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_LuaIgnoredArgument_hpp 28 | #define integral_LuaIgnoredArgument_hpp 29 | 30 | #include 31 | #include "exchanger.hpp" 32 | 33 | namespace integral { 34 | namespace detail { 35 | class LuaIgnoredArgument { 36 | public: 37 | // non-copyable 38 | LuaIgnoredArgument(const LuaIgnoredArgument &) = delete; 39 | LuaIgnoredArgument & operator=(const LuaIgnoredArgument &) = delete; 40 | 41 | LuaIgnoredArgument(LuaIgnoredArgument &&) = default; 42 | LuaIgnoredArgument() = default; 43 | }; 44 | 45 | namespace exchanger { 46 | template<> 47 | class Exchanger { 48 | public: 49 | inline static LuaIgnoredArgument get(lua_State *luaState, int index); 50 | //Caution! A possible (not recommended) push method that pushes nothing onto the lua stack would require adaptations in the whole codebase because exchanger::push is (mostly) expected to push a single element on the stack 51 | }; 52 | } 53 | 54 | //-- 55 | 56 | namespace exchanger { 57 | inline LuaIgnoredArgument Exchanger::get(lua_State * /*luaState*/, int /*index*/) { 58 | return LuaIgnoredArgument(); 59 | } 60 | } 61 | } 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /samples/core/luafunction_argument/algorithm.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // algorithm.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | namespace { 36 | std::vector getTransformed(std::vector vectorCopy, const integral::LuaFunctionArgument &luaFunctionArgument) { 37 | // vectorCopy is a copy of the lua vector 38 | // the lua table argument is not modified 39 | std::for_each(vectorCopy.begin(), vectorCopy.end(), [&luaFunctionArgument](int &element) -> void { 40 | element = luaFunctionArgument.call(element); 41 | }); 42 | return vectorCopy; 43 | } 44 | } 45 | 46 | extern "C" { 47 | LUALIB_API int luaopen_libalgorithm(lua_State *luaState) { 48 | try { 49 | // module table 50 | lua_newtable(luaState); 51 | integral::setFunction(luaState, "getTransformed", getTransformed); 52 | return 1; 53 | } catch (const std::exception &exception) { 54 | lua_pushstring(luaState, (std::string("[luafunction_argument sample setup] ") + exception.what()).c_str()); 55 | } catch (...) { 56 | lua_pushstring(luaState, "[luafunction_argument sample setup] unknown exception thrown"); 57 | } 58 | // Error return outside catch scope so that the exception destructor can be called 59 | return lua_error(luaState); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/integral/ReferenceValue.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ReferenceValue.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_ReferenceValue_hpp 28 | #define integral_ReferenceValue_hpp 29 | 30 | #include "ReferenceBase.hpp" 31 | 32 | namespace integral::detail { 33 | template 34 | class ReferenceValue : public ReferenceBase> { 35 | public: 36 | template 37 | inline ReferenceValue(L &&key, D &&chainedReference); 38 | 39 | inline void push(lua_State *luaState) const; 40 | }; 41 | 42 | namespace exchanger { 43 | template 44 | class Exchanger> { 45 | public: 46 | inline static void push(lua_State *luaState, const ReferenceValue &referenceValue); 47 | }; 48 | } 49 | 50 | //-- 51 | 52 | template 53 | template 54 | inline ReferenceValue::ReferenceValue(L &&key, D &&chainedReference) : 55 | ReferenceBase>(std::forward(key), std::forward(chainedReference)) 56 | {} 57 | 58 | template 59 | inline void ReferenceValue::push(lua_State *luaState) const { 60 | ReferenceBase>::getChainedReference().push(luaState); 61 | ReferenceBase>::pushValueFromTable(luaState); 62 | } 63 | 64 | namespace exchanger { 65 | template 66 | inline void Exchanger>::push(lua_State *luaState, const ReferenceValue &referenceValue) { 67 | referenceValue.push(luaState); 68 | } 69 | } 70 | } 71 | 72 | #endif 73 | 74 | -------------------------------------------------------------------------------- /samples/core/ignored_argument/VectorOfDoubles.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // VectorOfDoubles.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2015, 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | extern "C" { 34 | LUALIB_API int luaopen_libVectorOfDoubles(lua_State *luaState) { 35 | try { 36 | // use std::vector as a regular object type using Adaptor 37 | using VectorOfDoubles = integral::Adaptor>; 38 | integral::pushClassMetatable(luaState); 39 | integral::setConstructor(luaState, "new"); 40 | // because of some legacy lua implementation details, __len receives two arguments, the second argument can be safely ignored 41 | integral::setFunction(luaState, "__len", [](const VectorOfDoubles &vector, integral::LuaIgnoredArgument) -> std::size_t { 42 | return vector.size(); 43 | }); 44 | // explicit cast is necessary to avoid ambiguity because std::vector::push_back is an overloaded function 45 | integral::setFunction(luaState, "pushBack", static_cast(&VectorOfDoubles::push_back)); 46 | return 1; 47 | } catch (const std::exception &exception) { 48 | lua_pushstring(luaState, (std::string("[ignored_argument sample setup] ") + exception.what()).c_str()); 49 | } catch (...) { 50 | lua_pushstring(luaState, "[ignored_argument sample setup] unknown exception thrown"); 51 | } 52 | // Error return outside catch scope so that the exception destructor can be called 53 | return lua_error(luaState); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /lib/integral/FunctorTraits.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // FunctorTraits.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2015, 2016, 2019, 2020, 2021 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_FunctorTraits_hpp 28 | #define integral_FunctorTraits_hpp 29 | 30 | #include 31 | #include "FunctionSignature.hpp" 32 | 33 | namespace integral { 34 | namespace detail { 35 | template 36 | class FunctorTraits : public FunctorTraits::operator())> {}; 37 | 38 | template 39 | class FunctorTraits : public FunctionSignature {}; 40 | 41 | template 42 | class FunctorTraits : public FunctionSignature {}; 43 | 44 | template 45 | class FunctorTraits : public FunctionSignature {}; 46 | 47 | template 48 | class FunctorTraits : public FunctionSignature {}; 49 | 50 | template 51 | class FunctorTraits : public FunctionSignature {}; 52 | 53 | template 54 | class FunctorTraits : public FunctionSignature {}; 55 | 56 | template 57 | class FunctorTraits : public FunctionSignature {}; 58 | 59 | template 60 | class FunctorTraits : public FunctionSignature {}; 61 | } 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /lib/integral/DefaultArgumentManagerContainer.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // DefaultArgumentManagerContainer.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2016, 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_DefaultArgumentManagerContainer_hpp 28 | #define integral_DefaultArgumentManagerContainer_hpp 29 | 30 | #include 31 | #include 32 | #include "argument.hpp" 33 | #include "DefaultArgumentManager.hpp" 34 | #include "IsTemplateClass.hpp" 35 | 36 | namespace integral { 37 | namespace detail { 38 | template 39 | class DefaultArgumentManagerContainer { 40 | static_assert(IsTemplateClass::value == true, "typename T in DefaultArgumentManagerContainer must be a DefaultArgumentManager"); 41 | public: 42 | template 43 | inline DefaultArgumentManagerContainer(DefaultArgument &&...defaultArguments); 44 | 45 | inline const T & getDefaultArgumentManager() const; 46 | 47 | private: 48 | T defaultArgumentManager_; 49 | }; 50 | 51 | //-- 52 | 53 | template 54 | template 55 | inline DefaultArgumentManagerContainer::DefaultArgumentManagerContainer(DefaultArgument &&...defaultArguments) : defaultArgumentManager_(std::move(defaultArguments)...) { 56 | argument::validateDefaultArguments(defaultArguments...); 57 | } 58 | 59 | template 60 | inline const T & DefaultArgumentManagerContainer::getDefaultArgumentManager() const { 61 | return defaultArgumentManager_; 62 | } 63 | } 64 | } 65 | 66 | #endif /* integral_DefaultArgumentManagerContainer_hpp */ 67 | -------------------------------------------------------------------------------- /lib/integral/ClassMetatable.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ClassMetatable.hpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2017, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #ifndef integral_ClassMetatable_hpp 28 | #define integral_ClassMetatable_hpp 29 | 30 | #include 31 | #include 32 | #include 33 | #include "class_composite.hpp" 34 | #include "exchanger.hpp" 35 | #include "generic.hpp" 36 | #include "type_manager.hpp" 37 | 38 | namespace integral { 39 | // T: class type 40 | template 41 | class ClassMetatable : public detail::class_composite::ClassCompositeInterface> { 42 | public: 43 | // non-copyable 44 | ClassMetatable(const ClassMetatable &) = delete; 45 | ClassMetatable & operator=(const ClassMetatable &) = delete; 46 | 47 | ClassMetatable(ClassMetatable &&) = default; 48 | ClassMetatable() = default; 49 | }; 50 | 51 | namespace detail { 52 | namespace exchanger { 53 | template 54 | class Exchanger> { 55 | public: 56 | inline static void push(lua_State *luaState); 57 | inline static void push(lua_State *luaState, const ClassMetatable &); 58 | }; 59 | } 60 | } 61 | 62 | //-- 63 | 64 | namespace detail { 65 | namespace exchanger { 66 | template 67 | inline void Exchanger>::push(lua_State *luaState) { 68 | type_manager::pushClassMetatable(luaState); 69 | } 70 | 71 | template 72 | inline void Exchanger>::push(lua_State *luaState, const ClassMetatable &) { 73 | push(luaState); 74 | } 75 | } 76 | } 77 | } 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /samples/core/reference_wrapper/reference_wrapper.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // reference_wrapper.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2014, 2015, 2016, 2017, 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class Object { 33 | public: 34 | void printMessage() const { 35 | std::cout << "Object " << this << " message!" << std::endl; 36 | } 37 | }; 38 | 39 | int main() { 40 | lua_State *luaState = nullptr; 41 | 42 | try { 43 | luaState = luaL_newstate(); 44 | if (luaState == nullptr) { 45 | return 1; 46 | } 47 | luaL_openlibs(luaState); 48 | 49 | integral::pushClassMetatable(luaState); 50 | integral::setFunction(luaState, "print", &Object::printMessage); 51 | 52 | lua_pop(luaState, 1); 53 | 54 | std::cout << "C++:" << std::endl; 55 | Object object; 56 | object.printMessage(); 57 | 58 | // std::reference_wrapper has automatic synthetic inheritance do T as if it was defined as: 59 | // integral::defineInheritance(luaState, [](std::reference_wrapper *referenceWrapperPointer) -> T * { 60 | // return &referenceWrapperPointer->get(); 61 | // }); 62 | integral::push>(luaState, object); 63 | lua_setglobal(luaState, "objectReference"); 64 | 65 | luaL_dostring(luaState, "print('lua:')\n" 66 | "objectReference:print()"); 67 | 68 | lua_close(luaState); 69 | return 0; 70 | } catch (const std::exception &exception) { 71 | std::cout << "[reference_wrapper sample] " << exception.what() << std::endl; 72 | } catch (...) { 73 | std::cout << "unknown exception thrown" << std::endl; 74 | } 75 | 76 | lua_close(luaState); 77 | return 1; 78 | } 79 | -------------------------------------------------------------------------------- /samples/abstraction/ignored_argument/ignored_argument.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // ignored_argument.cpp 3 | // integral 4 | // 5 | // MIT License 6 | // 7 | // Copyright (c) 2019, 2020 André Pereira Henriques (aphenriques (at) outlook (dot) com) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE. 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | // std::vector is automatically converted to a lua table. Vector is a regular class for integral and is not converted to a lua table 32 | class Vector : public std::vector {}; 33 | 34 | int main() { 35 | try { 36 | integral::State luaState; 37 | luaState.openLibs(); 38 | 39 | luaState["Vector"] = integral::ClassMetatable() 40 | .setConstructor("new") 41 | // because of some legacy lua implementation details, __len receives two arguments, the second argument can be safely ignored 42 | .setFunction("__len", [](const Vector &vector, integral::LuaIgnoredArgument) -> std::size_t { 43 | return vector.size(); 44 | }) 45 | // explicit cast is necessary to avoid ambiguity 46 | .setFunction("pushBack", static_cast(&Vector::push_back)); 47 | 48 | luaState.doString("v = Vector.new()\n" 49 | "print(#v)\n" // prints "0' 50 | "v:pushBack(42)\n" 51 | "print(#v)\n" // prints "1" 52 | "v:pushBack(42)\n" 53 | "print(#v)"); // prints "2" 54 | 55 | return EXIT_SUCCESS; 56 | } catch (const std::exception &exception) { 57 | std::cerr << "[ignored_argument] " << exception.what() << std::endl; 58 | } catch (...) { 59 | std::cerr << "unknown exception thrown" << std::endl; 60 | } 61 | return EXIT_FAILURE; 62 | } 63 | --------------------------------------------------------------------------------