Rename variables to conform with Lisp coding style
This commit is contained in:
parent
20ac2dff2e
commit
65e5fc9f21
136
gobgen.el
136
gobgen.el
@ -47,14 +47,14 @@
|
|||||||
(defun gobject-get-prefix (class-name)
|
(defun gobject-get-prefix (class-name)
|
||||||
(car (split-string class-name "_")))
|
(car (split-string class-name "_")))
|
||||||
|
|
||||||
(defun gobgen-gen-header (CLASS_FULL_NAME
|
(defun gobgen-gen-header (class-full-name-upper
|
||||||
CLASS_PREFIX
|
class-prefix-upper
|
||||||
CLASS_NAME
|
class-name-upper
|
||||||
ClassFullName
|
class-full-name-camel
|
||||||
func-prefix
|
func-prefix
|
||||||
parent_prefix
|
parent-prefix-snake
|
||||||
ParentPrefix
|
parent-prefix-camel
|
||||||
ParentName
|
parent-name-camel
|
||||||
parent-header
|
parent-header
|
||||||
recent-glib
|
recent-glib
|
||||||
need-private)
|
need-private)
|
||||||
@ -62,18 +62,18 @@
|
|||||||
|
|
||||||
(concat
|
(concat
|
||||||
"#ifndef __"
|
"#ifndef __"
|
||||||
CLASS_FULL_NAME
|
class-full-name-upper
|
||||||
"_H__\n"
|
"_H__\n"
|
||||||
|
|
||||||
"#define __"
|
"#define __"
|
||||||
CLASS_FULL_NAME
|
class-full-name-upper
|
||||||
"_H__\n"
|
"_H__\n"
|
||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
(if (string-equal "g" parent_prefix)
|
(if (string-equal "g" parent-prefix-snake)
|
||||||
"#include <glib-object.h>"
|
"#include <glib-object.h>"
|
||||||
(if (string-equal "gtk" parent_prefix)
|
(if (string-equal "gtk" parent-prefix-snake)
|
||||||
"#include <gtk/gtk.h>"
|
"#include <gtk/gtk.h>"
|
||||||
(concat "// You might want to revise this\n"
|
(concat "// You might want to revise this\n"
|
||||||
"#include <"
|
"#include <"
|
||||||
@ -87,34 +87,34 @@
|
|||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
"#define " CLASS_PREFIX "_TYPE_" CLASS_NAME " (" func-prefix "_get_type())\n"
|
"#define " class-prefix-upper "_TYPE_" class-name-upper " (" func-prefix "_get_type())\n"
|
||||||
|
|
||||||
"#define " CLASS_FULL_NAME "(o) (G_TYPE_CHECK_INSTANCE_CAST((o), " CLASS_PREFIX "_TYPE_" CLASS_NAME ", " ClassFullName "))\n"
|
"#define " class-full-name-upper "(o) (G_TYPE_CHECK_INSTANCE_CAST((o), " class-prefix-upper "_TYPE_" class-name-upper ", " class-full-name-camel "))\n"
|
||||||
|
|
||||||
"#define " CLASS_FULL_NAME "_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), " CLASS_PREFIX "_TYPE_" CLASS_NAME ", " ClassFullName "Class))\n"
|
"#define " class-full-name-upper "_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), " class-prefix-upper "_TYPE_" class-name-upper ", " class-full-name-camel "Class))\n"
|
||||||
|
|
||||||
"#define " CLASS_PREFIX "_IS_" CLASS_NAME "(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), " CLASS_PREFIX "_TYPE_" CLASS_NAME "))\n"
|
"#define " class-prefix-upper "_IS_" class-name-upper "(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), " class-prefix-upper "_TYPE_" class-name-upper "))\n"
|
||||||
|
|
||||||
"#define " CLASS_PREFIX "_IS_" CLASS_NAME "_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), " CLASS_PREFIX "_TYPE_" CLASS_NAME "))\n"
|
"#define " class-prefix-upper "_IS_" class-name-upper "_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), " class-prefix-upper "_TYPE_" class-name-upper "))\n"
|
||||||
|
|
||||||
"#define " CLASS_FULL_NAME"_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), " CLASS_PREFIX "_TYPE_" CLASS_NAME ", " ClassFullName "Class))\n"
|
"#define " class-full-name-upper"_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), " class-prefix-upper "_TYPE_" class-name-upper ", " class-full-name-camel "Class))\n"
|
||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
"typedef struct _" ClassFullName " " ClassFullName ";\n"
|
"typedef struct _" class-full-name-camel " " class-full-name-camel ";\n"
|
||||||
|
|
||||||
"typedef struct _" ClassFullName "Class " ClassFullName "Class;\n"
|
"typedef struct _" class-full-name-camel "Class " class-full-name-camel "Class;\n"
|
||||||
|
|
||||||
(if (and (not recent-glib) need-private)
|
(if (and (not recent-glib) need-private)
|
||||||
(concat "typedef struct _" ClassFullName "Private " ClassFullName "Private;\n"))
|
(concat "typedef struct _" class-full-name-camel "Private " class-full-name-camel "Private;\n"))
|
||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
"struct _" ClassFullName " {\n"
|
"struct _" class-full-name-camel " {\n"
|
||||||
|
|
||||||
" /* Parent instance structure */\n"
|
" /* Parent instance structure */\n"
|
||||||
|
|
||||||
" " ParentPrefix ParentName " parent_instance;\n"
|
" " parent-prefix-camel parent-name-camel " parent_instance;\n"
|
||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
@ -123,15 +123,15 @@
|
|||||||
(if (and (not recent-glib) need-private)
|
(if (and (not recent-glib) need-private)
|
||||||
(concat "\n"
|
(concat "\n"
|
||||||
" /*< private >*/\n"
|
" /*< private >*/\n"
|
||||||
" " ClassFullName "Private *priv;\n"))
|
" " class-full-name-camel "Private *priv;\n"))
|
||||||
|
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
"struct _" ClassFullName "Class {\n"
|
"struct _" class-full-name-camel "Class {\n"
|
||||||
|
|
||||||
" " ParentPrefix ParentName "Class parent_class;\n"
|
" " parent-prefix-camel parent-name-camel "Class parent_class;\n"
|
||||||
|
|
||||||
"};\n"
|
"};\n"
|
||||||
|
|
||||||
@ -146,18 +146,18 @@
|
|||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
"#endif /* __"
|
"#endif /* __"
|
||||||
CLASS_FULL_NAME
|
class-full-name-upper
|
||||||
"_H__ */\n"))
|
"_H__ */\n"))
|
||||||
|
|
||||||
(defun gobgen-gen-code (CLASS_FULL_NAME
|
(defun gobgen-gen-code (class-full-name-upper
|
||||||
CLASS_PREFIX
|
class-prefix-upper
|
||||||
CLASS_NAME
|
class-name-upper
|
||||||
class_name
|
class-name-snake
|
||||||
ClassFullName
|
class-full-name-camel
|
||||||
func-prefix
|
func-prefix
|
||||||
file-name-header
|
file-name-header
|
||||||
PARENT_PREFIX
|
parent-prefix-upper
|
||||||
PARENT_NAME
|
parent-name-upper
|
||||||
recent-glib
|
recent-glib
|
||||||
need-private)
|
need-private)
|
||||||
"Generate the contents of a GObject source file."
|
"Generate the contents of a GObject source file."
|
||||||
@ -171,21 +171,21 @@
|
|||||||
(concat
|
(concat
|
||||||
(if (not recent-glib)
|
(if (not recent-glib)
|
||||||
(concat
|
(concat
|
||||||
"#define " CLASS_FULL_NAME "_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE( \\\n"
|
"#define " class-full-name-upper "_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE( \\\n"
|
||||||
" (o), \\\n"
|
" (o), \\\n"
|
||||||
" " CLASS_PREFIX "_TYPE_" CLASS_NAME ", \\\n"
|
" " class-prefix-upper "_TYPE_" class-name-upper ", \\\n"
|
||||||
" " ClassFullName "Private \\\n"
|
" " class-full-name-camel "Private \\\n"
|
||||||
" ))\n"
|
" ))\n"
|
||||||
"\n"))
|
"\n"))
|
||||||
|
|
||||||
(if recent-glib "typedef ")
|
(if recent-glib "typedef ")
|
||||||
|
|
||||||
"struct _" ClassFullName "Private {\n"
|
"struct _" class-full-name-camel "Private {\n"
|
||||||
" /* TODO: You must add something here, or GLib will produce warnings! */\n"
|
" /* TODO: You must add something here, or GLib will produce warnings! */\n"
|
||||||
"}"
|
"}"
|
||||||
|
|
||||||
(if recent-glib
|
(if recent-glib
|
||||||
(concat " " ClassFullName "Private"))
|
(concat " " class-full-name-camel "Private"))
|
||||||
|
|
||||||
";\n"
|
";\n"
|
||||||
"\n"))
|
"\n"))
|
||||||
@ -195,7 +195,7 @@
|
|||||||
(if (and recent-glib need-private)
|
(if (and recent-glib need-private)
|
||||||
"_WITH_PRIVATE")
|
"_WITH_PRIVATE")
|
||||||
|
|
||||||
"(" ClassFullName ", " func-prefix ", " PARENT_PREFIX "_TYPE_" PARENT_NAME ");\n"
|
"(" class-full-name-camel ", " func-prefix ", " parent-prefix-upper "_TYPE_" parent-name-upper ");\n"
|
||||||
|
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
@ -209,14 +209,14 @@
|
|||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
"static void\n"
|
"static void\n"
|
||||||
func-prefix "_class_init(" ClassFullName "Class *klass)\n"
|
func-prefix "_class_init(" class-full-name-camel "Class *klass)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" GObjectClass *gobject_class = G_OBJECT_CLASS(klass);\n"
|
" GObjectClass *gobject_class = G_OBJECT_CLASS(klass);\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
(if (and (not recent-glib) need-private)
|
(if (and (not recent-glib) need-private)
|
||||||
(concat
|
(concat
|
||||||
" g_type_class_add_private(klass, sizeof(" ClassFullName "Private));\n"
|
" g_type_class_add_private(klass, sizeof(" class-full-name-camel "Private));\n"
|
||||||
"\n"))
|
"\n"))
|
||||||
|
|
||||||
" gobject_class->finalize = " func-prefix "_finalize;\n"
|
" gobject_class->finalize = " func-prefix "_finalize;\n"
|
||||||
@ -226,12 +226,12 @@
|
|||||||
"\n"
|
"\n"
|
||||||
|
|
||||||
"static void\n"
|
"static void\n"
|
||||||
func-prefix "_init(" ClassFullName " *" class_name ")\n"
|
func-prefix "_init(" class-full-name-camel " *" class-name-snake ")\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
||||||
(if (and (not recent-glib) need-private)
|
(if (and (not recent-glib) need-private)
|
||||||
(concat
|
(concat
|
||||||
" " class_name "->priv = " CLASS_FULL_NAME "_GET_PRIVATE(" class_name ");\n"))
|
" " class-name-snake "->priv = " class-full-name-upper "_GET_PRIVATE(" class-name-snake ");\n"))
|
||||||
|
|
||||||
"}\n"))
|
"}\n"))
|
||||||
|
|
||||||
@ -262,21 +262,21 @@
|
|||||||
(parent-name-pcs (split-string parent-name "_"))
|
(parent-name-pcs (split-string parent-name "_"))
|
||||||
(class-prefix-pcs (split-string class-prefix "_"))
|
(class-prefix-pcs (split-string class-prefix "_"))
|
||||||
(class-name-pcs (split-string class-name "_"))
|
(class-name-pcs (split-string class-name "_"))
|
||||||
(parent_prefix (string-join parent-prefix-pcs "_"))
|
(parent-prefix-snake (string-join parent-prefix-pcs "_"))
|
||||||
(ParentPrefix (mapconcat 'capitalize parent-prefix-pcs ""))
|
(parent-prefix-camel (mapconcat 'capitalize parent-prefix-pcs ""))
|
||||||
(PARENT_PREFIX (upcase parent_prefix))
|
(parent-prefix-upper (upcase parent-prefix-snake))
|
||||||
(parent_name (string-join parent-name-pcs "_"))
|
(parent_name (string-join parent-name-pcs "_"))
|
||||||
(ParentName (mapconcat 'capitalize parent-name-pcs ""))
|
(parent-name-camel (mapconcat 'capitalize parent-name-pcs ""))
|
||||||
(PARENT_NAME (upcase parent_name))
|
(parent-name-upper (upcase parent_name))
|
||||||
(class_prefix (string-join class-prefix-pcs "_"))
|
(class_prefix (string-join class-prefix-pcs "_"))
|
||||||
(ClassPrefix (mapconcat 'capitalize class-prefix-pcs ""))
|
(ClassPrefix (mapconcat 'capitalize class-prefix-pcs ""))
|
||||||
(CLASS_PREFIX (upcase class_prefix))
|
(class-prefix-upper (upcase class_prefix))
|
||||||
(class_name (string-join class-name-pcs "_"))
|
(class-name-snake (string-join class-name-pcs "_"))
|
||||||
(ClassName (mapconcat 'capitalize class-name-pcs ""))
|
(ClassName (mapconcat 'capitalize class-name-pcs ""))
|
||||||
(CLASS_NAME (upcase class_name))
|
(class-name-upper (upcase class-name-snake))
|
||||||
(func-prefix (concat class_prefix "_" class_name))
|
(func-prefix (concat class_prefix "_" class-name-snake))
|
||||||
(ClassFullName (concat ClassPrefix ClassName))
|
(class-full-name-camel (concat ClassPrefix ClassName))
|
||||||
(CLASS_FULL_NAME (concat CLASS_PREFIX "_" CLASS_NAME))
|
(class-full-name-upper (concat class-prefix-upper "_" class-name-upper))
|
||||||
(parent-header (concat (string-join (append parent-prefix-pcs parent-name-pcs) "-") ".h"))
|
(parent-header (concat (string-join (append parent-prefix-pcs parent-name-pcs) "-") ".h"))
|
||||||
(file-name-base (string-join (append class-prefix-pcs class-name-pcs) "-"))
|
(file-name-base (string-join (append class-prefix-pcs class-name-pcs) "-"))
|
||||||
(file-name-code (concat file-name-base ".c"))
|
(file-name-code (concat file-name-base ".c"))
|
||||||
@ -286,14 +286,14 @@
|
|||||||
(split-window-vertically)
|
(split-window-vertically)
|
||||||
(other-window 1)
|
(other-window 1)
|
||||||
(find-file file-name-header)
|
(find-file file-name-header)
|
||||||
(insert (gobgen-gen-header CLASS_FULL_NAME
|
(insert (gobgen-gen-header class-full-name-upper
|
||||||
CLASS_PREFIX
|
class-prefix-upper
|
||||||
CLASS_NAME
|
class-name-upper
|
||||||
ClassFullName
|
class-full-name-camel
|
||||||
func-prefix
|
func-prefix
|
||||||
parent_prefix
|
parent-prefix-snake
|
||||||
ParentPrefix
|
parent-prefix-camel
|
||||||
ParentName
|
parent-name-camel
|
||||||
parent-header
|
parent-header
|
||||||
recent-glib
|
recent-glib
|
||||||
need-private))
|
need-private))
|
||||||
@ -301,15 +301,15 @@
|
|||||||
(split-window-vertically)
|
(split-window-vertically)
|
||||||
(other-window 1)
|
(other-window 1)
|
||||||
(find-file file-name-code)
|
(find-file file-name-code)
|
||||||
(insert (gobgen-gen-code CLASS_FULL_NAME
|
(insert (gobgen-gen-code class-full-name-upper
|
||||||
CLASS_PREFIX
|
class-prefix-upper
|
||||||
CLASS_NAME
|
class-name-upper
|
||||||
class_name
|
class-name-snake
|
||||||
ClassFullName
|
class-full-name-camel
|
||||||
func-prefix
|
func-prefix
|
||||||
file-name-header
|
file-name-header
|
||||||
PARENT_PREFIX
|
parent-prefix-upper
|
||||||
PARENT_NAME
|
parent-name-upper
|
||||||
recent-glib
|
recent-glib
|
||||||
need-private)))))))
|
need-private)))))))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user