From 15c824ddae14ee5027a755365489a98d2c34a802 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Thu, 17 Nov 2016 10:59:19 +0200 Subject: [PATCH] Implement a constructor in the lightweight object type that copies a regular object. --- include/sqrat/sqratObject.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/sqrat/sqratObject.h b/include/sqrat/sqratObject.h index edfe1c7f..ab7443c6 100644 --- a/include/sqrat/sqratObject.h +++ b/include/sqrat/sqratObject.h @@ -711,6 +711,18 @@ struct LightObject { } } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + /// Construct a LightObject from a regular Object instance. + /// + /// \param so Object to copy + /// + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + LightObject(const Object& obj) : mObj(obj.GetObject()) { + if (!sq_isnull(mObj)) { + sq_addref(obj.GetVM(), &mObj); + } + } + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Constructs an LightObject from a C++ instance ///