/* * moocpp/gboxed.h * * Copyright (C) 2004-2016 by Yevgen Muntyan * * This file is part of medit. medit is free software; you can * redistribute it and/or modify it under the terms of the * GNU Lesser General Public License as published by the * Free Software Foundation; either version 2.1 of the License, * or (at your option) any later version. * * You should have received a copy of the GNU Lesser General Public * License along with medit. If not, see . */ #pragma once #include #include #include namespace moo { template class gboxed_helper { public: static T* array_elm_copy(T* obj) { return new T(*obj); } static gpointer copy(gpointer p) { return array_elm_copy(reinterpret_cast(p)); } static void array_elm_free(T* obj) { delete obj; } static void free(gpointer p) { array_elm_free(reinterpret_cast(p)); } }; #define MOO_DEFINE_BOXED_CPP_TYPE(Object, object) \ MOO_DEFINE_BOXED_TYPE(Object, object, \ gboxed_helper::copy, \ gboxed_helper::free) } // namespace moo