File function.hpp

File List > include > simplesquirrel > function.hpp

Go to the documentation of this file.

#pragma once
#ifndef SSQ_FUNCTION_HEADER_H
#define SSQ_FUNCTION_HEADER_H

#include "object.hpp"
#include "exceptions.hpp"
#include "args.hpp"

namespace ssq {
    class SSQ_API Function: public Object {
    public:
        explicit Function(HSQUIRRELVM vm);
        virtual ~Function() = default;
        explicit Function(const Object& object);
        Function(const Function& other);
        Function(Function&& other) NOEXCEPT;
        unsigned int getNumOfParams() const;
        Function& operator = (const Function& other);
        Function& operator = (Function&& other) NOEXCEPT;
    };
#ifndef DOXYGEN_SHOULD_SKIP_THIS
    namespace detail {
        template<>
        inline Function popValue(HSQUIRRELVM vm, SQInteger index){
            checkType(vm, index, OT_CLOSURE);
            Function val(vm);
            if (SQ_FAILED(sq_getstackobj(vm, index, &val.getRaw()))) throw TypeException("Could not get Table from squirrel stack");
            sq_addref(vm, &val.getRaw());
            return val;
        }
    }
#endif
}

#endif