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));
|
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
|
} // namespace moo
|
||||||
|
@ -58,7 +58,7 @@ SET(mooedit_sources
|
|||||||
mooedit/mooeditwindow.c
|
mooedit/mooeditwindow.c
|
||||||
mooedit/mooeditwindow-impl.h
|
mooedit/mooeditwindow-impl.h
|
||||||
mooedit/mooeditfileinfo-impl.h
|
mooedit/mooeditfileinfo-impl.h
|
||||||
mooedit/mooeditfileinfo.c
|
mooedit/mooeditfileinfo.cpp
|
||||||
mooedit/moofold.c
|
mooedit/moofold.c
|
||||||
mooedit/moofold.h
|
mooedit/moofold.h
|
||||||
mooedit/mooindenter.c
|
mooedit/mooindenter.c
|
||||||
|
@ -5,10 +5,8 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
struct MooOpenInfo
|
struct MooOpenInfo : public GObject
|
||||||
{
|
{
|
||||||
GObject parent;
|
|
||||||
|
|
||||||
GFile *file;
|
GFile *file;
|
||||||
char *encoding;
|
char *encoding;
|
||||||
int line;
|
int line;
|
||||||
@ -20,9 +18,7 @@ struct MooOpenInfoClass
|
|||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MooReloadInfo {
|
struct MooReloadInfo : public GObject {
|
||||||
GObject parent;
|
|
||||||
|
|
||||||
char *encoding;
|
char *encoding;
|
||||||
int line;
|
int line;
|
||||||
};
|
};
|
||||||
@ -32,9 +28,7 @@ struct MooReloadInfoClass
|
|||||||
GObjectClass parent_class;
|
GObjectClass parent_class;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MooSaveInfo {
|
struct MooSaveInfo : public GObject {
|
||||||
GObject parent;
|
|
||||||
|
|
||||||
GFile *file;
|
GFile *file;
|
||||||
char *encoding;
|
char *encoding;
|
||||||
};
|
};
|
||||||
|
@ -21,6 +21,9 @@
|
|||||||
|
|
||||||
#include "mooeditfileinfo-impl.h"
|
#include "mooeditfileinfo-impl.h"
|
||||||
#include <mooutils/mooutils-misc.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_open_info_class_init (MooOpenInfoClass *klass);
|
||||||
static void moo_save_info_class_init (MooSaveInfoClass *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);
|
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->file = g_file_dup (file);
|
||||||
info->encoding = g_strdup (encoding);
|
info->encoding = g_strdup (encoding);
|
||||||
@ -226,7 +229,7 @@ moo_open_info_set_line (MooOpenInfo *info,
|
|||||||
MooOpenFlags
|
MooOpenFlags
|
||||||
moo_open_info_get_flags (MooOpenInfo *info)
|
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;
|
return info->flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -293,7 +296,7 @@ moo_save_info_new_file (GFile *file,
|
|||||||
|
|
||||||
g_return_val_if_fail (G_IS_FILE (file), NULL);
|
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->file = g_file_dup (file);
|
||||||
info->encoding = g_strdup (encoding);
|
info->encoding = g_strdup (encoding);
|
||||||
@ -397,7 +400,7 @@ moo_reload_info_new (const char *encoding,
|
|||||||
{
|
{
|
||||||
MooReloadInfo *info;
|
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->encoding = g_strdup (encoding);
|
||||||
info->line = line;
|
info->line = line;
|
@ -338,8 +338,11 @@ moo_editor_class_init (MooEditorClass *klass)
|
|||||||
g_type_class_unref (edit_window_class);
|
g_type_class_unref (edit_window_class);
|
||||||
|
|
||||||
add_new_window_action ();
|
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()
|
MooEditorPrivate::MooEditorPrivate()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user