In January 2021 we will introduce a 10 GB quota for project repositories. Higher limits for individual projects will be available on request. Please see https://doku.lrz.de/display/PUBLIC/GitLab for more information.

Module.h 3.26 KB
Newer Older
Nikola Dinev's avatar
Nikola Dinev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
#pragma once

#include <vector>
#include <set>
#include <string>
#include <map>
#include <memory>

namespace elsa
{
    struct Module {
        struct Function {
            struct Parameter {
                std::string name;
                std::string type;
                std::string defaultValue;

                Parameter(std::string name, std::string type)
                    : name{name}, type{type}, defaultValue{""}
                {
                }

                Parameter(std::string name, std::string type, std::string defaultValue)
                    : name{name}, type{type}, defaultValue{defaultValue}
                {
                }
            };

            std::string name;
            std::string returnType;
            std::vector<Parameter> params;
            std::string refQualifier;
            std::size_t numDefaultArgs{0};

            // Some default arguments may not represent an rvalue or have side effects, and,
            // therefore, may not be (at least not easily) bindable using the standard method for
            // binding of default args. Upon encountering such an argument, it and all following
            // arguments should be converted to overloads instead. Set to the number of
            // arguments if all are bindable.
            std::size_t posFirstNonBindableDefaultArg{0};
            bool isStatic;
            bool isConstructor;
            bool isConst;
            bool isTemplate;

            constexpr static auto RQ_NONE = "";
            constexpr static auto RQ_LVAL = "&";
            constexpr static auto RQ_RVAL = "&&";
        };

        struct UserDefinedTag {
            std::string name;
            std::string namespaceStrippedName;
            std::string alias;

            virtual ~UserDefinedTag() = default;
        };

        // represents a class or struct
        struct Record : public UserDefinedTag {
            std::vector<std::string> bases;
            std::map<std::string, Function> methods;
            bool isAbstract;

            ~Record() override = default;
        };

        struct Enum : public UserDefinedTag {
            /// maps enumerator name to value
            /// the value is stored as a string, as an enum type may be as large as an unsigned long
            /// long or a (signed) long long, and the signedness must be determined on a per-enum
            /// basis
            std::map<std::string, std::string> values;
            bool isScoped;

            ~Enum() override = default;
        };

        struct ClassHints {
            std::string recordName;
            std::string classHintsName;
            std::set<std::string> ignoredMethods;
            bool definesCustomMethods{false};
            bool exposesBufferInfo{false};
        };

        std::string name;
        std::string path;
        std::string pythonName;
        std::vector<std::unique_ptr<UserDefinedTag>> tags;
        std::set<std::string> includes;
        std::set<std::string> pybindIncludes;

        struct ModuleHints {
            // path to hints file, empty if none is specified
            std::string includePath;
            bool definesGlobalCustomFunctions{false};
        };

        ModuleHints moduleHints;
        std::map<std::string, ClassHints> classHints;
    };
} // namespace elsa