More C++
This commit is contained in:
parent
30e2a71627
commit
6ec8adce93
@ -43,4 +43,21 @@ inline T* object_ref(T *obj)
|
||||
return static_cast<T*>(g_object_ref(obj));
|
||||
}
|
||||
|
||||
struct class_helper
|
||||
{
|
||||
template<typename X>
|
||||
static size_t address(X* x)
|
||||
{
|
||||
return reinterpret_cast<size_t>(reinterpret_cast<const volatile char*>(x));
|
||||
}
|
||||
|
||||
template<typename Sup, typename Sub>
|
||||
static void verify_g_object_subclass_alignment()
|
||||
{
|
||||
Sup* x = nullptr;
|
||||
Sub* y = static_cast<Sub*>(x);
|
||||
moo_release_assert(class_helper::address(x) == class_helper::address(y));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace moo
|
||||
|
@ -58,7 +58,7 @@ SET(mooedit_sources
|
||||
mooedit/mooeditwindow.c
|
||||
mooedit/mooeditwindow-impl.h
|
||||
mooedit/mooeditfileinfo-impl.h
|
||||
mooedit/mooeditfileinfo.c
|
||||
mooedit/mooeditfileinfo.cpp
|
||||
mooedit/moofold.c
|
||||
mooedit/moofold.h
|
||||
mooedit/mooindenter.c
|
||||
|
@ -5,10 +5,8 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
struct MooOpenInfo
|
||||
struct MooOpenInfo : public GObject
|
||||
{
|
||||
GObject parent;
|
||||
|
||||
GFile *file;
|
||||
char *encoding;
|
||||
int line;
|
||||
@ -20,9 +18,7 @@ struct MooOpenInfoClass
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
struct MooReloadInfo {
|
||||
GObject parent;
|
||||
|
||||
struct MooReloadInfo : public GObject {
|
||||
char *encoding;
|
||||
int line;
|
||||
};
|
||||
@ -32,9 +28,7 @@ struct MooReloadInfoClass
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
struct MooSaveInfo {
|
||||
GObject parent;
|
||||
|
||||
struct MooSaveInfo : public GObject {
|
||||
GFile *file;
|
||||
char *encoding;
|
||||
};
|
||||
|
@ -21,6 +21,9 @@
|
||||
|
||||
#include "mooeditfileinfo-impl.h"
|
||||
#include <mooutils/mooutils-misc.h>
|
||||
#include <moocpp/gobjectutils.h>
|
||||
|
||||
using namespace moo;
|
||||
|
||||
static void moo_open_info_class_init (MooOpenInfoClass *klass);
|
||||
static void moo_save_info_class_init (MooSaveInfoClass *klass);
|
||||
@ -52,7 +55,7 @@ moo_open_info_new_file (GFile *file,
|
||||
|
||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||
|
||||
info = g_object_new (MOO_TYPE_OPEN_INFO, NULL);
|
||||
info = MOO_OPEN_INFO (g_object_new (MOO_TYPE_OPEN_INFO, NULL));
|
||||
|
||||
info->file = g_file_dup (file);
|
||||
info->encoding = g_strdup (encoding);
|
||||
@ -226,7 +229,7 @@ moo_open_info_set_line (MooOpenInfo *info,
|
||||
MooOpenFlags
|
||||
moo_open_info_get_flags (MooOpenInfo *info)
|
||||
{
|
||||
g_return_val_if_fail (MOO_IS_OPEN_INFO (info), 0);
|
||||
g_return_val_if_fail (MOO_IS_OPEN_INFO (info), MOO_OPEN_FLAGS_NONE);
|
||||
return info->flags;
|
||||
}
|
||||
|
||||
@ -293,7 +296,7 @@ moo_save_info_new_file (GFile *file,
|
||||
|
||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
||||
|
||||
info = g_object_new (MOO_TYPE_SAVE_INFO, NULL);
|
||||
info = MOO_SAVE_INFO (g_object_new (MOO_TYPE_SAVE_INFO, NULL));
|
||||
|
||||
info->file = g_file_dup (file);
|
||||
info->encoding = g_strdup (encoding);
|
||||
@ -397,7 +400,7 @@ moo_reload_info_new (const char *encoding,
|
||||
{
|
||||
MooReloadInfo *info;
|
||||
|
||||
info = g_object_new (MOO_TYPE_RELOAD_INFO, NULL);
|
||||
info = MOO_RELOAD_INFO (g_object_new (MOO_TYPE_RELOAD_INFO, NULL));
|
||||
|
||||
info->encoding = g_strdup (encoding);
|
||||
info->line = line;
|
@ -338,8 +338,11 @@ moo_editor_class_init (MooEditorClass *klass)
|
||||
g_type_class_unref (edit_window_class);
|
||||
|
||||
add_new_window_action ();
|
||||
}
|
||||
|
||||
class_helper::verify_g_object_subclass_alignment<GObject, MooOpenInfo>();
|
||||
class_helper::verify_g_object_subclass_alignment<GObject, MooSaveInfo>();
|
||||
class_helper::verify_g_object_subclass_alignment<GObject, MooReloadInfo>();
|
||||
}
|
||||
|
||||
MooEditorPrivate::MooEditorPrivate()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user