File instance.hpp
File List > include > simplesquirrel > instance.hpp
Go to the documentation of this file.
#pragma once
#ifndef SSQ_INSTANCE_HEADER_H
#define SSQ_INSTANCE_HEADER_H
#include "object.hpp"
#include "args.hpp"
namespace ssq {
class Class;
class SSQ_API Instance: public Object {
public:
Instance();
virtual ~Instance() = default;
Instance(HSQUIRRELVM vm);
explicit Instance(const Object& object);
Instance(const Instance& other);
Instance(Instance&& other) NOEXCEPT;
Class getClass();
Instance& operator = (const Instance& other);
Instance& operator = (Instance&& other) NOEXCEPT;
};
class SSQ_API SqWeakRef: public Instance {
public:
SqWeakRef();
SqWeakRef(HSQUIRRELVM vm);
SqWeakRef(const SqWeakRef& other);
SqWeakRef(SqWeakRef&& other);
explicit SqWeakRef(const Instance& instance);
void swap(SqWeakRef& other);
SqWeakRef& operator = (const SqWeakRef& other);
SqWeakRef& operator = (SqWeakRef&& other);
};
#ifndef DOXYGEN_SHOULD_SKIP_THIS
namespace detail {
template<>
inline Instance popValue(HSQUIRRELVM vm, SQInteger index){
checkType(vm, index, OT_INSTANCE);
Instance val(vm);
if (SQ_FAILED(sq_getstackobj(vm, index, &val.getRaw()))) throw TypeException("Could not get Instance from squirrel stack");
sq_addref(vm, &val.getRaw());
return val;
}
template<>
inline SqWeakRef popValue(HSQUIRRELVM vm, SQInteger index){
checkType(vm, index, OT_INSTANCE);
SqWeakRef val(vm);
if (SQ_FAILED(sq_getstackobj(vm, index, &val.getRaw()))) throw TypeException("Could not get Instance from squirrel stack");
return val;
}
}
#endif
}
#endif