├── .appveyor.yml ├── .editorconfig ├── .gitattributes ├── .gitignore ├── .travis.yml ├── CHANGELOG.md ├── CMakeLists.txt ├── CONTRIBUTING.md ├── COPYING.txt ├── INSTALL.txt ├── README.md ├── ci ├── build.sh └── lua_local.sh ├── cmake ├── Config.cmake ├── MacOSX.cmake ├── Modules │ └── FindPonder.cmake ├── PackageFilename.cmake ├── Packaging.cmake ├── PonderConfig.cmake.in ├── ponder.pc.in └── version.in ├── deps ├── lua-5.3 │ ├── CMakeLists.txt │ ├── Makefile │ ├── README │ ├── doc │ │ ├── contents.html │ │ ├── index.css │ │ ├── logo.gif │ │ ├── lua.1 │ │ ├── lua.css │ │ ├── luac.1 │ │ ├── manual.css │ │ ├── manual.html │ │ ├── osi-certified-72x60.png │ │ └── readme.html │ └── src │ │ ├── Makefile │ │ ├── lapi.c │ │ ├── lapi.h │ │ ├── lauxlib.c │ │ ├── lauxlib.h │ │ ├── lbaselib.c │ │ ├── lbitlib.c │ │ ├── lcode.c │ │ ├── lcode.h │ │ ├── lcorolib.c │ │ ├── lctype.c │ │ ├── lctype.h │ │ ├── ldblib.c │ │ ├── ldebug.c │ │ ├── ldebug.h │ │ ├── ldo.c │ │ ├── ldo.h │ │ ├── ldump.c │ │ ├── lfunc.c │ │ ├── lfunc.h │ │ ├── lgc.c │ │ ├── lgc.h │ │ ├── linit.c │ │ ├── liolib.c │ │ ├── llex.c │ │ ├── llex.h │ │ ├── llimits.h │ │ ├── lmathlib.c │ │ ├── lmem.c │ │ ├── lmem.h │ │ ├── loadlib.c │ │ ├── lobject.c │ │ ├── lobject.h │ │ ├── lopcodes.c │ │ ├── lopcodes.h │ │ ├── loslib.c │ │ ├── lparser.c │ │ ├── lparser.h │ │ ├── lprefix.h │ │ ├── lstate.c │ │ ├── lstate.h │ │ ├── lstring.c │ │ ├── lstring.h │ │ ├── lstrlib.c │ │ ├── ltable.c │ │ ├── ltable.h │ │ ├── ltablib.c │ │ ├── ltm.c │ │ ├── ltm.h │ │ ├── lua.c │ │ ├── lua.h │ │ ├── lua.hpp │ │ ├── luac.c │ │ ├── luaconf.h │ │ ├── lualib.h │ │ ├── lundump.c │ │ ├── lundump.h │ │ ├── lutf8lib.c │ │ ├── lvm.c │ │ ├── lvm.h │ │ ├── lzio.c │ │ └── lzio.h ├── rapidjson │ ├── include │ │ └── rapidjson │ │ │ ├── allocators.h │ │ │ ├── cursorstreamwrapper.h │ │ │ ├── document.h │ │ │ ├── encodedstream.h │ │ │ ├── encodings.h │ │ │ ├── error │ │ │ ├── en.h │ │ │ └── error.h │ │ │ ├── filereadstream.h │ │ │ ├── filewritestream.h │ │ │ ├── fwd.h │ │ │ ├── internal │ │ │ ├── biginteger.h │ │ │ ├── diyfp.h │ │ │ ├── dtoa.h │ │ │ ├── ieee754.h │ │ │ ├── itoa.h │ │ │ ├── meta.h │ │ │ ├── pow10.h │ │ │ ├── regex.h │ │ │ ├── stack.h │ │ │ ├── strfunc.h │ │ │ ├── strtod.h │ │ │ └── swap.h │ │ │ ├── istreamwrapper.h │ │ │ ├── memorybuffer.h │ │ │ ├── memorystream.h │ │ │ ├── msinttypes │ │ │ ├── inttypes.h │ │ │ └── stdint.h │ │ │ ├── ostreamwrapper.h │ │ │ ├── pointer.h │ │ │ ├── prettywriter.h │ │ │ ├── rapidjson.h │ │ │ ├── reader.h │ │ │ ├── schema.h │ │ │ ├── stream.h │ │ │ ├── stringbuffer.h │ │ │ └── writer.h │ ├── license.txt │ └── readme.md └── rapidxml │ ├── include │ └── rapidxml │ │ ├── rapidxml.hpp │ │ ├── rapidxml_iterators.hpp │ │ ├── rapidxml_print.hpp │ │ └── rapidxml_utils.hpp │ ├── license.txt │ └── manual.html ├── doc ├── CMakeLists.txt ├── api │ ├── Doxyfile.in │ ├── dox_style.css │ ├── footer.html │ ├── header.html │ ├── images │ │ ├── Lua-Logo-128.png │ │ └── ponder1.jpg │ └── pages │ │ ├── blog │ │ ├── 20160516-Ponder-1.hpp │ │ ├── 20160918-Ponder-2.hpp │ │ └── 20180908-Ponder-3.hpp │ │ ├── building.hpp │ │ ├── license.hpp │ │ └── mainpage.hpp ├── doxygen_cheatsheet.txt ├── mkdocs.sh ├── updocs.sh └── uplocaldocs.sh ├── include └── ponder │ ├── args.hpp │ ├── arraymapper.hpp │ ├── arrayproperty.hpp │ ├── class.hpp │ ├── class.inl │ ├── classbuilder.hpp │ ├── classbuilder.inl │ ├── classcast.hpp │ ├── classget.hpp │ ├── classget.inl │ ├── classvisitor.hpp │ ├── config.hpp │ ├── constructor.hpp │ ├── detail │ ├── arraypropertyimpl.hpp │ ├── arraypropertyimpl.inl │ ├── classmanager.hpp │ ├── constructorimpl.hpp │ ├── dictionary.hpp │ ├── enummanager.hpp │ ├── enumpropertyimpl.hpp │ ├── enumpropertyimpl.inl │ ├── functionimpl.hpp │ ├── functiontraits.hpp │ ├── getter.hpp │ ├── getter.inl │ ├── idtraits.hpp │ ├── issmartpointer.hpp │ ├── objectholder.hpp │ ├── objectholder.inl │ ├── objecttraits.hpp │ ├── observernotifier.hpp │ ├── propertyfactory.hpp │ ├── rawtype.hpp │ ├── simplepropertyimpl.hpp │ ├── simplepropertyimpl.inl │ ├── string_view.hpp │ ├── typeid.hpp │ ├── userpropertyimpl.hpp │ ├── userpropertyimpl.inl │ ├── util.hpp │ ├── valueimpl.hpp │ ├── valueprovider.hpp │ ├── valueref.hpp │ ├── variant.hpp │ └── variant_recursive_wrapper.hpp │ ├── enum.hpp │ ├── enum.inl │ ├── enumbuilder.hpp │ ├── enumget.hpp │ ├── enumget.inl │ ├── enumobject.hpp │ ├── enumobject.inl │ ├── enumproperty.hpp │ ├── error.hpp │ ├── error.inl │ ├── errors.hpp │ ├── function.hpp │ ├── observer.hpp │ ├── pondertype.hpp │ ├── property.hpp │ ├── qt │ ├── qlist.hpp │ ├── qstring.hpp │ ├── qt.hpp │ ├── qtfunction.hpp │ ├── qthelper.hpp │ ├── qtmapper.hpp │ ├── qtsimpleproperty.hpp │ └── qvector.hpp │ ├── simpleproperty.hpp │ ├── type.hpp │ ├── userdata.hpp │ ├── userobject.hpp │ ├── userobject.inl │ ├── userproperty.hpp │ ├── uses │ ├── archive │ │ ├── rapidjson.hpp │ │ └── rapidxml.hpp │ ├── detail │ │ ├── lua.hpp │ │ └── runtime.hpp │ ├── lua.hpp │ ├── runtime.hpp │ ├── serialise.hpp │ ├── serialise.inl │ └── uses.hpp │ ├── value.hpp │ ├── value.inl │ ├── valuemapper.hpp │ └── valuevisitor.hpp ├── src ├── args.cpp ├── arrayproperty.cpp ├── class.cpp ├── classcast.cpp ├── classmanager.cpp ├── classvisitor.cpp ├── enum.cpp ├── enumbuilder.cpp ├── enummanager.cpp ├── enumobject.cpp ├── enumproperty.cpp ├── error.cpp ├── errors.cpp ├── function.cpp ├── observer.cpp ├── observernotifier.cpp ├── pondertype.cpp ├── property.cpp ├── simpleproperty.cpp ├── userdata.cpp ├── userobject.cpp ├── userproperty.cpp ├── util.cpp └── value.cpp └── test ├── CMakeLists.txt ├── catch.hpp ├── examples ├── CMakeLists.txt ├── declare.cpp ├── inspect.cpp ├── main.cpp ├── serialise.cpp ├── shapes.cpp ├── simple.cpp ├── test.hpp └── userdata.cpp ├── lua ├── CMakeLists.txt └── main.cpp ├── ponder ├── CMakeLists.txt ├── arrayproperty.cpp ├── class.cpp ├── classvisitor.cpp ├── constructor.cpp ├── dictionary.cpp ├── enum.cpp ├── enumclass.cpp ├── enumclassobject.cpp ├── enumclassproperty.cpp ├── enumobject.cpp ├── enumproperty.cpp ├── function.cpp ├── inheritance.cpp ├── main.cpp ├── mapper.cpp ├── property.cpp ├── propertyaccess.cpp ├── serialise.cpp ├── string_view.cpp ├── tagholder.cpp ├── test.hpp ├── traits.cpp ├── userdata.cpp ├── userobject.cpp ├── userproperty.cpp └── value.cpp └── qt ├── CMakeLists.txt ├── functionmapping.cpp ├── functionmapping.hpp ├── main.cpp ├── propertymapping.cpp ├── propertymapping.hpp └── qstringmapping.cpp /.appveyor.yml: -------------------------------------------------------------------------------- 1 | 2 | version: 1.0.{build} 3 | shallow_clone: true 4 | 5 | image: 6 | - Visual Studio 2017 7 | - Visual Studio 2019 8 | 9 | environment: 10 | matrix: 11 | - ARCH: 32-bit 12 | VS17GEN: "Visual Studio 15 2017" 13 | VS19GEN: "Visual Studio 16 2019" 14 | VS19ARCH: "-A Win32" 15 | CMOPTS: "-DBUILD_TEST=ON -DBUILD_SHARED_LIBS=OFF" 16 | - ARCH: 64-bit 17 | VS17GEN: "Visual Studio 15 2017 Win64" 18 | VS19GEN: "Visual Studio 16 2019" 19 | VS19ARCH: "-A x64" 20 | CMOPTS: "-DBUILD_TEST=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_TEST_LUA=ON" 21 | 22 | build: 23 | parallel: true 24 | 25 | build_script: 26 | - cmd: | 27 | echo "image:%APPVEYOR_BUILD_WORKER_IMAGE%. arch:%ARCH%." 28 | cmake --version 29 | mkdir build 30 | cd build 31 | if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" cmake -G "%VS17GEN%" %CMOPTS% .. 32 | if "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" cmake -G "%VS19GEN%" %VS19ARCH% %CMOPTS% .. 33 | cmake --build . --config Debug 34 | cmake --build . --config Release 35 | 36 | test_script: 37 | - cmd: | 38 | cd test 39 | ctest -C Debug -V 40 | ctest -C Release -V 41 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Configuration file for EditorConfig 2 | # More information is available under http://EditorConfig.org 3 | 4 | # Ignore any other files further up in the file system 5 | root = true 6 | 7 | # Configuration for all files 8 | [*] 9 | insert_final_newline = true 10 | indent_style = space 11 | indent_size = 4 12 | trim_trailing_whitespace = true 13 | guidelines = 120 14 | guidelines_style = 1px dashed 808080 15 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | *.hpp text 4 | *.inl text 5 | *.cpp text 6 | *.doxy text 7 | *.html text 8 | *.css text 9 | *.in text 10 | *.txt text 11 | *.cmake text 12 | *.sh text eol=lf 13 | 14 | *.png binary 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | build*/ 3 | 4 | # Text editors temporary files 5 | *~ 6 | .~* 7 | ~* 8 | *.swp 9 | Thumbs.db 10 | 11 | # End products 12 | *.lib 13 | *.dll 14 | *.dylib 15 | *.o 16 | *.a 17 | *.1 18 | include/ponder/version.hpp 19 | test/Debug 20 | test/Release 21 | 22 | deps/lua-*/install 23 | deps/lua-*/src/lua 24 | deps/lua-*/src/luac 25 | bd_*/ 26 | 27 | # Auto-generated documentation files 28 | doc/egs 29 | doc/api/pages/_* 30 | *.doxy 31 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | dist: bionic 4 | 5 | jobs: 6 | include: 7 | - os: osx 8 | osx_image: xcode9.2 # OS X 10.12 (oldest Xcode/macOS we support) 9 | - os: osx 10 | osx_image: xcode12 # OS X 10.15.5 11 | - os: linux # see dist above 12 | compiler: clang 13 | - os: linux 14 | compiler: gcc 15 | 16 | install: 17 | - echo Lang:$LANG. OS:$TRAVIS_OS_NAME. CC:$CC. 18 | - uname -a 19 | - | 20 | # if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 21 | # brew update 22 | # if [ -z `brew list | grep cmake` ]; then brew install cmake; fi 23 | # brew outdated cmake || brew upgrade cmake 24 | # if [ -z `which ninja` ]; then brew install ninja; fi 25 | # fi 26 | - | 27 | # if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 28 | # sudo apt-get -qq update 29 | # sudo apt-get install -y libc++-dev cmake ninja 30 | # fi 31 | 32 | script: 33 | - ./ci/build.sh 34 | 35 | notifications: 36 | email: false 37 | 38 | 39 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | Contributing 3 | ------------ 4 | 5 | Hi, if you have found a bug, or would like to comment or extend an example then you will find this 6 | document useful. 7 | 8 | 9 | ### Reporting bugs 10 | 11 | Obviously, please try and read the [documentation][doc], and examples first. If you are getting 12 | unexpected behaviour then please visit the [issues][i] page. Check existing issues first, and if 13 | you can't find your problem, open a new issue. Code samples very welcome when describing bugs. 14 | 15 | 16 | ### Submitting code 17 | 18 | I'm largely following the [gitflow][gf] workflow. 19 | 20 | Tips & rules: 21 | 22 | - It is best to open an issue and discuss the change before making it. This will act as 23 | partial documentation for the change. 24 | - It would be appreciated if you could patch the `develop` branch; your changes may need testing, 25 | refactoring, or documentation, before being released. Your bug may also be fixed there. 26 | - If you are going a *pull request* then please create a feature branch before committing your 27 | changes. 28 | - All the tests need to pass before anything is pulled. You'll be able to see this in 29 | you PR. There are tests for Linux, MacOS, and Windows. All need to pass. 30 | 31 | Thanks, 32 | BQ 33 | 34 | 35 | [doc]: https://billyquith.github.io/ponder/ 36 | [i]: https://github.com/billyquith/ponder/issues 37 | [gf]: https://nvie.com/posts/a-successful-git-branching-model/ 38 | -------------------------------------------------------------------------------- /COPYING.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 2 | Contact: Tegesoft Information (contact@tegesoft.com) 3 | 4 | This file is part of the Ponder library, formerly CAMP. 5 | 6 | The MIT License (MIT) 7 | 8 | Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 9 | Copyright (C) 2015-2020 Nick Trout. 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in 19 | all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | -------------------------------------------------------------------------------- /INSTALL.txt: -------------------------------------------------------------------------------- 1 | 2 | Building Ponder 3 | --------------- 4 | 5 | The build system used for Ponder is CMake (http://cmake.org/). 6 | 7 | Once you have generated the project files / makefiles for your favorite compiler 8 | (please refer to http://cmake.org/ if you do not know how to do it), 9 | you can use them to compile the Ponder binaries. 10 | 11 | The following targets are defined: 12 | 13 | (empty) 14 | builds everything 15 | 16 | ponder 17 | builds the Ponder library 18 | 19 | pondertest 20 | builds the Ponder unit tests 21 | 22 | doc 23 | generates the API documentation in HTML format; on Windows, if the HTML Help Workshop program 24 | is available, the CHM documentation is generated as well; requires doxygen to be installed 25 | 26 | install 27 | installs all the generated components to the standard path 28 | 29 | 30 | Installing Ponder 31 | ----------------- 32 | 33 | There are three ways to install Ponder: 34 | - Running the installer (on Windows and Mac OS X) and following the instructions 35 | - Uncompressing the binary archive to a standard path (C:\Program Files, /usr/local/, ...) 36 | - Using CMake and calling the "install" target (see above) 37 | 38 | This will create the following directories: 39 | - /bin contains the Ponder binary files 40 | - /doc contains the API documentation 41 | - /include contains the Ponder header files 42 | - /lib contains the Ponder library files 43 | - /utils contains various utilities related to Ponder 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Ponder 3 | ------ 4 | 5 | Linux & OSX: [![Build Status](https://travis-ci.org/billyquith/ponder.svg?branch=master)](https://travis-ci.org/billyquith/ponder) - 6 | Windows: [![Build status](https://ci.appveyor.com/api/projects/status/spskn9y93e8osve2/branch/master?svg=true)](https://ci.appveyor.com/project/billyquith/ponder/branch/master) 7 | 8 | Currents status: 3.2-alpha. API is unstable as features added/changed. 9 | 10 | ### New: Version 3 11 | 12 | V1 replaced Boost with C++11. V2 added Lua bindings. V3 refactored to remove some warts, 13 | ease future development, and re-add serialisation. API is evolving. 14 | 15 | ### About 16 | 17 | Ponder is a C++ multi-purpose reflection library. It provides an abstraction for most 18 | of the high-level concepts of C++: classes, enumerations, functions, properties. 19 | 20 | C++1x supplies better support for compile-time reflection. Runtime reflection involves 21 | baking compile-time reflection into the executable so this can be used at runtime. Ponder 22 | presents a simple API for baking your objects so that they can be used at runtime. The baking 23 | can also, optionally, userdata and support for Lua scripting. 24 | 25 | Features: 26 | 27 | - API to expose C++ objects. 28 | - Runtime API to create objects, call functions, and read and modify properties. 29 | - Automatic Lua binding generation. 30 | 31 | ### Links 32 | 33 | - [Homepage & documentation](http://billyquith.github.io/ponder/). 34 | - [GitHub project](https://github.com/billyquith/ponder). 35 | - [Release notes][rel]. 36 | - [Maintainer blog](https://chinbilly.blogspot.com/search/label/ponder) 37 | 38 | ### Build 39 | 40 | Compilers supported. [Requires C++17][compsupp]. 41 | 42 | - MSVC 2017+ 43 | - Xcode 8+ 44 | - GCC 7+ 45 | - Clang 3.9+ 46 | 47 | Ponder uses CMake to generate project files which are then used to build the project ([Build 48 | docs][build]). E.g. Use `make` to build Ponder (but you can use any build system CMake supports): 49 | 50 | ```bash 51 | git clone https://github.com/billyquith/ponder.git 52 | cd ponder 53 | mkdir build && cd build 54 | cmake -G "Unix Makefiles" .. 55 | make 56 | ``` 57 | 58 | ### Package Managers 59 | 60 | Windows [vcpkg][vcpkg]: 61 | 62 | vcpkg install ponder 63 | 64 | ### History 65 | 66 | Ponder is a fork of [CAMP][camp], which has been retired by the original authors. CAMP relies 67 | on Boost, and is pre-C++11. In Ponder, the Boost dependency has been removed, and instead, 68 | C++11 features are used. CAMP was developed by Technogerma Systems France and then by [Tegesoft][tege]. 69 | 70 | See [CHANGELOG.md](CHANGELOG.md) and [release notes][rel] for more details on Ponder changes. 71 | 72 | [rel]: https://billyquith.github.io/ponder/blog_ponder_3.html 73 | [cl]: https://github.com/billyquith/ponder/CHANGELOG.md 74 | [build]: https://billyquith.github.io/ponder/building_ponder.html 75 | [tege]: http://www.tegesoft.com 76 | [camp]: https://github.com/tegesoft/camp 77 | [vcpkg]: https://docs.microsoft.com/en-us/cpp/build/vcpkg?view=msvc-160 78 | [compsupp]: https://en.cppreference.com/w/cpp/compiler_support 79 | -------------------------------------------------------------------------------- /ci/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | case `uname -s` in 4 | Darwin) 5 | if [ ! -z `which ninja` ]; then 6 | GEN=Ninja; 7 | else 8 | GEN=Xcode; 9 | BUILDARGS="-- -quiet"; # otherwise xcodebuild very verbose 10 | fi 11 | ;; 12 | Linux) 13 | #if [ ! -z `which ninja` ]; then GEN=Ninja; else GEN="Unix Makefiles"; fi 14 | GEN="Unix Makefiles" 15 | ;; 16 | esac 17 | 18 | cmake --version 19 | 20 | function proj # opts 21 | { 22 | [[ -d $BDIR ]] || mkdir $BDIR 23 | cd $BDIR 24 | if ! cmake .. -G"$GEN" $1; then exit 1; fi 25 | } 26 | 27 | function build_test # configs 28 | { 29 | for cfg in $1 30 | do 31 | echo "Build and testing config: $cfg" 32 | if ! cmake --build . --config $cfg $BUILDARGS; then exit 1; fi 33 | if ! ctest -C $cfg -V; then exit 1; fi 34 | done 35 | cd .. 36 | } 37 | 38 | function run # dirname, configs, opts 39 | { 40 | BDIR=bd_$1 41 | proj "$3" 42 | build_test "$2" 43 | } 44 | 45 | run static "Debug" "-DBUILD_SHARED_LIBS=OFF" 46 | #run shared "Debug Release" "-DBUILD_SHARED_LIBS=ON" 47 | 48 | run static_lua "Release" "-DBUILD_SHARED_LIBS=OFF -DUSES_LUA=ON -DBUILD_TEST_LUA=ON" 49 | #run shared_lua "Debug Release" "-DBUILD_SHARED_LIBS=ON -DUSES_LUA=ON -DBUILD_TEST_LUA=ON" 50 | -------------------------------------------------------------------------------- /ci/lua_local.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Run from project root 3 | 4 | cd deps 5 | 6 | # curl -R -O http://www.lua.org/ftp/lua-5.3.4.tar.gz 7 | # tar zxf lua-5.3.4.tar.gz 8 | cd lua-5.3 9 | 10 | case `uname -s` in 11 | Darwin) make macosx install INSTALL_TOP=../..;; 12 | Linux) make linux install INSTALL_TOP=../..;; 13 | *) echo "Unhandled OS"; exit 1;; 14 | esac 15 | -------------------------------------------------------------------------------- /cmake/Config.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Set the default build type to release with debug info 3 | if(NOT CMAKE_BUILD_TYPE) 4 | set(CMAKE_BUILD_TYPE RelWithDebInfo 5 | CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." 6 | ) 7 | endif() 8 | 9 | # Add an option for choosing the build type (shared or static) 10 | if(NOT BUILD_SHARED_LIBS) 11 | set(BUILD_SHARED_LIBS FALSE 12 | CACHE BOOL "TRUE to build Ponder as a shared library, FALSE to build it as a static library." 13 | ) 14 | endif() 15 | 16 | # Set the default test build option to false 17 | if(NOT BUILD_TEST) 18 | set(BUILD_TEST TRUE 19 | CACHE BOOL "TRUE to build the unit tests, FALSE otherwise." 20 | ) 21 | endif() 22 | 23 | if(NOT BUILD_TEST_EXAMPLES) 24 | set(BUILD_TEST_EXAMPLES TRUE 25 | CACHE BOOL "TRUE to build the example tests, FALSE otherwise." 26 | ) 27 | endif() 28 | 29 | if(NOT BUILD_TEST_LUA) 30 | set(BUILD_TEST_LUA FALSE 31 | CACHE BOOL "TRUE to build the Lua-specific tests (requires Lua), FALSE otherwise." 32 | ) 33 | endif() 34 | 35 | if(NOT BUILD_TEST_QT) 36 | set(BUILD_TEST_QT FALSE 37 | CACHE BOOL "TRUE to build the Qt-specific unit tests (requires Qt 4.5), FALSE otherwise." 38 | ) 39 | endif() 40 | 41 | if(NOT USES_LUA) 42 | set(USES_LUA ${BUILD_TEST_LUA} 43 | CACHE BOOL "TRUE to include Lua support (requires Lua), FALSE otherwise." 44 | ) 45 | endif() 46 | 47 | if(NOT USES_RAPIDJSON) 48 | set(USES_RAPIDJSON TRUE 49 | CACHE BOOL "TRUE to include RapidJSON support, FALSE otherwise." 50 | ) 51 | endif() 52 | 53 | if(NOT USES_RAPIDXML) 54 | set(USES_RAPIDXML TRUE 55 | CACHE BOOL "TRUE to include RapidXML support, FALSE otherwise." 56 | ) 57 | endif() 58 | 59 | # define install directory for miscelleneous files 60 | if(WIN32 AND NOT UNIX) 61 | set(INSTALL_MISC_DIR .) 62 | elseif(UNIX) 63 | set(INSTALL_MISC_DIR share/ponder) 64 | endif() 65 | 66 | # setup MacOSX build environment if necessary 67 | include(${PONDER_SOURCE_DIR}/cmake/MacOSX.cmake) 68 | 69 | set(PONDER_LUA_VERSION lua-5.3) 70 | -------------------------------------------------------------------------------- /cmake/Modules/FindPonder.cmake: -------------------------------------------------------------------------------- 1 | # Locate Ponder library 2 | # This module defines 3 | # PONDER_FOUND, if false, do not try to link to Ponder 4 | # PONDER_LIBRARIES 5 | # PONDER_INCLUDE_DIR, where to find ponder/version.hpp 6 | 7 | FIND_PATH(PONDER_INCLUDE_DIR ponder/version.hpp 8 | HINTS 9 | $ENV{PONDER_DIR} 10 | PATH_SUFFIXES include 11 | PATHS 12 | ~/Library/Frameworks 13 | /Library/Frameworks 14 | /usr/local 15 | /usr 16 | /sw # Fink 17 | /opt/local # DarwinPorts 18 | /opt/csw # Blastwave 19 | /opt 20 | ) 21 | 22 | FIND_LIBRARY(PONDER_LIBRARY 23 | NAMES ponder 24 | HINTS 25 | $ENV{PONDER_DIR} 26 | PATH_SUFFIXES lib64 lib 27 | PATHS 28 | ~/Library/Frameworks 29 | /Library/Frameworks 30 | /usr/local 31 | /usr 32 | /sw 33 | /opt/local 34 | /opt/csw 35 | /opt 36 | ) 37 | 38 | SET(PONDER_LIBRARIES "${PONDER_LIBRARY}" CACHE STRING "Ponder Libraries") 39 | 40 | INCLUDE(FindPackageHandleStandardArgs) 41 | # handle the QUIETLY and REQUIRED arguments and set PONDER_FOUND to TRUE if 42 | # all listed variables are TRUE 43 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(PONDER DEFAULT_MSG PONDER_LIBRARIES PONDER_INCLUDE_DIR) 44 | 45 | MARK_AS_ADVANCED(PONDER_INCLUDE_DIR PONDER_LIBRARIES PONDER_LIBRARY) 46 | 47 | -------------------------------------------------------------------------------- /cmake/PonderConfig.cmake.in: -------------------------------------------------------------------------------- 1 | set(PONDER_VERSION "@PONDER_VERSION_STR@") 2 | 3 | @PACKAGE_INIT@ 4 | 5 | set_and_check(PONDER_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include") 6 | 7 | include("${CMAKE_CURRENT_LIST_DIR}/PonderTargets.cmake") 8 | 9 | # Convenience variables following find_package conventions for modules 10 | set(PONDER_INCLUDE_DIRS "${PONDER_INCLUDE_DIR}") 11 | set(PONDER_LIBRARIES ponder::ponder) 12 | 13 | -------------------------------------------------------------------------------- /cmake/ponder.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | includedir=${prefix}/include 3 | libdir=${prefix}/lib 4 | 5 | Name: ponder 6 | Description: Ponder is a multi-purpose reflection library for C++ 7 | Version: @PONDER_VERSION_STR@ 8 | CFlags: -I${includedir} 9 | Libs: -L${libdir} -lponder 10 | -------------------------------------------------------------------------------- /cmake/version.in: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 4 | ** Contact: Tegesoft Information (contact@tegesoft.com) 5 | ** 6 | ** This file is part of the CAMP library. 7 | ** 8 | ** The MIT License (MIT) 9 | ** 10 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 11 | ** Copyright (C) 2015-2020 Nick Trout. 12 | ** 13 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 14 | ** of this software and associated documentation files (the "Software"), to deal 15 | ** in the Software without restriction, including without limitation the rights 16 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | ** copies of the Software, and to permit persons to whom the Software is 18 | ** furnished to do so, subject to the following conditions: 19 | ** 20 | ** The above copyright notice and this permission notice shall be included in 21 | ** all copies or substantial portions of the Software. 22 | ** 23 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | ** THE SOFTWARE. 30 | ** 31 | ****************************************************************************/ 32 | 33 | 34 | #ifndef PONDER_VERSION_HPP 35 | #define PONDER_VERSION_HPP 36 | 37 | // Define the version of CAMP. 38 | // If the version is x.y.z, then PONDER_VERSION is the integer (x*1000000 + y*1000 + z). 39 | // PONDER_VERSION_STR is the string representation of the version. 40 | #define PONDER_VERSION ((@VERSION_MAJOR@)*1000000 + (@VERSION_MINOR@)*1000 + (@VERSION_PATCH@)) 41 | #define PONDER_VERSION_STR "@PONDER_VERSION_STR@" 42 | 43 | #endif // PONDER_VERSION_HPP 44 | 45 | -------------------------------------------------------------------------------- /deps/lua-5.3/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | #project(lua C) 3 | #cmake_minimum_required(VERSION 3.4) 4 | 5 | if(NOT UNIX) 6 | 7 | include_directories(src ${CMAKE_CURRENT_BINARY_DIR}) 8 | 9 | set(SRC_LUA 10 | src/lapi.c 11 | src/lcode.c 12 | src/lctype.c 13 | src/ldebug.c 14 | src/ldo.c 15 | src/ldump.c 16 | src/lfunc.c 17 | src/lgc.c 18 | src/llex.c 19 | src/lmem.c 20 | src/lobject.c 21 | src/lopcodes.c 22 | src/lparser.c 23 | src/lstate.c 24 | src/lstring.c 25 | src/ltable.c 26 | src/ltm.c 27 | src/lundump.c 28 | src/lvm.c 29 | src/lzio.c) 30 | 31 | set(SRC_LIB 32 | src/lauxlib.c 33 | src/lbaselib.c 34 | src/lbitlib.c 35 | src/lcorolib.c 36 | src/ldblib.c 37 | src/liolib.c 38 | src/lmathlib.c 39 | src/loslib.c 40 | src/lstrlib.c 41 | src/ltablib.c 42 | src/lutf8lib.c 43 | src/loadlib.c 44 | src/linit.c) 45 | 46 | add_library(liblua ${SRC_LUA} ${SRC_LIB}) 47 | 48 | # add_library(libluadll SHARED ${SRC_LUA} ${SRC_LIB}) 49 | # target_compile_definitions(libluadll PRIVATE _CRT_SECURE_NO_WARNINGS LUA_BUILD_AS_DLL) 50 | # set_target_properties(libluadll PROPERTIES OUTPUT_NAME lua53) 51 | 52 | add_executable(lua src/lua.c) 53 | target_link_libraries(lua liblua ${LINK_LIBS}) 54 | 55 | add_executable(luac src/luac.c) 56 | target_link_libraries(luac liblua ${LINK_LIBS}) 57 | 58 | endif(NOT UNIX) 59 | -------------------------------------------------------------------------------- /deps/lua-5.3/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.3.4, released on 12 Jan 2017. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /deps/lua-5.3/doc/index.css: -------------------------------------------------------------------------------- 1 | ul { 2 | list-style-type: none ; 3 | } 4 | 5 | ul.contents { 6 | padding: 0 ; 7 | } 8 | 9 | table { 10 | border: none ; 11 | border-spacing: 0 ; 12 | border-collapse: collapse ; 13 | } 14 | 15 | td { 16 | vertical-align: top ; 17 | padding: 0 ; 18 | text-align: left ; 19 | line-height: 1.25 ; 20 | width: 15% ; 21 | } 22 | -------------------------------------------------------------------------------- /deps/lua-5.3/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/billyquith/ponder/aff8843efa8069b272bad49df2d820a9b4d88171/deps/lua-5.3/doc/logo.gif -------------------------------------------------------------------------------- /deps/lua-5.3/doc/lua.1: -------------------------------------------------------------------------------- 1 | .\" $Id: lua.man,v 1.14 2016/10/17 15:43:50 lhf Exp $ 2 | .TH LUA 1 "$Date: 2016/10/17 15:43:50 $" 3 | .SH NAME 4 | lua \- Lua interpreter 5 | .SH SYNOPSIS 6 | .B lua 7 | [ 8 | .I options 9 | ] 10 | [ 11 | .I script 12 | [ 13 | .I args 14 | ] 15 | ] 16 | .SH DESCRIPTION 17 | .B lua 18 | is the standalone Lua interpreter. 19 | It loads and executes Lua programs, 20 | either in textual source form or 21 | in precompiled binary form. 22 | (Precompiled binaries are output by 23 | .BR luac , 24 | the Lua compiler.) 25 | .B lua 26 | can be used as a batch interpreter and also interactively. 27 | .LP 28 | The given 29 | .I options 30 | are handled in order and then 31 | the Lua program in file 32 | .I script 33 | is loaded and executed. 34 | The given 35 | .I args 36 | are available to 37 | .I script 38 | as strings in a global table named 39 | .BR arg . 40 | If no options or arguments are given, 41 | then 42 | .B "\-v \-i" 43 | is assumed when the standard input is a terminal; 44 | otherwise, 45 | .B "\-" 46 | is assumed. 47 | .LP 48 | In interactive mode, 49 | .B lua 50 | prompts the user, 51 | reads lines from the standard input, 52 | and executes them as they are read. 53 | If the line contains an expression or list of expressions, 54 | then the line is evaluated and the results are printed. 55 | If a line does not contain a complete statement, 56 | then a secondary prompt is displayed and 57 | lines are read until a complete statement is formed or 58 | a syntax error is found. 59 | .LP 60 | At the very start, 61 | before even handling the command line, 62 | .B lua 63 | checks the contents of the environment variables 64 | .B LUA_INIT_5_3 65 | or 66 | .BR LUA_INIT , 67 | in that order. 68 | If the contents is of the form 69 | .RI '@ filename ', 70 | then 71 | .I filename 72 | is executed. 73 | Otherwise, the string is assumed to be a Lua statement and is executed. 74 | .SH OPTIONS 75 | .TP 76 | .BI \-e " stat" 77 | execute statement 78 | .IR stat . 79 | .TP 80 | .B \-i 81 | enter interactive mode after executing 82 | .IR script . 83 | .TP 84 | .BI \-l " name" 85 | execute the equivalent of 86 | .IB name =require(' name ') 87 | before executing 88 | .IR script . 89 | .TP 90 | .B \-v 91 | show version information. 92 | .TP 93 | .B \-E 94 | ignore environment variables. 95 | .TP 96 | .B \-\- 97 | stop handling options. 98 | .TP 99 | .B \- 100 | stop handling options and execute the standard input as a file. 101 | .SH "SEE ALSO" 102 | .BR luac (1) 103 | .br 104 | The documentation at lua.org, 105 | especially section 7 of the reference manual. 106 | .SH DIAGNOSTICS 107 | Error messages should be self explanatory. 108 | .SH AUTHORS 109 | R. Ierusalimschy, 110 | L. H. de Figueiredo, 111 | W. Celes 112 | .\" EOF 113 | -------------------------------------------------------------------------------- /deps/lua-5.3/doc/lua.css: -------------------------------------------------------------------------------- 1 | html { 2 | background-color: #F8F8F8 ; 3 | } 4 | 5 | body { 6 | background-color: #FFFFFF ; 7 | color: #000000 ; 8 | font-family: Helvetica, Arial, sans-serif ; 9 | text-align: justify ; 10 | line-height: 1.25 ; 11 | margin: 16px auto ; 12 | padding: 32px ; 13 | border: solid #a0a0a0 1px ; 14 | border-radius: 20px ; 15 | max-width: 70em ; 16 | width: 90% ; 17 | } 18 | 19 | h1, h2, h3, h4 { 20 | color: #000080 ; 21 | font-family: Verdana, Geneva, sans-serif ; 22 | font-weight: normal ; 23 | font-style: normal ; 24 | text-align: left ; 25 | } 26 | 27 | h1 { 28 | font-size: 28pt ; 29 | } 30 | 31 | h1 img { 32 | vertical-align: text-bottom ; 33 | } 34 | 35 | h2:before { 36 | content: "\2756" ; 37 | padding-right: 0.5em ; 38 | } 39 | 40 | a { 41 | text-decoration: none ; 42 | } 43 | 44 | a:link { 45 | color: #000080 ; 46 | } 47 | 48 | a:link:hover, a:visited:hover { 49 | background-color: #D0D0FF ; 50 | color: #000080 ; 51 | border-radius: 4px ; 52 | } 53 | 54 | a:link:active, a:visited:active { 55 | color: #FF0000 ; 56 | } 57 | 58 | div.menubar { 59 | padding-bottom: 0.5em ; 60 | } 61 | 62 | p.menubar { 63 | margin-left: 2.5em ; 64 | } 65 | 66 | .menubar a:hover { 67 | margin: -3px -3px -3px -3px ; 68 | padding: 3px 3px 3px 3px ; 69 | border-radius: 4px ; 70 | } 71 | 72 | :target { 73 | background-color: #F0F0F0 ; 74 | margin: -8px ; 75 | padding: 8px ; 76 | border-radius: 8px ; 77 | outline: none ; 78 | } 79 | 80 | hr { 81 | display: none ; 82 | } 83 | 84 | table hr { 85 | background-color: #a0a0a0 ; 86 | color: #a0a0a0 ; 87 | border: 0 ; 88 | height: 1px ; 89 | display: block ; 90 | } 91 | 92 | .footer { 93 | color: gray ; 94 | font-size: x-small ; 95 | text-transform: lowercase ; 96 | } 97 | 98 | input[type=text] { 99 | border: solid #a0a0a0 2px ; 100 | border-radius: 2em ; 101 | background-image: url('images/search.png') ; 102 | background-repeat: no-repeat ; 103 | background-position: 4px center ; 104 | padding-left: 20px ; 105 | height: 2em ; 106 | } 107 | 108 | pre.session { 109 | background-color: #F8F8F8 ; 110 | padding: 1em ; 111 | border-radius: 8px ; 112 | } 113 | 114 | td.gutter { 115 | width: 4% ; 116 | } 117 | 118 | table.columns { 119 | border: none ; 120 | border-spacing: 0 ; 121 | border-collapse: collapse ; 122 | } 123 | 124 | table.columns td { 125 | vertical-align: top ; 126 | padding: 0 ; 127 | padding-bottom: 1em ; 128 | text-align: justify ; 129 | line-height: 1.25 ; 130 | } 131 | 132 | p.logos a:link:hover, p.logos a:visited:hover { 133 | background-color: inherit ; 134 | } 135 | 136 | table.book { 137 | border: none ; 138 | border-spacing: 0 ; 139 | border-collapse: collapse ; 140 | } 141 | 142 | table.book td { 143 | padding: 0 ; 144 | vertical-align: top ; 145 | } 146 | 147 | table.book td.cover { 148 | padding-right: 1em ; 149 | } 150 | 151 | table.book img { 152 | border: solid #000080 1px ; 153 | } 154 | 155 | table.book span { 156 | font-size: small ; 157 | text-align: left ; 158 | display: block ; 159 | margin-top: 0.25em ; 160 | } 161 | 162 | img { 163 | background-color: white ; 164 | } 165 | -------------------------------------------------------------------------------- /deps/lua-5.3/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | color: gray ; 12 | float: right ; 13 | font-family: inherit ; 14 | font-style: normal ; 15 | font-size: small ; 16 | } 17 | 18 | h2:before { 19 | content: "" ; 20 | padding-right: 0em ; 21 | } 22 | -------------------------------------------------------------------------------- /deps/lua-5.3/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/billyquith/ponder/aff8843efa8069b272bad49df2d820a9b4d88171/deps/lua-5.3/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /deps/lua-5.3/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.9 2015/03/06 19:49:50 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.12 2014/11/02 19:19:04 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include "lctype.h" 14 | 15 | #if !LUA_USE_CTYPE /* { */ 16 | 17 | #include 18 | 19 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 20 | 0x00, /* EOZ */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 22 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 26 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 27 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 28 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 29 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 30 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 32 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 33 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 34 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 35 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 36 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 52 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 53 | }; 54 | 55 | #endif /* } */ 56 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.14 2015/05/22 17:45:56 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : -1) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | 21 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 22 | const char *opname); 23 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, 24 | const TValue *p2); 25 | LUAI_FUNC l_noret luaG_opinterror (lua_State *L, const TValue *p1, 26 | const TValue *p2, 27 | const char *msg); 28 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, 29 | const TValue *p2); 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 31 | const TValue *p2); 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 33 | LUAI_FUNC const char *luaG_addinfo (lua_State *L, const char *msg, 34 | TString *src, int line); 35 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 36 | LUAI_FUNC void luaG_traceexec (lua_State *L); 37 | 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.29 2015/12/21 13:02:14 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | /* 17 | ** Macro to check stack size and grow stack if needed. Parameters 18 | ** 'pre'/'pos' allow the macro to preserve a pointer into the 19 | ** stack across reallocations, doing the work only when needed. 20 | ** 'condmovestack' is used in heavy tests to force a stack reallocation 21 | ** at every check. 22 | */ 23 | #define luaD_checkstackaux(L,n,pre,pos) \ 24 | if (L->stack_last - L->top <= (n)) \ 25 | { pre; luaD_growstack(L, n); pos; } else { condmovestack(L,pre,pos); } 26 | 27 | /* In general, 'pre'/'pos' are empty (nothing to save) */ 28 | #define luaD_checkstack(L,n) luaD_checkstackaux(L,n,(void)0,(void)0) 29 | 30 | 31 | 32 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 33 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 34 | 35 | 36 | /* type of protected functions, to be ran by 'runprotected' */ 37 | typedef void (*Pfunc) (lua_State *L, void *ud); 38 | 39 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 40 | const char *mode); 41 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 42 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 43 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults); 44 | LUAI_FUNC void luaD_callnoyield (lua_State *L, StkId func, int nResults); 45 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 46 | ptrdiff_t oldtop, ptrdiff_t ef); 47 | LUAI_FUNC int luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, 48 | int nres); 49 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 50 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 51 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 52 | LUAI_FUNC void luaD_inctop (lua_State *L); 53 | 54 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 55 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.15 2015/01/13 15:49:11 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | /* test whether thread is in 'twups' list */ 22 | #define isintwups(L) (L->twups != L) 23 | 24 | 25 | /* 26 | ** maximum number of upvalues in a closure (both C and Lua). (Value 27 | ** must fit in a VM register.) 28 | */ 29 | #define MAXUPVAL 255 30 | 31 | 32 | /* 33 | ** Upvalues for Lua closures 34 | */ 35 | struct UpVal { 36 | TValue *v; /* points to stack or to its own value */ 37 | lu_mem refcount; /* reference counter */ 38 | union { 39 | struct { /* (when open) */ 40 | UpVal *next; /* linked list */ 41 | int touched; /* mark to avoid cycles with dead threads */ 42 | } open; 43 | TValue value; /* the value (when closed) */ 44 | } u; 45 | }; 46 | 47 | #define upisopen(up) ((up)->v != &(up)->u.value) 48 | 49 | 50 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 51 | LUAI_FUNC CClosure *luaF_newCclosure (lua_State *L, int nelems); 52 | LUAI_FUNC LClosure *luaF_newLclosure (lua_State *L, int nelems); 53 | LUAI_FUNC void luaF_initupvals (lua_State *L, LClosure *cl); 54 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 55 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 56 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 57 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 58 | int pc); 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.39 2016/12/04 20:17:24 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #define linit_c 9 | #define LUA_LIB 10 | 11 | /* 12 | ** If you embed Lua in your program and need to open the standard 13 | ** libraries, call luaL_openlibs in your program. If you need a 14 | ** different set of libraries, copy this file to your project and edit 15 | ** it to suit your needs. 16 | ** 17 | ** You can also *preload* libraries, so that a later 'require' can 18 | ** open the library, which is already linked to the application. 19 | ** For that, do the following code: 20 | ** 21 | ** luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); 22 | ** lua_pushcfunction(L, luaopen_modname); 23 | ** lua_setfield(L, -2, modname); 24 | ** lua_pop(L, 1); // remove PRELOAD table 25 | */ 26 | 27 | #include "lprefix.h" 28 | 29 | 30 | #include 31 | 32 | #include "lua.h" 33 | 34 | #include "lualib.h" 35 | #include "lauxlib.h" 36 | 37 | 38 | /* 39 | ** these libs are loaded by lua.c and are readily available to any Lua 40 | ** program 41 | */ 42 | static const luaL_Reg loadedlibs[] = { 43 | {"_G", luaopen_base}, 44 | {LUA_LOADLIBNAME, luaopen_package}, 45 | {LUA_COLIBNAME, luaopen_coroutine}, 46 | {LUA_TABLIBNAME, luaopen_table}, 47 | {LUA_IOLIBNAME, luaopen_io}, 48 | {LUA_OSLIBNAME, luaopen_os}, 49 | {LUA_STRLIBNAME, luaopen_string}, 50 | {LUA_MATHLIBNAME, luaopen_math}, 51 | {LUA_UTF8LIBNAME, luaopen_utf8}, 52 | {LUA_DBLIBNAME, luaopen_debug}, 53 | #if defined(LUA_COMPAT_BITLIB) 54 | {LUA_BITLIBNAME, luaopen_bit32}, 55 | #endif 56 | {NULL, NULL} 57 | }; 58 | 59 | 60 | LUALIB_API void luaL_openlibs (lua_State *L) { 61 | const luaL_Reg *lib; 62 | /* "require" functions from 'loadedlibs' and set results to global table */ 63 | for (lib = loadedlibs; lib->func; lib++) { 64 | luaL_requiref(L, lib->name, lib->func, 1); 65 | lua_pop(L, 1); /* remove lib */ 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.79 2016/05/02 14:02:12 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | #if !defined(LUA_ENV) 18 | #define LUA_ENV "_ENV" 19 | #endif 20 | 21 | 22 | /* 23 | * WARNING: if you change the order of this enumeration, 24 | * grep "ORDER RESERVED" 25 | */ 26 | enum RESERVED { 27 | /* terminal symbols denoted by reserved words */ 28 | TK_AND = FIRST_RESERVED, TK_BREAK, 29 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 30 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 31 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 32 | /* other terminal symbols */ 33 | TK_IDIV, TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, 34 | TK_SHL, TK_SHR, 35 | TK_DBCOLON, TK_EOS, 36 | TK_FLT, TK_INT, TK_NAME, TK_STRING 37 | }; 38 | 39 | /* number of reserved words */ 40 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 41 | 42 | 43 | typedef union { 44 | lua_Number r; 45 | lua_Integer i; 46 | TString *ts; 47 | } SemInfo; /* semantics information */ 48 | 49 | 50 | typedef struct Token { 51 | int token; 52 | SemInfo seminfo; 53 | } Token; 54 | 55 | 56 | /* state of the lexer plus state of the parser when shared by all 57 | functions */ 58 | typedef struct LexState { 59 | int current; /* current character (charint) */ 60 | int linenumber; /* input line counter */ 61 | int lastline; /* line of last token 'consumed' */ 62 | Token t; /* current token */ 63 | Token lookahead; /* look ahead token */ 64 | struct FuncState *fs; /* current function (parser) */ 65 | struct lua_State *L; 66 | ZIO *z; /* input stream */ 67 | Mbuffer *buff; /* buffer for tokens */ 68 | Table *h; /* to avoid collection/reuse strings */ 69 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 70 | TString *source; /* current source name */ 71 | TString *envn; /* environment variable name */ 72 | } LexState; 73 | 74 | 75 | LUAI_FUNC void luaX_init (lua_State *L); 76 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 77 | TString *source, int firstchar); 78 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 79 | LUAI_FUNC void luaX_next (LexState *ls); 80 | LUAI_FUNC int luaX_lookahead (LexState *ls); 81 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 82 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 83 | 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.91 2015/03/06 19:45:54 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lmem_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "ldebug.h" 18 | #include "ldo.h" 19 | #include "lgc.h" 20 | #include "lmem.h" 21 | #include "lobject.h" 22 | #include "lstate.h" 23 | 24 | 25 | 26 | /* 27 | ** About the realloc function: 28 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 29 | ** ('osize' is the old size, 'nsize' is the new size) 30 | ** 31 | ** * frealloc(ud, NULL, x, s) creates a new block of size 's' (no 32 | ** matter 'x'). 33 | ** 34 | ** * frealloc(ud, p, x, 0) frees the block 'p' 35 | ** (in this specific case, frealloc must return NULL); 36 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 37 | ** (which is equivalent to free(NULL) in ISO C) 38 | ** 39 | ** frealloc returns NULL if it cannot create or reallocate the area 40 | ** (any reallocation to an equal or smaller size cannot fail!) 41 | */ 42 | 43 | 44 | 45 | #define MINSIZEARRAY 4 46 | 47 | 48 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 49 | int limit, const char *what) { 50 | void *newblock; 51 | int newsize; 52 | if (*size >= limit/2) { /* cannot double it? */ 53 | if (*size >= limit) /* cannot grow even a little? */ 54 | luaG_runerror(L, "too many %s (limit is %d)", what, limit); 55 | newsize = limit; /* still have at least one free place */ 56 | } 57 | else { 58 | newsize = (*size)*2; 59 | if (newsize < MINSIZEARRAY) 60 | newsize = MINSIZEARRAY; /* minimum size */ 61 | } 62 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 63 | *size = newsize; /* update only when everything else is OK */ 64 | return newblock; 65 | } 66 | 67 | 68 | l_noret luaM_toobig (lua_State *L) { 69 | luaG_runerror(L, "memory allocation error: block too big"); 70 | } 71 | 72 | 73 | 74 | /* 75 | ** generic allocation routine. 76 | */ 77 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 78 | void *newblock; 79 | global_State *g = G(L); 80 | size_t realosize = (block) ? osize : 0; 81 | lua_assert((realosize == 0) == (block == NULL)); 82 | #if defined(HARDMEMTESTS) 83 | if (nsize > realosize && g->gcrunning) 84 | luaC_fullgc(L, 1); /* force a GC whenever possible */ 85 | #endif 86 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); 87 | if (newblock == NULL && nsize > 0) { 88 | lua_assert(nsize > realosize); /* cannot fail when shrinking a block */ 89 | if (g->version) { /* is state fully built? */ 90 | luaC_fullgc(L, 1); /* try to free some memory... */ 91 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 92 | } 93 | if (newblock == NULL) 94 | luaD_throw(L, LUA_ERRMEM); 95 | } 96 | lua_assert((nsize == 0) == (newblock == NULL)); 97 | g->GCdebt = (g->GCdebt + nsize) - realosize; 98 | return newblock; 99 | } 100 | 101 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.43 2014/12/19 17:26:14 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro reallocs a vector 'b' from 'on' to 'n' elements, where 19 | ** each element has size 'e'. In case of arithmetic overflow of the 20 | ** product 'n'*'e', it raises an error (calling 'luaM_toobig'). Because 21 | ** 'e' is always constant, it avoids the runtime division MAX_SIZET/(e). 22 | ** 23 | ** (The macro is somewhat complex to avoid warnings: The 'sizeof' 24 | ** comparison avoids a runtime comparison when overflow cannot occur. 25 | ** The compiler should be able to optimize the real test by itself, but 26 | ** when it does it, it may give a warning about "comparison is always 27 | ** false due to limited range of data type"; the +1 tricks the compiler, 28 | ** avoiding this warning but also this optimization.) 29 | */ 30 | #define luaM_reallocv(L,b,on,n,e) \ 31 | (((sizeof(n) >= sizeof(size_t) && cast(size_t, (n)) + 1 > MAX_SIZET/(e)) \ 32 | ? luaM_toobig(L) : cast_void(0)) , \ 33 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 34 | 35 | /* 36 | ** Arrays of chars do not need any test 37 | */ 38 | #define luaM_reallocvchar(L,b,on,n) \ 39 | cast(char *, luaM_realloc_(L, (b), (on)*sizeof(char), (n)*sizeof(char))) 40 | 41 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 42 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 43 | #define luaM_freearray(L, b, n) luaM_realloc_(L, (b), (n)*sizeof(*(b)), 0) 44 | 45 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 46 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 47 | #define luaM_newvector(L,n,t) \ 48 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 49 | 50 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 51 | 52 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 53 | if ((nelems)+1 > (size)) \ 54 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 55 | 56 | #define luaM_reallocvector(L, v,oldn,n,t) \ 57 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 58 | 59 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 60 | 61 | /* not to be called directly */ 62 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 63 | size_t size); 64 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 65 | size_t size_elem, int limit, 66 | const char *what); 67 | 68 | #endif 69 | 70 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lprefix.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lprefix.h,v 1.2 2014/12/29 16:54:13 roberto Exp $ 3 | ** Definitions for Lua code that must come before any other header file 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lprefix_h 8 | #define lprefix_h 9 | 10 | 11 | /* 12 | ** Allows POSIX/XSI stuff 13 | */ 14 | #if !defined(LUA_USE_C89) /* { */ 15 | 16 | #if !defined(_XOPEN_SOURCE) 17 | #define _XOPEN_SOURCE 600 18 | #elif _XOPEN_SOURCE == 0 19 | #undef _XOPEN_SOURCE /* use -D_XOPEN_SOURCE=0 to undefine it */ 20 | #endif 21 | 22 | /* 23 | ** Allows manipulation of large files in gcc and some other compilers 24 | */ 25 | #if !defined(LUA_32BITS) && !defined(_FILE_OFFSET_BITS) 26 | #define _LARGEFILE_SOURCE 1 27 | #define _FILE_OFFSET_BITS 64 28 | #endif 29 | 30 | #endif /* } */ 31 | 32 | 33 | /* 34 | ** Windows stuff 35 | */ 36 | #if defined(_WIN32) /* { */ 37 | 38 | #if !defined(_CRT_SECURE_NO_WARNINGS) 39 | #define _CRT_SECURE_NO_WARNINGS /* avoid warnings about ISO C functions */ 40 | #endif 41 | 42 | #endif /* } */ 43 | 44 | #endif 45 | 46 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.61 2015/11/03 15:36:01 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizelstring(l) (sizeof(union UTString) + ((l) + 1) * sizeof(char)) 16 | 17 | #define sizeludata(l) (sizeof(union UUdata) + (l)) 18 | #define sizeudata(u) sizeludata((u)->len) 19 | 20 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 21 | (sizeof(s)/sizeof(char))-1)) 22 | 23 | 24 | /* 25 | ** test whether a string is a reserved word 26 | */ 27 | #define isreserved(s) ((s)->tt == LUA_TSHRSTR && (s)->extra > 0) 28 | 29 | 30 | /* 31 | ** equality for short strings, which are always internalized 32 | */ 33 | #define eqshrstr(a,b) check_exp((a)->tt == LUA_TSHRSTR, (a) == (b)) 34 | 35 | 36 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 37 | LUAI_FUNC unsigned int luaS_hashlongstr (TString *ts); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 40 | LUAI_FUNC void luaS_clearcache (global_State *g); 41 | LUAI_FUNC void luaS_init (lua_State *L); 42 | LUAI_FUNC void luaS_remove (lua_State *L, TString *ts); 43 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s); 44 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 45 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 46 | LUAI_FUNC TString *luaS_createlngstrobj (lua_State *L, size_t l); 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.23 2016/12/22 13:08:50 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gval(n) (&(n)->i_val) 15 | #define gnext(n) ((n)->i_key.nk.next) 16 | 17 | 18 | /* 'const' to avoid wrong writings that can mess up field 'next' */ 19 | #define gkey(n) cast(const TValue*, (&(n)->i_key.tvk)) 20 | 21 | /* 22 | ** writable version of 'gkey'; allows updates to individual fields, 23 | ** but not to the whole (which has incompatible type) 24 | */ 25 | #define wgkey(n) (&(n)->i_key.nk) 26 | 27 | #define invalidateTMcache(t) ((t)->flags = 0) 28 | 29 | 30 | /* true when 't' is using 'dummynode' as its hash part */ 31 | #define isdummy(t) ((t)->lastfree == NULL) 32 | 33 | 34 | /* allocated size for hash nodes */ 35 | #define allocsizenode(t) (isdummy(t) ? 0 : sizenode(t)) 36 | 37 | 38 | /* returns the key, given the value of a table entry */ 39 | #define keyfromval(v) \ 40 | (gkey(cast(Node *, cast(char *, (v)) - offsetof(Node, i_val)))) 41 | 42 | 43 | LUAI_FUNC const TValue *luaH_getint (Table *t, lua_Integer key); 44 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, lua_Integer key, 45 | TValue *value); 46 | LUAI_FUNC const TValue *luaH_getshortstr (Table *t, TString *key); 47 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 48 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 49 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 50 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 51 | LUAI_FUNC Table *luaH_new (lua_State *L); 52 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, unsigned int nasize, 53 | unsigned int nhsize); 54 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, unsigned int nasize); 55 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 56 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 57 | LUAI_FUNC int luaH_getn (Table *t); 58 | 59 | 60 | #if defined(LUA_DEBUG) 61 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 62 | LUAI_FUNC int luaH_isdummy (const Table *t); 63 | #endif 64 | 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.22 2016/02/26 19:20:15 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" and "ORDER OP" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with fast access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_MOD, 29 | TM_POW, 30 | TM_DIV, 31 | TM_IDIV, 32 | TM_BAND, 33 | TM_BOR, 34 | TM_BXOR, 35 | TM_SHL, 36 | TM_SHR, 37 | TM_UNM, 38 | TM_BNOT, 39 | TM_LT, 40 | TM_LE, 41 | TM_CONCAT, 42 | TM_CALL, 43 | TM_N /* number of elements in the enum */ 44 | } TMS; 45 | 46 | 47 | 48 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 49 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 50 | 51 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 52 | 53 | #define ttypename(x) luaT_typenames_[(x) + 1] 54 | 55 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 56 | 57 | 58 | LUAI_FUNC const char *luaT_objtypename (lua_State *L, const TValue *o); 59 | 60 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 61 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 62 | TMS event); 63 | LUAI_FUNC void luaT_init (lua_State *L); 64 | 65 | LUAI_FUNC void luaT_callTM (lua_State *L, const TValue *f, const TValue *p1, 66 | const TValue *p2, TValue *p3, int hasres); 67 | LUAI_FUNC int luaT_callbinTM (lua_State *L, const TValue *p1, const TValue *p2, 68 | StkId res, TMS event); 69 | LUAI_FUNC void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, 70 | StkId res, TMS event); 71 | LUAI_FUNC int luaT_callorderTM (lua_State *L, const TValue *p1, 72 | const TValue *p2, TMS event); 73 | 74 | 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.45 2017/01/12 17:14:26 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | /* version suffix for environment variable names */ 15 | #define LUA_VERSUFFIX "_" LUA_VERSION_MAJOR "_" LUA_VERSION_MINOR 16 | 17 | 18 | LUAMOD_API int (luaopen_base) (lua_State *L); 19 | 20 | #define LUA_COLIBNAME "coroutine" 21 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 22 | 23 | #define LUA_TABLIBNAME "table" 24 | LUAMOD_API int (luaopen_table) (lua_State *L); 25 | 26 | #define LUA_IOLIBNAME "io" 27 | LUAMOD_API int (luaopen_io) (lua_State *L); 28 | 29 | #define LUA_OSLIBNAME "os" 30 | LUAMOD_API int (luaopen_os) (lua_State *L); 31 | 32 | #define LUA_STRLIBNAME "string" 33 | LUAMOD_API int (luaopen_string) (lua_State *L); 34 | 35 | #define LUA_UTF8LIBNAME "utf8" 36 | LUAMOD_API int (luaopen_utf8) (lua_State *L); 37 | 38 | #define LUA_BITLIBNAME "bit32" 39 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 40 | 41 | #define LUA_MATHLIBNAME "math" 42 | LUAMOD_API int (luaopen_math) (lua_State *L); 43 | 44 | #define LUA_DBLIBNAME "debug" 45 | LUAMOD_API int (luaopen_debug) (lua_State *L); 46 | 47 | #define LUA_LOADLIBNAME "package" 48 | LUAMOD_API int (luaopen_package) (lua_State *L); 49 | 50 | 51 | /* open all previous libraries */ 52 | LUALIB_API void (luaL_openlibs) (lua_State *L); 53 | 54 | 55 | 56 | #if !defined(lua_assert) 57 | #define lua_assert(x) ((void)0) 58 | #endif 59 | 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.45 2015/09/08 15:41:05 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "llimits.h" 11 | #include "lobject.h" 12 | #include "lzio.h" 13 | 14 | 15 | /* data to catch conversion errors */ 16 | #define LUAC_DATA "\x19\x93\r\n\x1a\n" 17 | 18 | #define LUAC_INT 0x5678 19 | #define LUAC_NUM cast_num(370.5) 20 | 21 | #define MYINT(s) (s[0]-'0') 22 | #define LUAC_VERSION (MYINT(LUA_VERSION_MAJOR)*16+MYINT(LUA_VERSION_MINOR)) 23 | #define LUAC_FORMAT 0 /* this is the official format */ 24 | 25 | /* load one chunk; from lundump.c */ 26 | LUAI_FUNC LClosure* luaU_undump (lua_State* L, ZIO* Z, const char* name); 27 | 28 | /* dump one chunk; from ldump.c */ 29 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, 30 | void* data, int strip); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.37 2015/09/08 15:41:05 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lzio_c 8 | #define LUA_CORE 9 | 10 | #include "lprefix.h" 11 | 12 | 13 | #include 14 | 15 | #include "lua.h" 16 | 17 | #include "llimits.h" 18 | #include "lmem.h" 19 | #include "lstate.h" 20 | #include "lzio.h" 21 | 22 | 23 | int luaZ_fill (ZIO *z) { 24 | size_t size; 25 | lua_State *L = z->L; 26 | const char *buff; 27 | lua_unlock(L); 28 | buff = z->reader(L, z->data, &size); 29 | lua_lock(L); 30 | if (buff == NULL || size == 0) 31 | return EOZ; 32 | z->n = size - 1; /* discount char being returned */ 33 | z->p = buff; 34 | return cast_uchar(*(z->p++)); 35 | } 36 | 37 | 38 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 39 | z->L = L; 40 | z->reader = reader; 41 | z->data = data; 42 | z->n = 0; 43 | z->p = NULL; 44 | } 45 | 46 | 47 | /* --------------------------------------------------------------- read --- */ 48 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 49 | while (n) { 50 | size_t m; 51 | if (z->n == 0) { /* no bytes in buffer? */ 52 | if (luaZ_fill(z) == EOZ) /* try to read more */ 53 | return n; /* no more input; return number of missing bytes */ 54 | else { 55 | z->n++; /* luaZ_fill consumed first byte; put it back */ 56 | z->p--; 57 | } 58 | } 59 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 60 | memcpy(b, z->p, m); 61 | z->n -= m; 62 | z->p += m; 63 | b = (char *)b + m; 64 | n -= m; 65 | } 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /deps/lua-5.3/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.31 2015/09/08 15:41:05 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_buffremove(buff,i) ((buff)->n -= (i)) 36 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 37 | 38 | 39 | #define luaZ_resizebuffer(L, buff, size) \ 40 | ((buff)->buffer = luaM_reallocvchar(L, (buff)->buffer, \ 41 | (buff)->buffsize, size), \ 42 | (buff)->buffsize = size) 43 | 44 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 45 | 46 | 47 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 48 | void *data); 49 | LUAI_FUNC size_t luaZ_read (ZIO* z, void *b, size_t n); /* read next n bytes */ 50 | 51 | 52 | 53 | /* --------- Private Part ------------------ */ 54 | 55 | struct Zio { 56 | size_t n; /* bytes still unread */ 57 | const char *p; /* current position in buffer */ 58 | lua_Reader reader; /* reader function */ 59 | void *data; /* additional data */ 60 | lua_State *L; /* Lua state (for reader) */ 61 | }; 62 | 63 | 64 | LUAI_FUNC int luaZ_fill (ZIO *z); 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /deps/rapidjson/include/rapidjson/cursorstreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_CURSORSTREAMWRAPPER_H_ 16 | #define RAPIDJSON_CURSORSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | 20 | #if defined(__GNUC__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(effc++) 23 | #endif 24 | 25 | #if defined(_MSC_VER) && _MSC_VER <= 1800 26 | RAPIDJSON_DIAG_PUSH 27 | RAPIDJSON_DIAG_OFF(4702) // unreachable code 28 | RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated 29 | #endif 30 | 31 | RAPIDJSON_NAMESPACE_BEGIN 32 | 33 | 34 | //! Cursor stream wrapper for counting line and column number if error exists. 35 | /*! 36 | \tparam InputStream Any stream that implements Stream Concept 37 | */ 38 | template > 39 | class CursorStreamWrapper : public GenericStreamWrapper { 40 | public: 41 | typedef typename Encoding::Ch Ch; 42 | 43 | CursorStreamWrapper(InputStream& is): 44 | GenericStreamWrapper(is), line_(1), col_(0) {} 45 | 46 | // counting line and column number 47 | Ch Take() { 48 | Ch ch = this->is_.Take(); 49 | if(ch == '\n') { 50 | line_ ++; 51 | col_ = 0; 52 | } else { 53 | col_ ++; 54 | } 55 | return ch; 56 | } 57 | 58 | //! Get the error line number, if error exists. 59 | size_t GetLine() const { return line_; } 60 | //! Get the error column number, if error exists. 61 | size_t GetColumn() const { return col_; } 62 | 63 | private: 64 | size_t line_; //!< Current Line 65 | size_t col_; //!< Current Column 66 | }; 67 | 68 | #if defined(_MSC_VER) && _MSC_VER <= 1800 69 | RAPIDJSON_DIAG_POP 70 | #endif 71 | 72 | #if defined(__GNUC__) 73 | RAPIDJSON_DIAG_POP 74 | #endif 75 | 76 | RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // RAPIDJSON_CURSORSTREAMWRAPPER_H_ 79 | -------------------------------------------------------------------------------- /deps/rapidjson/include/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../stream.h" 19 | #include 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | namespace internal { 23 | 24 | //! Custom strlen() which works on different character types. 25 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 26 | \param s Null-terminated input string. 27 | \return Number of characters in the string. 28 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 29 | */ 30 | template 31 | inline SizeType StrLen(const Ch* s) { 32 | RAPIDJSON_ASSERT(s != 0); 33 | const Ch* p = s; 34 | while (*p) ++p; 35 | return SizeType(p - s); 36 | } 37 | 38 | template <> 39 | inline SizeType StrLen(const char* s) { 40 | return SizeType(std::strlen(s)); 41 | } 42 | 43 | template <> 44 | inline SizeType StrLen(const wchar_t* s) { 45 | return SizeType(std::wcslen(s)); 46 | } 47 | 48 | //! Returns number of code points in a encoded string. 49 | template 50 | bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { 51 | RAPIDJSON_ASSERT(s != 0); 52 | RAPIDJSON_ASSERT(outCount != 0); 53 | GenericStringStream is(s); 54 | const typename Encoding::Ch* end = s + length; 55 | SizeType count = 0; 56 | while (is.src_ < end) { 57 | unsigned codepoint; 58 | if (!Encoding::Decode(is, &codepoint)) 59 | return false; 60 | count++; 61 | } 62 | *outCount = count; 63 | return true; 64 | } 65 | 66 | } // namespace internal 67 | RAPIDJSON_NAMESPACE_END 68 | 69 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 70 | -------------------------------------------------------------------------------- /deps/rapidjson/include/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /deps/rapidjson/include/rapidjson/memorybuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYBUFFER_H_ 16 | #define RAPIDJSON_MEMORYBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! Represents an in-memory output byte stream. 24 | /*! 25 | This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. 26 | 27 | It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. 28 | 29 | Differences between MemoryBuffer and StringBuffer: 30 | 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 31 | 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. 32 | 33 | \tparam Allocator type for allocating memory buffer. 34 | \note implements Stream concept 35 | */ 36 | template 37 | struct GenericMemoryBuffer { 38 | typedef char Ch; // byte 39 | 40 | GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 41 | 42 | void Put(Ch c) { *stack_.template Push() = c; } 43 | void Flush() {} 44 | 45 | void Clear() { stack_.Clear(); } 46 | void ShrinkToFit() { stack_.ShrinkToFit(); } 47 | Ch* Push(size_t count) { return stack_.template Push(count); } 48 | void Pop(size_t count) { stack_.template Pop(count); } 49 | 50 | const Ch* GetBuffer() const { 51 | return stack_.template Bottom(); 52 | } 53 | 54 | size_t GetSize() const { return stack_.GetSize(); } 55 | 56 | static const size_t kDefaultCapacity = 256; 57 | mutable internal::Stack stack_; 58 | }; 59 | 60 | typedef GenericMemoryBuffer<> MemoryBuffer; 61 | 62 | //! Implement specialized version of PutN() with memset() for better performance. 63 | template<> 64 | inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { 65 | std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c)); 66 | } 67 | 68 | RAPIDJSON_NAMESPACE_END 69 | 70 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 71 | -------------------------------------------------------------------------------- /deps/rapidjson/include/rapidjson/memorystream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_MEMORYSTREAM_H_ 16 | #define RAPIDJSON_MEMORYSTREAM_H_ 17 | 18 | #include "stream.h" 19 | 20 | #ifdef __clang__ 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(unreachable-code) 23 | RAPIDJSON_DIAG_OFF(missing-noreturn) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Represents an in-memory input byte stream. 29 | /*! 30 | This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. 31 | 32 | It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. 33 | 34 | Differences between MemoryStream and StringStream: 35 | 1. StringStream has encoding but MemoryStream is a byte stream. 36 | 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. 37 | 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). 38 | \note implements Stream concept 39 | */ 40 | struct MemoryStream { 41 | typedef char Ch; // byte 42 | 43 | MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} 44 | 45 | Ch Peek() const { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; } 46 | Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; } 47 | size_t Tell() const { return static_cast(src_ - begin_); } 48 | 49 | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 50 | void Put(Ch) { RAPIDJSON_ASSERT(false); } 51 | void Flush() { RAPIDJSON_ASSERT(false); } 52 | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; } 53 | 54 | // For encoding detection only. 55 | const Ch* Peek4() const { 56 | return Tell() + 4 <= size_ ? src_ : 0; 57 | } 58 | 59 | const Ch* src_; //!< Current read position. 60 | const Ch* begin_; //!< Original head of the string. 61 | const Ch* end_; //!< End of stream. 62 | size_t size_; //!< Size of the stream. 63 | }; 64 | 65 | RAPIDJSON_NAMESPACE_END 66 | 67 | #ifdef __clang__ 68 | RAPIDJSON_DIAG_POP 69 | #endif 70 | 71 | #endif // RAPIDJSON_MEMORYBUFFER_H_ 72 | -------------------------------------------------------------------------------- /deps/rapidjson/include/rapidjson/ostreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_OSTREAMWRAPPER_H_ 16 | #define RAPIDJSON_OSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | RAPIDJSON_DIAG_PUSH 23 | RAPIDJSON_DIAG_OFF(padded) 24 | #endif 25 | 26 | RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept. 29 | /*! 30 | The classes can be wrapped including but not limited to: 31 | 32 | - \c std::ostringstream 33 | - \c std::stringstream 34 | - \c std::wpstringstream 35 | - \c std::wstringstream 36 | - \c std::ifstream 37 | - \c std::fstream 38 | - \c std::wofstream 39 | - \c std::wfstream 40 | 41 | \tparam StreamType Class derived from \c std::basic_ostream. 42 | */ 43 | 44 | template 45 | class BasicOStreamWrapper { 46 | public: 47 | typedef typename StreamType::char_type Ch; 48 | BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} 49 | 50 | void Put(Ch c) { 51 | stream_.put(c); 52 | } 53 | 54 | void Flush() { 55 | stream_.flush(); 56 | } 57 | 58 | // Not implemented 59 | char Peek() const { RAPIDJSON_ASSERT(false); return 0; } 60 | char Take() { RAPIDJSON_ASSERT(false); return 0; } 61 | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; } 62 | char* PutBegin() { RAPIDJSON_ASSERT(false); return 0; } 63 | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; } 64 | 65 | private: 66 | BasicOStreamWrapper(const BasicOStreamWrapper&); 67 | BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); 68 | 69 | StreamType& stream_; 70 | }; 71 | 72 | typedef BasicOStreamWrapper OStreamWrapper; 73 | typedef BasicOStreamWrapper WOStreamWrapper; 74 | 75 | #ifdef __clang__ 76 | RAPIDJSON_DIAG_POP 77 | #endif 78 | 79 | RAPIDJSON_NAMESPACE_END 80 | 81 | #endif // RAPIDJSON_OSTREAMWRAPPER_H_ 82 | -------------------------------------------------------------------------------- /deps/rapidxml/license.txt: -------------------------------------------------------------------------------- 1 | Use of this software is granted under one of the following two licenses, 2 | to be chosen freely by the user. 3 | 4 | 1. Boost Software License - Version 1.0 - August 17th, 2003 5 | =============================================================================== 6 | 7 | Copyright (c) 2006, 2007 Marcin Kalicinski 8 | 9 | Permission is hereby granted, free of charge, to any person or organization 10 | obtaining a copy of the software and accompanying documentation covered by 11 | this license (the "Software") to use, reproduce, display, distribute, 12 | execute, and transmit the Software, and to prepare derivative works of the 13 | Software, and to permit third-parties to whom the Software is furnished to 14 | do so, all subject to the following: 15 | 16 | The copyright notices in the Software and this entire statement, including 17 | the above license grant, this restriction and the following disclaimer, 18 | must be included in all copies of the Software, in whole or in part, and 19 | all derivative works of the Software, unless such copies or derivative 20 | works are solely in the form of machine-executable object code generated by 21 | a source language processor. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 26 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 27 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 28 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | DEALINGS IN THE SOFTWARE. 30 | 31 | 2. The MIT License 32 | =============================================================================== 33 | 34 | Copyright (c) 2006, 2007 Marcin Kalicinski 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a copy 37 | of this software and associated documentation files (the "Software"), to deal 38 | in the Software without restriction, including without limitation the rights 39 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 40 | of the Software, and to permit persons to whom the Software is furnished to do so, 41 | subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be included in all 44 | copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 52 | IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /doc/api/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /doc/api/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | $projectname: $title 9 | $title 10 | 11 | 12 | 13 | 14 | $treeview 15 | $search 16 | $mathjax 17 | 18 | $extrastylesheet 19 | 20 | 21 | 27 | 28 | 29 |
30 | 31 | 32 |
33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 46 | 47 | 48 | 49 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
41 |
$projectname 42 | $projectnumber 43 |
44 |
$projectbrief
45 |
50 |
$projectbrief
51 |
$searchbox
62 |
63 | 64 | 65 | -------------------------------------------------------------------------------- /doc/api/images/Lua-Logo-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/billyquith/ponder/aff8843efa8069b272bad49df2d820a9b4d88171/doc/api/images/Lua-Logo-128.png -------------------------------------------------------------------------------- /doc/api/images/ponder1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/billyquith/ponder/aff8843efa8069b272bad49df2d820a9b4d88171/doc/api/images/ponder1.jpg -------------------------------------------------------------------------------- /doc/api/pages/building.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | \page building_ponder Building Ponder 4 | 5 | These are some notes on how to build Ponder. It is assumed that you have some knowledge of 6 | [CMake][cmake]. If not, perhaps look at the [tutorial][tutorial], or search for tutorial resources, 7 | of which there are many. 8 | 9 | ## Get Ponder 10 | 11 | You can clone or download Ponder via the [Ponder project page][proj]. E.g. 12 | 13 | ``` 14 | git clone https://github.com/billyquith/ponder.git 15 | ``` 16 | 17 | ## Compiler Notes 18 | 19 | Ponder requires a C++ compiler that handles a minimum of **C++17**. These are some notes 20 | on compilers used in testing: 21 | 22 | - Compiler [C++ compatibility][compat] notes. 23 | - Clang has full support for C++17 since version 4. 24 | - GCC has good C++17 support from version 7 onwards. 25 | - Apple Xcode: 26 | - Apple Clang is a modified version of Clang with different version numbers. 27 | - [Version information](https://trac.macports.org/wiki/XcodeVersionInfo) 28 | - Versions since Xcode 9.2 should work. 29 | - Microsoft MSVC 2017 & 2019 32/64 bit - supported 30 | - MSVC started to have full C++17 support in 2019. Please prefer this version. 31 | - Best to use the most recent patched version. 32 | 33 | ## Generate Build Files 34 | 35 | Ponder uses `cmake` to generate project files. As you would normally do, create a build directory 36 | and generate your project files: 37 | 38 | ``` 39 | cd ponder 40 | mkdir build && cd build 41 | cmake -G "Unix Makefiles" .. 42 | make 43 | ``` 44 | 45 | ### Build Options 46 | 47 | There are various options you can pass to cmake to turn on optional features. These are processed 48 | in `cmake/Config.cmake`. 49 | 50 | Features: 51 | 52 | - `USES_LUA:BOOL` - turns Lua binding support on. See \ref ponder::lua. 53 | 54 | Tests: 55 | 56 | - `BUILD_TEST` - includes the unit tests. You might use this for reference. 57 | - `BUILD_TEST_LUA:BOOL` - turns Lua testing on. You might want to build this to ensure your project 58 | is set up correctly if `USES_LUA` is on. 59 | - `BUILD_TEST_EXAMPLES:BOOL` - includes the examples used in the documentation. 60 | 61 | Options: 62 | 63 | - `BUILD_SHARED_LIBS:BOOL` - builds Ponder as a shared library. 64 | - Only really applicable to Windows for making DLLs. 65 | - `CMAKE_BUILD_TYPE:STRING` - sets the build configuration. This defaults to "RelWithDebInfo". 66 | 67 | E.g. 68 | 69 | ``` 70 | cmake .. \ 71 | -G "Unix Makefiles" \ 72 | -D BUILD_TEST=TRUE # include unit tests \ 73 | -D USES_LUA=TRUE # turn on Lua support \ 74 | -D BUILD_TEST_LUA=TRUE # include Lua tests 75 | ``` 76 | 77 | ## Using Ponder 78 | 79 | You can include and link to Ponder as you would a normal library. Please note if you install Ponder 80 | there is a `FindPonder.cmake` module in the `cmake` directory which allows you to find and 81 | configure Ponder from your client project. 82 | 83 | [cmake]: https://cmake.org/ 84 | [tutorial]: https://cmake.org/cmake-tutorial/ 85 | [proj]: https://github.com/billyquith/ponder 86 | [compat]: https://en.cppreference.com/w/cpp/compiler_support#cpp14 87 | 88 | */ 89 | 90 | https://cmake.org/cmake-tutorial/ 91 | -------------------------------------------------------------------------------- /doc/api/pages/license.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | \page license_page Ponder License 4 | 5 | \verbatim 6 | The MIT License (MIT) 7 | 8 | Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 9 | Copyright (C) 2015-2020 Nick Trout. 10 | 11 | Permission is hereby granted, free of charge, to any person obtaining a copy 12 | of this software and associated documentation files (the "Software"), to deal 13 | in the Software without restriction, including without limitation the rights 14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | copies of the Software, and to permit persons to whom the Software is 16 | furnished to do so, subject to the following conditions: 17 | 18 | The above copyright notice and this permission notice shall be included in 19 | all copies or substantial portions of the Software. 20 | 21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | THE SOFTWARE. 28 | \endverbatim 29 | 30 | \note Ponder was forked from CAMP that was originally released released under LGPL. The license 31 | changed to MIT in 2014. 32 | 33 | */ 34 | -------------------------------------------------------------------------------- /doc/api/pages/mainpage.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | \mainpage Ponder C++ library documentation 4 | 5 | \image html ponder1.jpg "ponder: to reflect on" 6 | 7 | - **TL;DR** - Expose C++ classes and objects so they can used as data. Serialisation 8 | and Lua scripting supported. 9 | 10 | \image html Lua-Logo-128.png "Lua binding" 11 | 12 | \section overview Overview 13 | 14 | 15 | Ponder is a C++ library which provides runtime reflection for types. It provides an abstraction for 16 | most of the high-level concepts of C++ like classes, enumerations, properties, functions, and 17 | objects. By wrapping all these concepts into abstract structures, Ponder provides an extra layer of 18 | flexibility to programs, and allow them to expose and manipulate their data structures at runtime. 19 | 20 | Many applications can take advantage of Ponder, in order to automate tasks which would 21 | otherwise require a huge amount of work. For example, Ponder can be used to expose and edit 22 | objects' attributes into a graphical user interface. It can also be used to do 23 | automatic binding of C++ classes to script languages such as Python or Lua. 24 | Another possible application would be the serialization of objects to XML, text or 25 | binary formats. Or you can even combine all these examples to provide a powerful 26 | and consistent interface for manipulating your objects outside C++ code. 27 | 28 | Features: 29 | 30 | - Expose C++ classes so they can be found by name or type. 31 | - Create and destroy instance of classes at runtime. 32 | - Get and set properties on member variables. 33 | - Call member and static functions. 34 | - Save class instance data as JSON or XML. 35 | - Automatic [Lua][lua] binding generation. 36 | 37 | \section intro_example Quick example 38 | 39 | Here is a simple example of how to use Ponder. First we need a class to expose: 40 | 41 | \snippet simple.cpp eg_simple_class 42 | 43 | Then we declare what we want to expose to Ponder: 44 | 45 | \snippet simple.cpp eg_simple_declare 46 | 47 | We can then create and manipulate instances of the class using the API: 48 | 49 | \snippet simple.cpp eg_simple_use 50 | 51 | \section examples Examples 52 | 53 | - \subpage eg_page_shapes 54 | - \subpage eg_page_declare 55 | 56 | \section links Useful links 57 | 58 | - GitHub project. 59 | - Online documentation. 60 | - Blog articles. 61 | 62 | \section blog Articles 63 | 64 | - \subpage blog_ponder_1 65 | - \subpage blog_ponder_2 66 | - \subpage blog_ponder_3 67 | 68 | \section license License 69 | 70 | Ponder is distributed under the terms of the \ref license_page "MIT license". 71 | 72 | \ref license_page 73 | 74 | 75 | \page eg_page_shapes Shapes Example 76 | 77 | \snippet shapes.cpp eg_shapes 78 | 79 | 80 | \page eg_page_declare Declaration Example 81 | 82 | \snippet declare.cpp eg_declare 83 | 84 | [lua]: https://www.lua.org/about.html 85 | 86 | */ 87 | -------------------------------------------------------------------------------- /doc/doxygen_cheatsheet.txt: -------------------------------------------------------------------------------- 1 | 2 | Doxygen notes 3 | ------------- 4 | 5 | ------------------------------------------------------------ 6 | Page 7 | - https://www.stack.nl/~dimitri/doxygen/manual/commands.html 8 | ------------------------------------------------------------ 9 | 10 | /** 11 | 12 | \page page_tag Title 13 | 14 | \tableofcontents - Create TOC at top of page 15 | 16 | \section section_tag Section Title 17 | 18 | \subsection subsection_tag Subsection Title 19 | 20 | \snippet file.cpp snippet_tag - snipper from example file 21 | \snippet this snippet_tag - snippet from same file 22 | 23 | \par Indented paragraph 24 | 25 | \note Indented note, with highligting 26 | 27 | */ 28 | 29 | ------------------------------------------------------------ 30 | 31 | ------------------------------------------------------------ 32 | Markdown 33 | ------------------------------------------------------------ 34 | 35 | - Markdown support: https://www.stack.nl/~dimitri/doxygen/manual/markdown.html 36 | 37 | ======== Quote block ======== 38 | 39 | > This is a block quote 40 | > spanning multiple lines 41 | 42 | ======== List ======== 43 | 44 | - Item 1 45 | 46 | More text for this item. 47 | 48 | - Item 2 49 | + nested list item. 50 | + another nested item. 51 | - Item 3 52 | 53 | ======== Horizontal Rulers ======== 54 | 55 | - - - 56 | ______ 57 | 58 | ======== Emphasis ======== 59 | 60 | *italic* _italic_ **bold** __bold__ 61 | 62 | ======== Link ======== 63 | 64 | link. 65 | 66 | [The link text](@ref MyClass) - Doxygen link 67 | 68 | [text](URL) - text link 69 | 70 | ![Caption text](/path/to/img.jpg) - image, use ! 71 | 72 | [text][link_tag] 73 | 74 | [link_tag]: URL "Optional Title" 75 | 76 | - Auto linking (no square brackets) 77 | 78 | ======== Code Block ======== 79 | 80 | This a normal paragraph 81 | 82 | This is a code block 83 | 84 | We continue with a normal paragraph again. `printf()` code span. 85 | 86 | ```{.py} 87 | # A class 88 | class Dummy: 89 | pass 90 | ``` 91 | 92 | ======== Emphasis ======== 93 | 94 | First Header | Second Header 95 | ------------- | ------------- 96 | Content Cell | Content Cell 97 | Content Cell | Content Cell 98 | 99 | | Right | Center | Left | w/ column alignment 100 | | ----: | :----: | :---- | 101 | | 10 | 10 | 10 | 102 | | ^ | 1000 | 1000 | ^ merge rows 103 | | 100 ||| ||| Merge columns 104 | 105 | 106 | -------------------------------------------------------------------------------- /doc/mkdocs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | pushd ../build 4 | cmake --build . --target ponder_docs 5 | 6 | case `uname -s` in 7 | CYGWIN*) 8 | cygstart doc/api/html/index.html 9 | ;; 10 | Darwin*) 11 | open doc/api/html/index.html 12 | ;; 13 | esac 14 | 15 | popd 16 | -------------------------------------------------------------------------------- /doc/updocs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Update online documentation 3 | 4 | set -e 5 | 6 | PROJDIR=tmp-proj 7 | DOCDIR=tmp-docs 8 | DOCOUT=$PROJDIR/build/doc/api/html 9 | 10 | [ -d $PROJDIR ] && rm -rf $PROJDIR 11 | [ -d $DOCDIR ] && rm -rf $DOCDIR 12 | 13 | # document what is comitted 14 | git clone https://github.com/billyquith/ponder.git $PROJDIR -b master --depth=1 15 | git clone https://github.com/billyquith/ponder.git $DOCDIR -b gh-pages --depth=1 16 | 17 | pushd $PROJDIR 18 | mkdir build && cd build 19 | 20 | # OS specifc project creation 21 | case $(uname -s) in 22 | CYGWIN*) 23 | if [ ! -z "$(ninja --version)" ]; then 24 | echo "Use Ninja" 25 | cmake .. -G Ninja 26 | else 27 | "Use make" 28 | cmake .. -G "Unix Makefiles" 29 | fi 30 | ;; 31 | *) cmake .. -G Ninja 32 | ;; 33 | esac 34 | 35 | cmake --build . --target ponder_docs 36 | cd .. 37 | popd 38 | 39 | # reset and copy Doxygen docs 40 | [ -d $DOCDIR ] && rm -r $DOCDIR/* 41 | cp -r $DOCOUT/* $DOCDIR 42 | 43 | pushd $DOCDIR 44 | git add --all --verbose . 45 | git status 46 | if [[ "$1" == "-d" ]]; then exit 0; fi 47 | read -p "Commit message: " MESSAGE 48 | git commit -m "${MESSAGE:-"Update docs"}" 49 | git push 50 | popd 51 | 52 | [ -d $PROJDIR ] && rm -rf $PROJDIR 53 | [ -d $DOCDIR ] && rm -rf $DOCDIR 54 | -------------------------------------------------------------------------------- /doc/uplocaldocs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Update online documentation 3 | 4 | set -e 5 | 6 | if [ ! -f ../build/doc/api/html/index.html ]; then 7 | echo "Please build docs" 8 | exit 1 9 | fi 10 | 11 | DOCDIR=tmp-docs 12 | DOCOUT=../build/doc/api/html 13 | 14 | [ -d $DOCDIR ] && rm -rf $DOCDIR 15 | 16 | # document what is comitted 17 | git clone https://github.com/billyquith/ponder.git $DOCDIR -b gh-pages --depth=1 18 | 19 | # reset and copy Doxygen docs 20 | [ -d $DOCDIR ] && rm -r $DOCDIR/* 21 | cp -r $DOCOUT/* $DOCDIR 22 | 23 | pushd $DOCDIR 24 | git add --all --verbose . 25 | git status 26 | if [[ "$1" == "-d" ]]; then exit 0; fi 27 | read -p "Commit message: " MESSAGE 28 | git commit -m "${MESSAGE:-"Update docs"}" 29 | git push 30 | popd 31 | 32 | [ -d $DOCDIR ] && rm -rf $DOCDIR 33 | -------------------------------------------------------------------------------- /include/ponder/classcast.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | #ifndef PONDER_CLASSCAST_HPP 32 | #define PONDER_CLASSCAST_HPP 33 | 34 | #include 35 | 36 | namespace ponder 37 | { 38 | class Class; 39 | 40 | /** 41 | * \brief Convert a pointer from a source metaclass to a related target metaclass 42 | * 43 | * \param pointer Source pointer to convert 44 | * \param sourceClass Source metaclass to convert from 45 | * \param targetClass Target metaclass to convert to 46 | * 47 | * \return Converted pointer, or 0 on failure 48 | * 49 | * \throw ClassUnrelated sourceClass is not a base nor a derived of targetClass 50 | */ 51 | PONDER_API void* classCast(void* pointer, const Class& sourceClass, const Class& targetClass); 52 | 53 | } // namespace ponder 54 | 55 | #endif // PONDER_CLASSCAST_HPP 56 | -------------------------------------------------------------------------------- /include/ponder/classget.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | namespace ponder { 31 | 32 | inline size_t classCount() 33 | { 34 | return detail::ClassManager::instance().count(); 35 | } 36 | 37 | inline detail::ClassManager::ClassView classes() 38 | { 39 | return detail::ClassManager::instance().getClasses(); 40 | } 41 | 42 | inline const Class& classByName(IdRef name) 43 | { 44 | // Note: detail::typeName() not used here so no automated registration. 45 | return detail::ClassManager::instance().getByName(name); 46 | } 47 | 48 | template 49 | const Class& classByObject(const T& object) 50 | { 51 | return detail::ClassManager::instance().getById(detail::getTypeId(object)); 52 | } 53 | 54 | template 55 | const Class& classByType() 56 | { 57 | return detail::ClassManager::instance().getById(detail::getTypeId()); 58 | } 59 | 60 | template 61 | const Class* classByTypeSafe() 62 | { 63 | return detail::ClassManager::instance().getByIdSafe(detail::calcTypeId::Type>()); 64 | } 65 | 66 | } // namespace ponder 67 | -------------------------------------------------------------------------------- /include/ponder/constructor.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | #ifndef PONDER_CONSTRUCTOR_HPP 32 | #define PONDER_CONSTRUCTOR_HPP 33 | 34 | namespace ponder { 35 | 36 | class Args; 37 | class UserObject; 38 | 39 | /** 40 | * \brief Represents a metaconstructor which is used to create objects instances from metaclasses 41 | * 42 | * This class is an interface which has to be derived to implement typed constructors. 43 | * 44 | * \sa Property, Function 45 | */ 46 | class Constructor : public Type 47 | { 48 | public: 49 | 50 | /** 51 | * \brief Destructor 52 | */ 53 | virtual ~Constructor() {} 54 | 55 | /** 56 | * \brief Check if the constructor matches the given set of arguments 57 | * 58 | * \param args Set of arguments to check 59 | * 60 | * \return True if the constructor is compatible with the given arguments 61 | */ 62 | virtual bool matches(const Args& args) const = 0; 63 | 64 | /** 65 | * \brief Use the constructor to create a new object 66 | * 67 | * \param ptr If not null, use for placement new, otherwise heap allocate using new 68 | * \param args Set of arguments to pass to the constructor 69 | * 70 | * \return Pointer to the new object wrapped in a UserObject, or UserObject::nothing on failure 71 | */ 72 | virtual UserObject create(void* ptr, const Args& args) const = 0; 73 | }; 74 | 75 | } // namespace ponder 76 | 77 | #endif // PONDER_CONSTRUCTOR_HPP 78 | -------------------------------------------------------------------------------- /include/ponder/detail/enumpropertyimpl.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | namespace ponder { 32 | namespace detail { 33 | 34 | template 35 | EnumPropertyImpl::EnumPropertyImpl(IdRef name, A&& accessor) 36 | : EnumProperty(name, enumByType()) 37 | , m_accessor(accessor) 38 | { 39 | } 40 | 41 | template 42 | Value EnumPropertyImpl::getValue(const UserObject& object) const 43 | { 44 | return m_accessor.m_interface.getter(object.get()); 45 | } 46 | 47 | template 48 | void EnumPropertyImpl::setValue(const UserObject& object, const Value& value) const 49 | { 50 | if (!m_accessor.m_interface.setter(object.get(), value)) 51 | PONDER_ERROR(ForbiddenWrite(name())); 52 | } 53 | 54 | template 55 | bool EnumPropertyImpl::isReadable() const 56 | { 57 | return A::canRead; 58 | } 59 | 60 | template 61 | bool EnumPropertyImpl::isWritable() const 62 | { 63 | return A::canWrite; 64 | } 65 | 66 | } // namespace detail 67 | } // namespace ponder 68 | -------------------------------------------------------------------------------- /include/ponder/detail/getter.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | namespace ponder { 32 | namespace detail { 33 | 34 | template 35 | GetterInterface::~GetterInterface() 36 | { 37 | } 38 | 39 | template 40 | GetterImpl::GetterImpl(std::function function) 41 | : m_function(function) 42 | { 43 | } 44 | 45 | template 46 | T GetterImpl::get(const UserObject& object) const 47 | { 48 | return m_function(object.get()); 49 | } 50 | 51 | template 52 | Getter::Getter(const T& defaultValue) 53 | : m_getter() 54 | , m_defaultValue(defaultValue) 55 | { 56 | } 57 | 58 | template 59 | template 60 | Getter::Getter(std::function function) 61 | : m_getter(new GetterImpl(function)) 62 | { 63 | } 64 | 65 | template 66 | const T& Getter::get() const 67 | { 68 | return m_defaultValue; 69 | } 70 | 71 | template 72 | T Getter::get(const UserObject& object) const 73 | { 74 | return m_getter ? m_getter->get(object) : m_defaultValue; 75 | } 76 | 77 | } // namespace detail 78 | } // namespace ponder 79 | -------------------------------------------------------------------------------- /include/ponder/detail/issmartpointer.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | #ifndef PONDER_DETAIL_ISSMARTPOINTER_HPP 32 | #define PONDER_DETAIL_ISSMARTPOINTER_HPP 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | 39 | namespace ponder { 40 | 41 | template 42 | T* get_pointer(T *p) 43 | { 44 | return p; 45 | } 46 | 47 | template 48 | T* get_pointer(std::unique_ptr const& p) 49 | { 50 | return p.get(); 51 | } 52 | 53 | template 54 | T* get_pointer(std::shared_ptr const& p) 55 | { 56 | return p.get(); 57 | } 58 | 59 | namespace detail { 60 | 61 | /** 62 | * \brief Utility class which tells at compile-time if a type T is a smart pointer to a type U 63 | */ 64 | template 65 | struct IsSmartPointer 66 | { 67 | enum {value = false}; 68 | }; 69 | 70 | template 71 | struct IsSmartPointer, U> 72 | { 73 | enum {value = true}; 74 | }; 75 | 76 | template 77 | struct IsSmartPointer, U> 78 | { 79 | enum {value = true}; 80 | }; 81 | 82 | 83 | } // namespace detail 84 | } // namespace ponder 85 | 86 | #endif // PONDER_DETAIL_ISSMARTPOINTER_HPP 87 | -------------------------------------------------------------------------------- /include/ponder/detail/simplepropertyimpl.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | namespace ponder { 32 | namespace detail { 33 | 34 | template 35 | SimplePropertyImpl::SimplePropertyImpl(IdRef name, A accessor) 36 | : SimpleProperty(name, mapType()) 37 | , m_accessor(accessor) 38 | { 39 | } 40 | 41 | template 42 | Value SimplePropertyImpl::getValue(const UserObject& object) const 43 | { 44 | return Value{m_accessor.m_interface.getter(object.get())}; 45 | } 46 | 47 | template 48 | void SimplePropertyImpl::setValue(const UserObject& object, const Value& value) const 49 | { 50 | if (!m_accessor.m_interface.setter(object.ref(), value.to())) 51 | PONDER_ERROR(ForbiddenWrite(name())); 52 | } 53 | 54 | template 55 | bool SimplePropertyImpl::isReadable() const 56 | { 57 | return A::canRead; 58 | } 59 | 60 | template 61 | bool SimplePropertyImpl::isWritable() const 62 | { 63 | return A::canWrite; 64 | } 65 | 66 | } // namespace detail 67 | } // namespace ponder 68 | -------------------------------------------------------------------------------- /include/ponder/detail/userpropertyimpl.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | #ifndef PONDER_DETAIL_USERPROPERTYIMPL_HPP 32 | #define PONDER_DETAIL_USERPROPERTYIMPL_HPP 33 | 34 | #include 35 | 36 | namespace ponder { 37 | namespace detail { 38 | 39 | template 40 | class UserPropertyImpl : public UserProperty 41 | { 42 | public: 43 | 44 | UserPropertyImpl(IdRef name, A&& accessor); 45 | 46 | protected: 47 | 48 | bool isReadable() const final; 49 | bool isWritable() const final; 50 | 51 | Value getValue(const UserObject& object) const final; 52 | void setValue(const UserObject& object, const Value& value) const final; 53 | 54 | private: 55 | 56 | A m_accessor; // Object used to access the actual C++ property 57 | }; 58 | 59 | } // namespace detail 60 | } // namespace ponder 61 | 62 | #include 63 | 64 | 65 | #endif // PONDER_DETAIL_USERPROPERTYIMPL_HPP 66 | -------------------------------------------------------------------------------- /include/ponder/detail/userpropertyimpl.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | namespace ponder { 31 | namespace detail { 32 | 33 | template 34 | UserPropertyImpl::UserPropertyImpl(IdRef name, A&& accessor) 35 | : UserProperty(name, classByType()) 36 | , m_accessor(accessor) 37 | {} 38 | 39 | template 40 | Value UserPropertyImpl::getValue(const UserObject& object) const 41 | { 42 | // We copy the returned object based on the return type of the getter: (copy) T, const T&, (ref) T&. 43 | return m_accessor.m_interface.getValue(object.get()); 44 | } 45 | 46 | template 47 | void UserPropertyImpl::setValue(const UserObject& object, const Value& value) const 48 | { 49 | if (!m_accessor.m_interface.setter(object.ref(), value)) 50 | PONDER_ERROR(ForbiddenWrite(name())); 51 | } 52 | 53 | template 54 | bool UserPropertyImpl::isReadable() const 55 | { 56 | return A::canRead; 57 | } 58 | 59 | template 60 | bool UserPropertyImpl::isWritable() const 61 | { 62 | return A::canWrite; 63 | } 64 | 65 | } // namespace detail 66 | } // namespace ponder 67 | -------------------------------------------------------------------------------- /include/ponder/enum.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | namespace ponder { 31 | 32 | template 33 | EnumBuilder Enum::declare(IdRef name) 34 | { 35 | typedef detail::StaticTypeDecl typeDecl; 36 | Enum& newEnum = 37 | detail::EnumManager::instance() 38 | .addClass(typeDecl::id(false), name.empty() ? typeDecl::name(false) : name); 39 | return EnumBuilder(newEnum); 40 | } 41 | 42 | template 43 | void Enum::undeclare() 44 | { 45 | detail::EnumManager::instance().removeClass(detail::getTypeId()); 46 | } 47 | 48 | } // namespace ponder 49 | -------------------------------------------------------------------------------- /include/ponder/enumbuilder.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | #ifndef PONDER_ENUMBUILDER_HPP 32 | #define PONDER_ENUMBUILDER_HPP 33 | 34 | #include 35 | #include 36 | 37 | namespace ponder { 38 | 39 | class Enum; 40 | 41 | /** 42 | * \brief Proxy class which fills a metaenum with its members 43 | * 44 | * This class is returned by Enum::declare in order construct a 45 | * new metaenum. It contains functions to declare pairs to 46 | * fill the metaenum. 47 | * 48 | * This class should never be explicitely instantiated, unless you 49 | * need to split the metaenum creation in multiple parts. 50 | */ 51 | class PONDER_API EnumBuilder 52 | { 53 | public: 54 | 55 | /** 56 | * \brief Construct the builder with a target metaenum 57 | * 58 | * \param target Target metaenum to construct 59 | */ 60 | explicit EnumBuilder(Enum& target); 61 | 62 | /** 63 | * \brief Add a new pair to the metaenum 64 | * 65 | * \param name Name of the pair 66 | * \param value Value of the pair 67 | */ 68 | EnumBuilder& value(IdRef name, long value); 69 | 70 | /** 71 | * \brief Add a new pair to the metaenum using enum class 72 | * 73 | * e.g. `value("one", MyEnum::One)` 74 | * 75 | * \param name Name of the pair 76 | * \param enumValue Value of the pair 77 | */ 78 | template 79 | EnumBuilder& value(IdRef name, E enumValue) 80 | { 81 | return value(name, static_cast(enumValue)); 82 | } 83 | 84 | private: 85 | 86 | Enum* m_target; // Target metaenum to construct 87 | }; 88 | 89 | } // namespace ponder 90 | 91 | #endif // PONDER_ENUMBUILDER_HPP 92 | -------------------------------------------------------------------------------- /include/ponder/enumget.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | namespace ponder { 32 | 33 | inline size_t enumCount() 34 | { 35 | return detail::EnumManager::instance().count(); 36 | } 37 | 38 | inline const Enum& enumByName(IdRef name) 39 | { 40 | return detail::EnumManager::instance().getByName(name); 41 | } 42 | 43 | template 44 | const Enum& enumByObject(T) 45 | { 46 | return detail::EnumManager::instance().getById(detail::getTypeId()); 47 | } 48 | 49 | template 50 | const Enum& enumByType() 51 | { 52 | return detail::EnumManager::instance().getById(detail::getTypeId()); 53 | } 54 | 55 | template 56 | const Enum* enumByTypeSafe() 57 | { 58 | return detail::EnumManager::instance().getByIdSafe(detail::calcTypeId()); 59 | } 60 | 61 | } // namespace ponder 62 | -------------------------------------------------------------------------------- /include/ponder/enumobject.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | namespace ponder { 31 | 32 | template 33 | inline EnumObject::EnumObject(T value, typename std::enable_if::value >::type*) 34 | : m_value(static_cast(value)) 35 | , m_enum(&enumByType()) 36 | {} 37 | 38 | template 39 | inline E EnumObject::value() const 40 | { 41 | return static_cast(value()); 42 | } 43 | 44 | } // namespace ponder 45 | -------------------------------------------------------------------------------- /include/ponder/enumproperty.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | #ifndef PONDER_ENUMPROPERTY_HPP 32 | #define PONDER_ENUMPROPERTY_HPP 33 | 34 | #include 35 | 36 | namespace ponder { 37 | 38 | class Enum; 39 | 40 | /** 41 | * \brief Specialized type of property for enums 42 | * 43 | */ 44 | class PONDER_API EnumProperty : public Property 45 | { 46 | public: 47 | 48 | /** 49 | * \brief Construct the property from its description 50 | * 51 | * \param name Name of the property 52 | * \param propEnum Eumeration the property is bound to 53 | */ 54 | EnumProperty(IdRef name, const Enum& propEnum); 55 | 56 | /** 57 | * \brief Destructor 58 | */ 59 | virtual ~EnumProperty(); 60 | 61 | /** 62 | * \brief Get the owner enum 63 | * 64 | * \return Enum the property is bound to 65 | */ 66 | const Enum& getEnum() const; 67 | 68 | /** 69 | * \brief Accept the visitation of a ClassVisitor 70 | * 71 | * \param visitor Visitor to accept 72 | */ 73 | void accept(ClassVisitor& visitor) const override; 74 | 75 | private: 76 | 77 | const Enum* m_enum; // Owner enum of the property 78 | }; 79 | 80 | } // namespace ponder 81 | 82 | #endif // PONDER_ENUMPROPERTY_HPP 83 | -------------------------------------------------------------------------------- /include/ponder/error.inl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | namespace ponder { 32 | 33 | template 34 | T Error::prepare(T error, const String& file, int line, const String& function) 35 | { 36 | error.m_location = String(file) + " (" + str(line) + " ) - " + function; 37 | return error; 38 | } 39 | 40 | template 41 | ponder::String Error::str(T value) 42 | { 43 | return detail::convert(value); 44 | } 45 | 46 | } // namespace ponder 47 | -------------------------------------------------------------------------------- /include/ponder/qt/qlist.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | #ifndef PONDER_QT_QLIST_HPP 32 | #define PONDER_QT_QLIST_HPP 33 | 34 | 35 | #include 36 | #include 37 | 38 | 39 | namespace ponder_ext 40 | { 41 | /* 42 | * \brief Specialization of ArrayMapper for QList 43 | */ 44 | template 45 | struct ArrayMapper > 46 | { 47 | typedef T ElementType; 48 | 49 | static bool dynamic() 50 | { 51 | return true; 52 | } 53 | 54 | static size_t size(const QList& arr) 55 | { 56 | return static_cast(arr.size()); 57 | } 58 | 59 | static const T& get(const QList& arr, size_t index) 60 | { 61 | return arr[static_cast(index)]; 62 | } 63 | 64 | static void set(QList& arr, size_t index, const T& value) 65 | { 66 | arr[static_cast(index)] = value; 67 | } 68 | 69 | static void insert(QList& arr, size_t before, const T& value) 70 | { 71 | arr.insert(static_cast(before), value); 72 | } 73 | 74 | static void remove(QList& arr, size_t index) 75 | { 76 | arr.removeAt(static_cast(index)); 77 | } 78 | }; 79 | 80 | } // namespace ponder_ext 81 | 82 | 83 | #endif // PONDER_QT_QLIST_HPP 84 | -------------------------------------------------------------------------------- /include/ponder/qt/qstring.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | #ifndef PONDER_QT_QSTRING_HPP 32 | #define PONDER_QT_QSTRING_HPP 33 | 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | 40 | namespace ponder_ext 41 | { 42 | /** 43 | * \brief Value mapper for QString 44 | * 45 | * This class tells Ponder how to handle QString as a string type 46 | */ 47 | template <> 48 | struct ValueMapper 49 | { 50 | /** 51 | * \brief Ponder type associated to QString 52 | */ 53 | static const int type = ponder::ValueKind::String; 54 | 55 | /** 56 | * \brief Convert from QString to ponder::String 57 | * 58 | * \param source Source QString instance to convert 59 | * 60 | * \return \a source converted to a ponder::String 61 | */ 62 | static ponder::String to(const QString& source) 63 | { 64 | return source.toStdString(); 65 | } 66 | 67 | /** 68 | * \brief Convert from any type to QString 69 | * 70 | * We simply reuse ValueMapper. 71 | * 72 | * \param source Source value to convert 73 | * 74 | * \return \a source converted to a QString 75 | */ 76 | template 77 | static QString from(const T& source) 78 | { 79 | return QString::fromStdString(ValueMapper::from(source)); 80 | } 81 | }; 82 | 83 | } // namespace ponder_ext 84 | 85 | 86 | #endif // PONDER_QT_QSTRING_HPP 87 | -------------------------------------------------------------------------------- /include/ponder/qt/qt.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | #ifndef PONDER_QT_QT_HPP 32 | #define PONDER_QT_QT_HPP 33 | 34 | 35 | /** 36 | * This file extends Ponder for the Qt library; it contains all the mappings needed to 37 | * make Qt work seamlessly with Ponder: 38 | * - QString is declared as a string type 39 | * - QVector and QList are declared as array types 40 | * - QMapper maps Qt properties to Ponder properties 41 | */ 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | 49 | #endif // PONDER_QT_QT_HPP 50 | -------------------------------------------------------------------------------- /include/ponder/qt/qvector.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | 31 | #ifndef PONDER_QT_QVECTOR_HPP 32 | #define PONDER_QT_QVECTOR_HPP 33 | 34 | 35 | #include 36 | #include 37 | 38 | 39 | namespace ponder_ext 40 | { 41 | /* 42 | * \brief Specialization of ArrayMapper for QVector 43 | */ 44 | template 45 | struct ArrayMapper > 46 | { 47 | typedef T ElementType; 48 | 49 | static bool dynamic() 50 | { 51 | return true; 52 | } 53 | 54 | static size_t size(const QVector& arr) 55 | { 56 | return static_cast(arr.size()); 57 | } 58 | 59 | static const T& get(const QVector& arr, size_t index) 60 | { 61 | return arr[static_cast(index)]; 62 | } 63 | 64 | static void set(QVector& arr, size_t index, const T& value) 65 | { 66 | arr[static_cast(index)] = value; 67 | } 68 | 69 | static void insert(QVector& arr, size_t before, const T& value) 70 | { 71 | arr.insert(static_cast(before), value); 72 | } 73 | 74 | static void remove(QVector& arr, size_t index) 75 | { 76 | arr.remove(static_cast(index)); 77 | } 78 | }; 79 | 80 | } // namespace ponder_ext 81 | 82 | 83 | #endif // PONDER_QT_QVECTOR_HPP 84 | -------------------------------------------------------------------------------- /include/ponder/simpleproperty.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | #ifndef PONDER_SIMPLEPROPERTY_HPP 32 | #define PONDER_SIMPLEPROPERTY_HPP 33 | 34 | #include 35 | 36 | namespace ponder 37 | { 38 | /** 39 | * \brief Base class for all simple types of properties 40 | * 41 | * This class actually does nothing more than its base, it's just a way to separate 42 | * simple properties from other types. 43 | * 44 | * \sa ArrayProperty, EnumProperty, ObjectProperty 45 | */ 46 | class PONDER_API SimpleProperty : public Property 47 | { 48 | public: 49 | 50 | /** 51 | * \brief Construct the property from its description 52 | * 53 | * \param name Name of the property 54 | * \param type Type of the property 55 | */ 56 | SimpleProperty(IdRef name, ValueKind type); 57 | 58 | /** 59 | * \brief Destructor 60 | */ 61 | virtual ~SimpleProperty(); 62 | 63 | /** 64 | * \brief Accept the visitation of a ClassVisitor 65 | * 66 | * \param visitor Visitor to accept 67 | */ 68 | void accept(ClassVisitor& visitor) const override; 69 | }; 70 | 71 | } // namespace ponder 72 | 73 | #endif // PONDER_SIMPLEPROPERTY_HPP 74 | -------------------------------------------------------------------------------- /include/ponder/userdata.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2015-2020 Nick Trout. 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 17 | ** all 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 25 | ** THE SOFTWARE. 26 | ** 27 | ****************************************************************************/ 28 | 29 | #pragma once 30 | #ifndef PONDER_USERDATA_HPP 31 | #define PONDER_USERDATA_HPP 32 | 33 | #include 34 | #include 35 | 36 | namespace ponder { 37 | 38 | /** 39 | * \brief Name-value user data 40 | * 41 | * This is used to store user data for declared Types. The name is a string 42 | * and the Value can store any of the allowed types. 43 | * 44 | * \snippet userdata.cpp userdata_example 45 | */ 46 | class UserData 47 | { 48 | public: 49 | /** \brief Constructor 50 | * \param name : Id string 51 | * \param value : user Value 52 | */ 53 | UserData(IdRef name, Value&& value) : m_name(name), m_value(value) {} 54 | 55 | /** \brief Get the UserData name. 56 | * \return Id name 57 | */ 58 | IdReturn getName() const { return m_name; } 59 | 60 | /** \brief Get the Value 61 | * \return const Value 62 | */ 63 | const Value& getValue() const { return m_value; } 64 | //Value& getValue() { return m_value; } 65 | 66 | private: 67 | Id m_name; 68 | Value m_value; 69 | }; 70 | 71 | /** 72 | * \brief Interface to UserData store. 73 | */ 74 | class IUserDataStore 75 | { 76 | public: 77 | virtual ~IUserDataStore() {} 78 | virtual void setValue(const Type& t, IdRef name, const Value& v) = 0; 79 | virtual const Value* getValue(const Type& t, IdRef name) const = 0; 80 | virtual void removeValue(const Type& t, IdRef name) = 0; 81 | }; 82 | 83 | PONDER_API IUserDataStore* userDataStore(); 84 | 85 | } // namespace ponder 86 | 87 | #endif // PONDER_USERDATA_HPP 88 | -------------------------------------------------------------------------------- /include/ponder/userproperty.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #pragma once 31 | #ifndef PONDER_USERPROPERTY_HPP 32 | #define PONDER_USERPROPERTY_HPP 33 | 34 | #include 35 | 36 | namespace ponder 37 | { 38 | class Class; 39 | 40 | /** 41 | * \brief Specialized type of property for user types. 42 | */ 43 | class PONDER_API UserProperty : public Property 44 | { 45 | public: 46 | 47 | /** 48 | * \brief Construct the property from its description 49 | * 50 | * \param name Name of the property 51 | * \param propClass Eumeration the property is bound to 52 | */ 53 | UserProperty(IdRef name, const Class& propClass); 54 | 55 | /** 56 | * \brief Destructor 57 | */ 58 | virtual ~UserProperty(); 59 | 60 | /** 61 | * \brief Get the owner class 62 | * 63 | * \return Class the property is bound to 64 | */ 65 | const Class& getClass() const; 66 | 67 | /** 68 | * \brief Accept the visitation of a ClassVisitor 69 | * 70 | * \param visitor Visitor to accept 71 | */ 72 | void accept(ClassVisitor& visitor) const override; 73 | 74 | private: 75 | 76 | const Class* m_class; ///< Owner class of the property 77 | }; 78 | 79 | } // namespace ponder 80 | 81 | #endif // PONDER_ENUMPROPERTY_HPP 82 | -------------------------------------------------------------------------------- /src/args.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | const Args Args::empty; 36 | 37 | size_t Args::count() const 38 | { 39 | return m_values.size(); 40 | } 41 | 42 | const Value& Args::operator[](size_t index) const 43 | { 44 | // Make sure that the index is not out of range 45 | if (index >= m_values.size()) 46 | PONDER_ERROR(OutOfRange(index, m_values.size())); 47 | 48 | return m_values[index]; 49 | } 50 | 51 | Args Args::operator+(const Value& arg) const 52 | { 53 | Args newArgs(*this); 54 | newArgs += arg; 55 | 56 | return newArgs; 57 | } 58 | 59 | Args& Args::operator+=(const Value& arg) 60 | { 61 | m_values.push_back(arg); 62 | 63 | return *this; 64 | } 65 | 66 | Args& Args::insert(size_t index, const Value& v) 67 | { 68 | m_values.insert(m_values.begin() + index, v); 69 | return *this; 70 | } 71 | 72 | } // namespace ponder 73 | -------------------------------------------------------------------------------- /src/classcast.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | void* classCast(void* pointer, const Class& sourceClass, const Class& targetClass) 36 | { 37 | return sourceClass.applyOffset(pointer, targetClass); 38 | } 39 | 40 | } // namespace ponder 41 | -------------------------------------------------------------------------------- /src/classvisitor.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | 32 | namespace ponder { 33 | 34 | ClassVisitor::~ClassVisitor() 35 | { 36 | // Nothing to do 37 | } 38 | 39 | void ClassVisitor::visit(const Property&) 40 | { 41 | // The default implementation does nothing 42 | } 43 | 44 | void ClassVisitor::visit(const SimpleProperty&) 45 | { 46 | // The default implementation does nothing 47 | } 48 | 49 | void ClassVisitor::visit(const ArrayProperty&) 50 | { 51 | // The default implementation does nothing 52 | } 53 | 54 | void ClassVisitor::visit(const EnumProperty&) 55 | { 56 | // The default implementation does nothing 57 | } 58 | 59 | void ClassVisitor::visit(const UserProperty&) 60 | { 61 | // The default implementation does nothing 62 | } 63 | 64 | void ClassVisitor::visit(const Function&) 65 | { 66 | // The default implementation does nothing 67 | } 68 | 69 | ClassVisitor::ClassVisitor() 70 | { 71 | // Nothing to do 72 | } 73 | 74 | } // namespace ponder 75 | -------------------------------------------------------------------------------- /src/enum.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | Enum::Enum(IdRef name) 36 | : m_name(name) 37 | { 38 | } 39 | 40 | IdReturn Enum::name() const 41 | { 42 | return m_name; 43 | } 44 | 45 | size_t Enum::size() const 46 | { 47 | return m_enums.size(); 48 | } 49 | 50 | Enum::Pair Enum::pair(size_t index) const 51 | { 52 | // Make sure that the index is not out of range 53 | if (index >= m_enums.size()) 54 | PONDER_ERROR(OutOfRange(index, m_enums.size())); 55 | 56 | auto it = m_enums.at(index); 57 | return Pair(it->first, it->second); 58 | } 59 | 60 | bool Enum::hasName(IdRef name) const 61 | { 62 | return m_enums.containsKey(name); 63 | } 64 | 65 | bool Enum::hasValue(EnumValue value) const 66 | { 67 | return m_enums.containsValue(value); 68 | } 69 | 70 | IdReturn Enum::name(EnumValue value) const 71 | { 72 | auto it = m_enums.findValue(value); 73 | 74 | if (it == m_enums.end()) 75 | PONDER_ERROR(EnumValueNotFound(value, name())); 76 | 77 | return it->first; 78 | } 79 | 80 | Enum::EnumValue Enum::value(IdRef name) const 81 | { 82 | auto it = m_enums.findKey(name); 83 | 84 | if (it == m_enums.end()) 85 | PONDER_ERROR(EnumNameNotFound(name, m_name)); 86 | 87 | return it->second; 88 | } 89 | 90 | bool Enum::operator == (const Enum& other) const 91 | { 92 | return name() == other.name(); 93 | } 94 | 95 | bool Enum::operator != (const Enum& other) const 96 | { 97 | return name() != other.name(); 98 | } 99 | 100 | } // namespace ponder 101 | -------------------------------------------------------------------------------- /src/enumbuilder.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | EnumBuilder::EnumBuilder(Enum& target) 36 | : m_target(&target) 37 | { 38 | } 39 | 40 | EnumBuilder& EnumBuilder::value(IdRef name, Enum::EnumValue value) 41 | { 42 | assert(!m_target->hasName(name)); 43 | assert(!m_target->hasValue(value)); 44 | 45 | m_target->m_enums.insert(name, value); 46 | 47 | return *this; 48 | } 49 | 50 | } // namespace ponder 51 | -------------------------------------------------------------------------------- /src/enumobject.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | long EnumObject::value() const 36 | { 37 | return m_value; 38 | } 39 | 40 | IdReturn EnumObject::name() const 41 | { 42 | return m_enum->name(m_value); 43 | } 44 | 45 | const Enum& EnumObject::getEnum() const 46 | { 47 | return *m_enum; 48 | } 49 | 50 | bool EnumObject::operator==(const EnumObject& other) const 51 | { 52 | return (m_enum == other.m_enum) && (m_value == other.m_value); 53 | } 54 | 55 | bool EnumObject::operator<(const EnumObject& other) const 56 | { 57 | if (m_enum != other.m_enum) 58 | { 59 | return m_enum < other.m_enum; 60 | } 61 | else 62 | { 63 | return m_value < other.m_value; 64 | } 65 | } 66 | 67 | } // namespace ponder 68 | -------------------------------------------------------------------------------- /src/enumproperty.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | EnumProperty::EnumProperty(IdRef name, const Enum& propEnum) 36 | : Property(name, ValueKind::Enum) 37 | , m_enum(&propEnum) 38 | { 39 | } 40 | 41 | EnumProperty::~EnumProperty() 42 | { 43 | } 44 | 45 | const Enum& EnumProperty::getEnum() const 46 | { 47 | return *m_enum; 48 | } 49 | 50 | void EnumProperty::accept(ClassVisitor& visitor) const 51 | { 52 | visitor.visit(*this); 53 | } 54 | 55 | } // namespace ponder 56 | -------------------------------------------------------------------------------- /src/error.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | 32 | namespace ponder { 33 | 34 | Error::~Error() throw() 35 | { 36 | } 37 | 38 | const char* Error::what() const throw() 39 | { 40 | return m_message.c_str(); 41 | } 42 | 43 | const char* Error::where() const throw() 44 | { 45 | return m_location.c_str(); 46 | } 47 | 48 | Error::Error(IdRef message) 49 | : m_message(message) 50 | , m_location("") 51 | { 52 | } 53 | 54 | } // namespace ponder 55 | -------------------------------------------------------------------------------- /src/function.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace ponder { 35 | 36 | Function::~Function() 37 | { 38 | } 39 | 40 | IdReturn Function::name() const 41 | { 42 | return m_name; 43 | } 44 | 45 | ValueKind Function::returnType() const 46 | { 47 | return m_returnType; 48 | } 49 | 50 | void Function::accept(ClassVisitor& visitor) const 51 | { 52 | visitor.visit(*this); 53 | } 54 | 55 | } // namespace ponder 56 | -------------------------------------------------------------------------------- /src/observer.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace ponder { 35 | 36 | Observer::~Observer() 37 | { 38 | // Nothing to do 39 | } 40 | 41 | void Observer::classAdded(const Class&) 42 | { 43 | // Default implementation does nothing 44 | } 45 | 46 | void Observer::classRemoved(const Class&) 47 | { 48 | // Default implementation does nothing 49 | } 50 | 51 | void Observer::enumAdded(const Enum&) 52 | { 53 | // Default implementation does nothing 54 | } 55 | 56 | void Observer::enumRemoved(const Enum&) 57 | { 58 | // Default implementation does nothing 59 | } 60 | 61 | Observer::Observer() 62 | { 63 | // Nothing to do 64 | } 65 | 66 | PONDER_API void addObserver(Observer* observer) 67 | { 68 | detail::ClassManager::instance().addObserver(observer); 69 | detail::EnumManager::instance().addObserver(observer); 70 | } 71 | 72 | PONDER_API void removeObserver(Observer* observer) 73 | { 74 | detail::ClassManager::instance().removeObserver(observer); 75 | detail::EnumManager::instance().removeObserver(observer); 76 | } 77 | 78 | } // namespace ponder 79 | -------------------------------------------------------------------------------- /src/observernotifier.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace ponder { 35 | namespace detail { 36 | 37 | void ObserverNotifier::addObserver(Observer* observer) 38 | { 39 | assert(observer != nullptr); 40 | 41 | m_observers.insert(observer); 42 | } 43 | 44 | void ObserverNotifier::removeObserver(Observer* observer) 45 | { 46 | m_observers.erase(observer); 47 | } 48 | 49 | ObserverNotifier::ObserverNotifier() 50 | { 51 | } 52 | 53 | void ObserverNotifier::notifyClassAdded(const Class& theClass) 54 | { 55 | for (ObserverSet::iterator it = m_observers.begin(); it != m_observers.end(); ++it) 56 | { 57 | (*it)->classAdded(theClass); 58 | } 59 | } 60 | 61 | void ObserverNotifier::notifyClassRemoved(const Class& theClass) 62 | { 63 | for (ObserverSet::iterator it = m_observers.begin(); it != m_observers.end(); ++it) 64 | { 65 | (*it)->classRemoved(theClass); 66 | } 67 | } 68 | 69 | void ObserverNotifier::notifyEnumAdded(const Enum& theEnum) 70 | { 71 | for (ObserverSet::iterator it = m_observers.begin(); it != m_observers.end(); ++it) 72 | { 73 | (*it)->enumAdded(theEnum); 74 | } 75 | } 76 | 77 | void ObserverNotifier::notifyEnumRemoved(const Enum& theEnum) 78 | { 79 | for (ObserverSet::iterator it = m_observers.begin(); it != m_observers.end(); ++it) 80 | { 81 | (*it)->enumRemoved(theEnum); 82 | } 83 | } 84 | 85 | } // namespace details 86 | } // namespace ponder 87 | -------------------------------------------------------------------------------- /src/pondertype.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace ponder { 35 | namespace detail { 36 | 37 | void ensureTypeRegistered(TypeId const& id, void (*registerFunc)()) 38 | { 39 | if (registerFunc 40 | && !ClassManager::instance().classExists(id) 41 | && !EnumManager::instance().enumExists(id)) 42 | { 43 | registerFunc(); 44 | } 45 | } 46 | 47 | } // namespace detail 48 | } // namespace ponder 49 | -------------------------------------------------------------------------------- /src/property.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | Property::~Property() 36 | { 37 | } 38 | 39 | IdReturn Property::name() const 40 | { 41 | return m_name; 42 | } 43 | 44 | ValueKind Property::kind() const 45 | { 46 | return m_type; 47 | } 48 | 49 | bool Property::isReadable() const 50 | { 51 | return true; 52 | } 53 | 54 | bool Property::isWritable() const 55 | { 56 | return true; 57 | } 58 | 59 | Value Property::get(const UserObject& object) const 60 | { 61 | // Check if the property is readable 62 | if (!isReadable()) 63 | PONDER_ERROR(ForbiddenRead(name())); 64 | 65 | return getValue(object); 66 | } 67 | 68 | void Property::set(const UserObject& object, const Value& value) const 69 | { 70 | // Check if the property is writable 71 | if (!isWritable()) 72 | PONDER_ERROR(ForbiddenWrite(name())); 73 | 74 | // Here we don't call setValue directly, we rather let the user object do it 75 | // and add any processing needed for proper propagation of the modification 76 | object.set(*this, value); 77 | } 78 | 79 | void Property::accept(ClassVisitor& visitor) const 80 | { 81 | visitor.visit(*this); 82 | } 83 | 84 | Property::Property(IdRef name, ValueKind type) 85 | : m_name(name) 86 | , m_type(type) 87 | { 88 | } 89 | 90 | } // namespace ponder 91 | -------------------------------------------------------------------------------- /src/simpleproperty.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | SimpleProperty::SimpleProperty(IdRef name, ValueKind type) 36 | : Property(name, type) 37 | { 38 | } 39 | 40 | SimpleProperty::~SimpleProperty() 41 | { 42 | } 43 | 44 | void SimpleProperty::accept(ClassVisitor& visitor) const 45 | { 46 | visitor.visit(*this); 47 | } 48 | 49 | } // namespace ponder 50 | -------------------------------------------------------------------------------- /src/userproperty.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | 33 | namespace ponder { 34 | 35 | UserProperty::UserProperty(IdRef name, const Class& propClass) 36 | : Property(name, ValueKind::User) 37 | , m_class(&propClass) 38 | { 39 | } 40 | 41 | UserProperty::~UserProperty() 42 | { 43 | } 44 | 45 | const Class& UserProperty::getClass() const 46 | { 47 | return *m_class; 48 | } 49 | 50 | void UserProperty::accept(ClassVisitor& visitor) const 51 | { 52 | visitor.visit(*this); 53 | } 54 | 55 | } // namespace ponder 56 | -------------------------------------------------------------------------------- /src/value.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | 32 | namespace ponder { 33 | 34 | const Value Value::nothing; 35 | 36 | Value::Value() 37 | : m_value(NoType()) 38 | , m_type(ValueKind::None) 39 | { 40 | } 41 | 42 | Value::Value(const Value& other) 43 | : m_value(other.m_value) 44 | , m_type(other.m_type) 45 | { 46 | } 47 | 48 | Value::Value(Value&& other) 49 | { 50 | std::swap(m_value, other.m_value); 51 | std::swap(m_type, other.m_type); 52 | } 53 | 54 | void Value::operator = (const Value& other) 55 | { 56 | m_value = other.m_value; 57 | m_type = other.m_type; 58 | } 59 | 60 | ValueKind Value::kind() const 61 | { 62 | return m_type; 63 | } 64 | 65 | bool Value::operator == (const Value& other) const 66 | { 67 | return visit(detail::EqualVisitor(), other); 68 | } 69 | 70 | bool Value::operator < (const Value& other) const 71 | { 72 | return visit(detail::LessThanVisitor(), other); 73 | } 74 | 75 | std::istream& operator >> (std::istream& stream, Value& value) 76 | { 77 | // Use the string conversion 78 | // ponder::Id str; 79 | // stream >> str; 80 | // value = str; 81 | return stream; 82 | } 83 | 84 | std::ostream& operator << (std::ostream& stream, const Value& value) 85 | { 86 | // Use the string conversion 87 | return stream; // << value.to(); 88 | } 89 | 90 | } // namespace ponder 91 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ## 3 | ## Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 4 | ## Contact: Tegesoft Information (contact@tegesoft.com) 5 | ## 6 | ## This file is part of the Ponder library, formerly CAMP. 7 | ## 8 | ## The MIT License (MIT) 9 | ## 10 | ## Copyright (c) 2009-2014 TEGESO/TEGESOFT 11 | ## Copyright (C) 2015-2020 Nick Trout. 12 | ## 13 | ## Permission is hereby granted, free of charge, to any person obtaining a copy 14 | ## of this software and associated documentation files (the "Software"), to deal 15 | ## in the Software without restriction, including without limitation the rights 16 | ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | ## copies of the Software, and to permit persons to whom the Software is 18 | ## furnished to do so, subject to the following conditions: 19 | ## 20 | ## The above copyright notice and this permission notice shall be included in 21 | ## all copies or substantial portions of the Software. 22 | ## 23 | ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 | ## THE SOFTWARE. 30 | ## 31 | ############################################################################### 32 | 33 | 34 | add_subdirectory(ponder) 35 | 36 | if(BUILD_TEST_EXAMPLES) 37 | add_subdirectory(examples) 38 | endif() 39 | 40 | if(BUILD_TEST_LUA) 41 | add_subdirectory(lua) 42 | endif() 43 | 44 | # add the qt subdirectory, but do not build it by default 45 | if(BUILD_TEST_QT) 46 | add_subdirectory(qt) 47 | endif() 48 | 49 | 50 | -------------------------------------------------------------------------------- /test/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ## 3 | ## This file is part of the Ponder library. 4 | ## 5 | ## The MIT License (MIT) 6 | ## 7 | ## Copyright (C) 2015-2015-2020 Nick Trout. 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 17 | ## all 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 25 | ## THE SOFTWARE. 26 | ## 27 | ############################################################################### 28 | 29 | # set project's name 30 | project(exampletest) 31 | 32 | # all source files 33 | set(TEST_SRCS 34 | test.hpp 35 | declare.cpp 36 | inspect.cpp 37 | simple.cpp 38 | shapes.cpp 39 | userdata.cpp 40 | main.cpp 41 | ) 42 | 43 | link_directories( 44 | ${PONDER_BINARY_DIR} 45 | ) 46 | 47 | add_executable(egtest ${TEST_SRCS}) 48 | 49 | target_link_libraries(egtest ponder) 50 | 51 | # Add the executable as a CTest 52 | add_test(egtest egtest) 53 | 54 | -------------------------------------------------------------------------------- /test/examples/declare.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2015-2020 Nick Trout. 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 17 | ** all 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 25 | ** THE SOFTWARE. 26 | ** 27 | ****************************************************************************/ 28 | 29 | #include "test.hpp" 30 | 31 | //! [eg_declare] 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | //! [eg_declare_template1] 38 | 39 | // Templated class. 40 | template 41 | struct Data 42 | { 43 | typedef T Type; 44 | Data(Type v) : m_value(v) {} 45 | Type m_value; 46 | }; 47 | 48 | template 49 | static void declare_Data() 50 | { 51 | // Declare type Data 52 | ponder::Class::declare>() 53 | .template constructor() 54 | .property("value", &Data::m_value) 55 | ; 56 | } 57 | 58 | // Register the types with Ponder 59 | PONDER_TYPE(Data); 60 | PONDER_TYPE(Data); 61 | PONDER_TYPE(Data); 62 | 63 | void declare() 64 | { 65 | // Declare the type instances 66 | declare_Data(); 67 | declare_Data(); 68 | declare_Data(); 69 | } 70 | 71 | //! [eg_declare_template1] 72 | 73 | //! [eg_declare] 74 | 75 | TEST_CASE("declare") 76 | { 77 | declare(); 78 | } 79 | 80 | -------------------------------------------------------------------------------- /test/examples/inspect.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2015-2020 Nick Trout. 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 17 | ** all 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 25 | ** THE SOFTWARE. 26 | ** 27 | ****************************************************************************/ 28 | 29 | #include "test.hpp" 30 | 31 | //#include 32 | #include 33 | #include 34 | #include 35 | 36 | //! [inspect_example] 37 | 38 | //class A 39 | //{ 40 | //public: 41 | // A(int v) : m_value(v) {} 42 | // 43 | // int getValue() const { return m_value; } 44 | // 45 | //private: 46 | // int m_value; 47 | //}; 48 | // 49 | //PONDER_TYPE(A) 50 | // 51 | //static void declare() 52 | //{ 53 | // ponder::Class::declare("A") 54 | // .constructor() 55 | // .property("value", &A::getValue) 56 | // ; 57 | //} 58 | // 59 | //static void inspect() 60 | //{ 61 | // //! [classIterator] 62 | // for (auto&& cls : ponder::classIterator()) 63 | // { 64 | // std::cout << "Class " << cls.first << std::endl; 65 | // } 66 | // //! [classIterator] 67 | //} 68 | // 69 | ////! [inspect_example] 70 | // 71 | //// static void reportAll() 72 | //// { 73 | //// ponder::uses::reportAll(); 74 | //// } 75 | // 76 | //TEST_CASE("declare types") 77 | //{ 78 | // SECTION("intro") 79 | // { 80 | // ponder::Args args(1, true, "hello", 5.24, myObject); 81 | // } 82 | // 83 | // SECTION("intro") 84 | // { 85 | // std::printf("------------------------------------------------------------\n"); 86 | // declare(); 87 | // inspect(); 88 | // } 89 | //} 90 | 91 | 92 | -------------------------------------------------------------------------------- /test/examples/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2015-2020 Nick Trout. 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 17 | ** all 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 25 | ** THE SOFTWARE. 26 | ** 27 | ****************************************************************************/ 28 | 29 | #include 30 | 31 | #define PONDER_USES_RUNTIME_IMPL 32 | #include 33 | 34 | // This must be defined once in the entire project 35 | #define CATCH_CONFIG_MAIN 36 | #include "test.hpp" 37 | 38 | -------------------------------------------------------------------------------- /test/examples/serialise.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2015-2020 Nick Trout. 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 17 | ** all 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 25 | ** THE SOFTWARE. 26 | ** 27 | ****************************************************************************/ 28 | 29 | #include "test.hpp" 30 | 31 | //! [eg_serialise] 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | 38 | //! [eg_serialise] 39 | 40 | -------------------------------------------------------------------------------- /test/examples/test.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../catch.hpp" 4 | 5 | // see https://github.com/philsquared/Catch/blob/master/docs/tostring.md 6 | 7 | // Catch REQUIRE(x == y) converts x & y to strings so it can report errors. This causes 8 | // a problem if x or y don't convert, so use ((x == y) == true) instead. 9 | #define IS_TRUE(T) REQUIRE((T)) 10 | #define IS_FALSE(T) REQUIRE_FALSE((T)) 11 | #define IS_EQUAL(X,Y) REQUIRE(X == Y) 12 | 13 | -------------------------------------------------------------------------------- /test/lua/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ## 3 | ## This file is part of the Ponder library. 4 | ## 5 | ## The MIT License (MIT) 6 | ## 7 | ## Copyright (C) 2015-2020 Nick Trout. 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 17 | ## all 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 25 | ## THE SOFTWARE. 26 | ## 27 | ############################################################################### 28 | 29 | project(luatest) 30 | 31 | link_directories(${PONDER_BINARY_DIR}) 32 | 33 | add_executable(luatest main.cpp) 34 | 35 | target_compile_definitions(luatest PUBLIC PONDER_USING_LUA=1) 36 | 37 | if(UNIX) 38 | target_link_libraries(luatest ponder lua) 39 | else(UNIX) 40 | target_link_libraries(luatest ponder liblua) 41 | endif(UNIX) 42 | 43 | add_test(luatest luatest) # Add the executable as a CTest 44 | 45 | -------------------------------------------------------------------------------- /test/ponder/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the Ponder library, formerly CAMP. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Copyright (C) 2015-2020 Nick Trout. 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | 32 | #define PONDER_USES_RUNTIME_IMPL 33 | #include 34 | 35 | // This must be defined once in the entire project 36 | #define CATCH_CONFIG_MAIN 37 | #include "test.hpp" 38 | 39 | -------------------------------------------------------------------------------- /test/ponder/test.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../catch.hpp" 4 | 5 | #include 6 | #include 7 | 8 | // see https://github.com/philsquared/Catch/blob/master/docs/tostring.md 9 | 10 | // Catch REQUIRE(x == y) converts x & y to strings so it can report errors. This causes 11 | // a problem if x or y don't convert, so use ((x == y) == true) instead. 12 | #define IS_TRUE(T) REQUIRE((T)) 13 | #define IS_FALSE(T) REQUIRE_FALSE((T)) 14 | #define IS_EQUAL(X,Y) REQUIRE(X == Y) 15 | 16 | #define STATIC_ASSERT(T) static_assert((T), "static_assert failure: " #T) 17 | 18 | #define UNUSED(V) ((void)&(V)) 19 | 20 | inline std::ostream& operator << (std::ostream& stream, const ponder::Value& value) 21 | { 22 | return stream << value.to(); 23 | } 24 | -------------------------------------------------------------------------------- /test/qt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | ## 3 | ## Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 4 | ## Contact: Tegesoft Information (contact@tegesoft.com) 5 | ## 6 | ## This file is part of the CAMP library. 7 | ## 8 | ## The MIT License (MIT) 9 | ## 10 | ## Copyright (c) 2009-2014 TEGESO/TEGESOFT 11 | ## 12 | ## Permission is hereby granted, free of charge, to any person obtaining a copy 13 | ## of this software and associated documentation files (the "Software"), to deal 14 | ## in the Software without restriction, including without limitation the rights 15 | ## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | ## copies of the Software, and to permit persons to whom the Software is 17 | ## furnished to do so, subject to the following conditions: 18 | ## 19 | ## The above copyright notice and this permission notice shall be included in 20 | ## all copies or substantial portions of the Software. 21 | ## 22 | ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | ## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | ## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 26 | ## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 27 | ## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 28 | ## THE SOFTWARE. 29 | ## 30 | ############################################################################### 31 | 32 | 33 | cmake_minimum_required(VERSION 2.6) 34 | 35 | # set project's name 36 | project(PONDER_TEST_QT) 37 | 38 | # all source files 39 | set(PONDER_TEST_QT_SRCS 40 | main.cpp 41 | functionmapping.cpp 42 | functionmapping.hpp 43 | propertymapping.cpp 44 | propertymapping.hpp 45 | qstringmapping.cpp 46 | ) 47 | 48 | # find Boost 49 | find_package(Boost 1.38.0) # TODO - add Qt tests? port to Catch. 50 | 51 | # find Qt4 52 | find_package(Qt4 4.5.0 COMPONENTS QtCore REQUIRED) 53 | 54 | # add some useful macros and variables 55 | # (QT_USE_FILE is a variable defined by find_package( Qt4 ) that contains a path to CMake script) 56 | include(${QT_USE_FILE}) 57 | 58 | # this will run moc 59 | QT4_WRAP_CPP(PONDER_TEST_QT_MOC_SRCS functionmapping.hpp propertymapping.hpp) 60 | 61 | # include files search paths 62 | include_directories( 63 | ${Boost_INCLUDE_DIRS} 64 | ) 65 | 66 | # no implicit link to boost.test library 67 | add_definitions(-DBOOST_TEST_NO_LIB) 68 | 69 | # instruct CMake to build an executable from all of the source files 70 | add_executable(pondertest-qt ${PONDER_TEST_QT_SRCS} ${PONDER_TEST_QT_MOC_SRCS}) 71 | 72 | # last thing we have to do is to tell CMake what libraries our executable needs 73 | target_link_libraries(pondertest-qt ponder ${QT_LIBRARIES}) 74 | 75 | # Add the CTest 76 | add_test(pondertest-qt pondertest-qt) 77 | 78 | -------------------------------------------------------------------------------- /test/qt/functionmapping.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the CAMP library. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Contact: Tegesoft Information (contact@tegesoft.com) 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #ifndef PONDERTEST_QT_FUNCTIONMAPPING_HPP 31 | #define PONDERTEST_QT_FUNCTIONMAPPING_HPP 32 | 33 | #ifndef Q_MOC_RUN 34 | #include 35 | #include 36 | #include 37 | #endif 38 | #include 39 | #include 40 | #include 41 | 42 | namespace FunctionMappingTest 43 | { 44 | class MyClass : public QObject 45 | { 46 | Q_OBJECT 47 | 48 | public slots: 49 | 50 | void f1() 51 | { 52 | } 53 | 54 | bool f2(bool b) 55 | { 56 | return b; 57 | } 58 | 59 | int f3(int i1, int i2) 60 | { 61 | return i1 + i2; 62 | } 63 | 64 | long f4(long l1, long l2, long l3) 65 | { 66 | return l1 + l2 + l3; 67 | } 68 | 69 | double f5(double d1, double d2, double d3, double d4) 70 | { 71 | return d1 + d2 + d3 + d4; 72 | } 73 | 74 | QString f6(QString s1, QString s2, QString s3, QString s4, QString s5) 75 | { 76 | return s1 + s2 + s3 + s4 + s5; 77 | } 78 | }; 79 | 80 | inline void declare() 81 | { 82 | ponder::Class::declare("FunctionMappingTest::MyClass") 83 | .external(); 84 | } 85 | } 86 | 87 | PONDER_AUTO_TYPE_NONCOPYABLE(FunctionMappingTest::MyClass, &FunctionMappingTest::declare); 88 | 89 | // To make the boost.test logger happy 90 | inline std::ostream& operator<<(std::ostream& stream, const QString& string) 91 | { 92 | return stream << string.toStdString(); 93 | } 94 | 95 | #endif // PONDERTEST_QT_FUNCTIONMAPPING_HPP 96 | -------------------------------------------------------------------------------- /test/qt/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the CAMP library. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Contact: Tegesoft Information (contact@tegesoft.com) 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | // This must be defined once in the entire project 31 | #define BOOST_TEST_MODULE Ponder testqt 32 | 33 | // This will embed the whole source code of boost.test, 34 | // so that we don't need to link to it as an external library. 35 | // Note: to disable that and link to boost.test as a library, 36 | // simply remove "/included" from the header path below. 37 | #include 38 | -------------------------------------------------------------------------------- /test/qt/qstringmapping.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** This file is part of the CAMP library. 4 | ** 5 | ** The MIT License (MIT) 6 | ** 7 | ** Copyright (C) 2009-2014 TEGESO/TEGESOFT and/or its subsidiary(-ies) and mother company. 8 | ** Contact: Tegesoft Information (contact@tegesoft.com) 9 | ** 10 | ** Permission is hereby granted, free of charge, to any person obtaining a copy 11 | ** of this software and associated documentation files (the "Software"), to deal 12 | ** in the Software without restriction, including without limitation the rights 13 | ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | ** copies of the Software, and to permit persons to whom the Software is 15 | ** furnished to do so, subject to the following conditions: 16 | ** 17 | ** The above copyright notice and this permission notice shall be included in 18 | ** all copies or substantial portions of the Software. 19 | ** 20 | ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | ** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | ** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | ** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | ** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | ** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | ** THE SOFTWARE. 27 | ** 28 | ****************************************************************************/ 29 | 30 | #include 31 | #include 32 | #include "catch.hpp" 33 | #include 34 | 35 | // To make the boost.test logger happy 36 | inline std::ostream& operator<<(std::ostream& stream, const QString& string) 37 | { 38 | return stream << string.toStdString(); 39 | } 40 | 41 | //----------------------------------------------------------------------------- 42 | // Tests for camp_ext::ValueMapper 43 | //----------------------------------------------------------------------------- 44 | BOOST_AUTO_TEST_SUITE(QSTRING) 45 | 46 | BOOST_AUTO_TEST_CASE(type) 47 | { 48 | ponder::Value value = QString("hello"); 49 | 50 | BOOST_CHECK_EQUAL(value.kind(), ponder::stringType); 51 | } 52 | 53 | BOOST_AUTO_TEST_CASE(conversionsFromQString) 54 | { 55 | ponder::Value value = QString("-10"); 56 | 57 | BOOST_CHECK_EQUAL(value.to(), -10); 58 | BOOST_CHECK_CLOSE(value.to(), -10., 1E-5); 59 | BOOST_CHECK_EQUAL(value.to(), "-10"); 60 | BOOST_CHECK_EQUAL(value.to(), "-10"); 61 | } 62 | 63 | BOOST_AUTO_TEST_CASE(conversionsToQString) 64 | { 65 | BOOST_CHECK_EQUAL(ponder::Value(false).to(), QString("0")); 66 | BOOST_CHECK_EQUAL(ponder::Value(10).to(), QString("10")); 67 | BOOST_CHECK_EQUAL(ponder::Value(std::string("hello")).to(), QString("hello")); 68 | } 69 | 70 | BOOST_AUTO_TEST_SUITE_END() 71 | --------------------------------------------------------------------------------