[libical-glib] Move all the private methods in a common place named libical-glib-private.h.
- From: Miao Yu <williamyu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libical-glib] Move all the private methods in a common place named libical-glib-private.h.
- Date: Sat, 4 Apr 2015 14:40:33 +0000 (UTC)
commit dcc1f91b061f5c885c01ec0ddb6f464e194d8d7c
Author: William Yu <williamyu gnome org>
Date: Sat Apr 4 10:37:42 2015 -0400
Move all the private methods in a common place named libical-glib-private.h.
TODO | 3 ++
src/api/i-cal-comp-iter.xml | 2 +-
src/api/i-cal-datetimeperiod-type.xml | 2 +-
src/api/i-cal-recurrence-type.xml | 2 +-
src/api/i-cal-reqstat-type.xml | 2 +-
src/api/i-cal-timetype.xml | 2 +-
src/api/i-cal-timezone-phase.xml | 2 +-
src/api/i-cal-timezone.xml | 2 +-
src/api/i-cal-timezonetype.xml | 2 +-
src/build-tools/generator.c | 51 +++++++++++++++++++++++++++++++-
src/build-tools/generator.h | 1 +
src/libical-glib/Makefile.am | 1 +
12 files changed, 62 insertions(+), 10 deletions(-)
---
diff --git a/TODO b/TODO
index f37fd3e..f1a3cb9 100644
--- a/TODO
+++ b/TODO
@@ -1,6 +1,9 @@
TODO:
-Create installed Python tests.
-Try to move the declarations of methods with libical type arguments into a new file libical-glib-private.h.
+ --Fix the private methods in each structure.
+ --Make it prettier.
+ --Fix the Makefile.am to delete the libical-glib-private.h
Notes:
-Ignore pvl and sspm since they are too low level.
diff --git a/src/api/i-cal-comp-iter.xml b/src/api/i-cal-comp-iter.xml
index 67ff201..2f8dc26 100644
--- a/src/api/i-cal-comp-iter.xml
+++ b/src/api/i-cal-comp-iter.xml
@@ -14,7 +14,7 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
-->
<structure namespace="ICal" name="CompIter" native="struct icalcompiter" is_bare="true"
default_native="i_cal_comp_iter_new_default ()">
- <method name="i_cal_comp_iter_new_default" corresponds="CUSTOM" kind="constructor" since="1.0">
+ <method name="i_cal_comp_iter_new_default" corresponds="CUSTOM" kind="private" since="1.0">
<returns type="struct icalcompiter" annotation="transfer none" comment="The newly created
default native icalcompiter"/>
<custom> icalcompiter compiter;
compiter.kind = ICAL_NO_COMPONENT;
diff --git a/src/api/i-cal-datetimeperiod-type.xml b/src/api/i-cal-datetimeperiod-type.xml
index 78d3154..f44c1b9 100644
--- a/src/api/i-cal-datetimeperiod-type.xml
+++ b/src/api/i-cal-datetimeperiod-type.xml
@@ -14,7 +14,7 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
-->
<structure namespace="ICal" name="DatetimeperiodType" native="struct icaldatetimeperiodtype" is_bare="true"
default_native="i_cal_datetimeperiod_type_new_default ()" includes="libical-glib/i-cal-timetype.h,
libical-glib/i-cal-period-type.h">
- <method name="i_cal_datetimeperiod_type_new_default" corresponds="CUSTOM" annotation="skip"
kind="constructor" since="1.0">
+ <method name="i_cal_datetimeperiod_type_new_default" corresponds="CUSTOM" annotation="skip"
kind="private" since="1.0">
<returns type="struct icaldatetimeperiodtype" annotation="transfer full" comment="The newly created
#ICalDatetimeperiodType" />
<comment xml:space="preserve">Create a new default #ICalDatetimeperiodType</comment>
<custom> struct icaldatetimeperiodtype datetimeperiodtype;
diff --git a/src/api/i-cal-recurrence-type.xml b/src/api/i-cal-recurrence-type.xml
index fa7d1b0..6bcd474 100644
--- a/src/api/i-cal-recurrence-type.xml
+++ b/src/api/i-cal-recurrence-type.xml
@@ -34,7 +34,7 @@
<element name="ICAL_FRIDAY_WEEKDAY"/>
<element name="ICAL_SATURDAY_WEEKDAY"/>
</enum>
- <method name="i_cal_recurrence_type_new" corresponds="CUSTOM" annotation="skip" since="1.0">
+ <method name="i_cal_recurrence_type_new" corresponds="CUSTOM" annotation="skip" kind="private"
since="1.0">
<returns type="struct icalrecurrencetype" comment="The default value."/>
<custom> struct icalrecurrencetype ret;
icalrecurrencetype_clear (&ret);
diff --git a/src/api/i-cal-reqstat-type.xml b/src/api/i-cal-reqstat-type.xml
index e60405c..bdda0c2 100644
--- a/src/api/i-cal-reqstat-type.xml
+++ b/src/api/i-cal-reqstat-type.xml
@@ -24,7 +24,7 @@
<returns type="gchar *" annotation="transfer full" comment="A string."/>
<comment xml:space="preserve">Convert #ICalReqstatType to a string representation.</comment>
</method>
- <method name="i_cal_reqstat_type_new_default" corresponds="CUSTOM" kind="constructor" since="1.0">
+ <method name="i_cal_reqstat_type_new_default" corresponds="CUSTOM" kind="private" since="1.0">
<returns type="struct icalreqstattype" annotation="transfer full" comment="The newly created
#ICalReqstatType" />
<comment xml:space="preserve">Create a new default #ICalReqstatType</comment>
<custom> struct icalreqstattype reqstattype;
diff --git a/src/api/i-cal-timetype.xml b/src/api/i-cal-timetype.xml
index 08eecde..7253610 100644
--- a/src/api/i-cal-timetype.xml
+++ b/src/api/i-cal-timetype.xml
@@ -14,7 +14,7 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
-->
<structure namespace="ICal" name="Timetype" native="struct icaltimetype" is_bare="true"
default_native="i_cal_timetype_new_default ()">
- <method name="i_cal_timetype_new_default" corresponds="CUSTOM" annotation="skip" kind="constructor"
since="1.0">
+ <method name="i_cal_timetype_new_default" corresponds="CUSTOM" annotation="skip" kind="private"
since="1.0">
<returns type="struct icaltimetype" comment="The newly created #ICalTimetype. It is the epoch
time (19700-1-1 00:00:00 utc)" />
<comment xml:space="preserve">Create a new #ICalTimetype.</comment>
<custom> struct icaltimetype timetype;
diff --git a/src/api/i-cal-timezone-phase.xml b/src/api/i-cal-timezone-phase.xml
index 7cbb55b..2a519bf 100644
--- a/src/api/i-cal-timezone-phase.xml
+++ b/src/api/i-cal-timezone-phase.xml
@@ -14,7 +14,7 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
-->
<structure namespace="ICal" name="TimezonePhase" native="struct icaltimezonephase" is_bare="true"
default_native="i_cal_timezone_phase_new_default ()" includes="libical-glib/i-cal-timetype.h,
libical-glib/i-cal-datetimeperiod-type.h">
- <method name="i_cal_timezone_phase_new_default" corresponds="CUSTOM" kind="constructor" since="1.0">
+ <method name="i_cal_timezone_phase_new_default" corresponds="CUSTOM" kind="private" since="1.0">
<returns type="struct icaltimezonephase" annotation="transfer full" comment="The newly created
#ICalTimezonePhase" />
<comment xml:space="preserve">Create a new default #ICalTimezonePhase</comment>
<custom> struct icaltimezonephase timezonephase;
diff --git a/src/api/i-cal-timezone.xml b/src/api/i-cal-timezone.xml
index 4db69f8..ba7c103 100644
--- a/src/api/i-cal-timezone.xml
+++ b/src/api/i-cal-timezone.xml
@@ -18,7 +18,7 @@
<returns type="ICalTimezone *" annotation="transfer full, allow-none"
translator="i_cal_timezone_new_full" translator_argus="NULL, FALSE" comment="The newly created object of the
type #ICalTimezone." />
<comment xml:space="preserve">The constructor of the type #ICalTimezone</comment>
</method>
- <method name="i_cal_timezone_destroy" corresponds="CUSTOM" annotation="skip" kind="destructor" since="1.0">
+ <method name="i_cal_timezone_destroy" corresponds="CUSTOM" annotation="skip" kind="private" since="1.0">
<parameter type="icaltimezone *" name="zone" comment="The #ICalTimezone to be freed"/>
<comment xml:space="preserve">The destructor of the type #ICalTimezone to fully destroy the object by
providing 1 as the second argument of i_cal_time_zone_free. The method is used as a default destructor for
introspection.</comment>
<custom> icaltimezone_free (zone, 1);</custom>
diff --git a/src/api/i-cal-timezonetype.xml b/src/api/i-cal-timezonetype.xml
index 62f31b5..285b0dc 100644
--- a/src/api/i-cal-timezonetype.xml
+++ b/src/api/i-cal-timezonetype.xml
@@ -14,7 +14,7 @@
along with this library. If not, see <http://www.gnu.org/licenses/>.
-->
<structure namespace="ICal" name="Timezonetype" native="struct icaltimezonetype" is_bare="true"
default_native="i_cal_timezonetype_new_default ()" includes="libical-glib/i-cal-timetype.h">
- <method name="i_cal_timezonetype_new_default" corresponds="CUSTOM" kind="constructor" since="1.0">
+ <method name="i_cal_timezonetype_new_default" corresponds="CUSTOM" kind="private" since="1.0">
<returns type="struct icaltimezonetype" annotation="transfer full" comment="The newly created
#ICalTimezonetype" />
<comment xml:space="preserve">Create a new default #ICalTimezonetype</comment>
<custom> struct icaltimezonetype timezonetype;
diff --git a/src/build-tools/generator.c b/src/build-tools/generator.c
index 8bd4b3f..7cedd11 100644
--- a/src/build-tools/generator.c
+++ b/src/build-tools/generator.c
@@ -652,15 +652,58 @@ generate_header_method_protos (FILE *out, Structure *structure)
{
GList *iter;
Method *method;
+ gchar *typeName;
+ FILE * privateHeader;
+ gchar *privateHeaderComment;
+ privateHeader = NULL;
+ typeName = g_strconcat (structure->nameSpace, structure->name, NULL);
+ privateHeaderComment = g_strconcat ("/* Private header for ", typeName, " */\n", NULL);
+
if (structure->native != NULL) {
- generate_header_method_new_full (out, structure);
+ /** Open or create the private header file if it does not exist.
+ * Create the forward declaration.
+ * Create the new_full method in it.
+ */
+ privateHeader = fopen (PRIVATE_HEADER, "ab+");
+ fwrite (privateHeaderComment, sizeof (gchar), strlen (privateHeaderComment), privateHeader);
+ fwrite ("typedef struct _", sizeof (gchar), strlen ("typedef struct _"), privateHeader);
+ fwrite (typeName, sizeof (gchar), strlen (typeName), privateHeader);
+ fputc (' ', privateHeader);
+ fwrite (typeName, sizeof (gchar), strlen (typeName), privateHeader);
+ fputc (';', privateHeader);
+ fputc ('\n', privateHeader);
+ generate_header_method_new_full (privateHeader, structure);
+
generate_header_method_get_type (out, structure);
}
for (iter = g_list_first (structure->methods); iter != NULL; iter = g_list_next (iter)) {
method = (Method *)iter->data;
- generate_header_method_proto (out, method);
+
+ if (g_strcmp0 (method->kind, "private") == 0) {
+ /* This checks whether there was method declared in private header already. If not,
the forward declaration is needed. */
+ if (privateHeader == NULL) {
+ privateHeader = fopen (PRIVATE_HEADER, "ab+");
+ fwrite ("typedef struct _", sizeof (gchar), strlen ("typedef struct _"),
privateHeader);
+ fwrite (typeName, sizeof (gchar), strlen (typeName), privateHeader);
+ fputc (' ', privateHeader);
+ fwrite (typeName, sizeof (gchar), strlen (typeName), privateHeader);
+ fputc (';', privateHeader);
+ fputc ('\n', privateHeader);
+
+ }
+ generate_header_method_proto (privateHeader, method);
+ } else {
+ generate_header_method_proto (out, method);
+ }
+ }
+
+ g_free (typeName);
+
+ if (privateHeader != NULL) {
+ fclose (privateHeader);
+ privateHeader = NULL;
}
}
@@ -978,6 +1021,10 @@ generate_source_includes (FILE *out, Structure *structure)
fwrite (lowerTrain, sizeof (gchar), strlen (lowerTrain), out);
fwrite (".h>\n", sizeof (gchar), strlen (".h>\n"), out);
g_free (lowerTrain);
+
+ fwrite ("#include <libical-glib/", sizeof (gchar), strlen ("#include <libical-glib/"), out);
+ fwrite (PRIVATE_HEADER, sizeof (gchar), strlen (PRIVATE_HEADER), out);
+ fwrite (">\n", sizeof (gchar), strlen (">\n"), out);
for (g_hash_table_iter_init (&iter_table, structure->dependencies); g_hash_table_iter_next
(&iter_table, &key, &value);) {
typeName = (gchar *)key;
diff --git a/src/build-tools/generator.h b/src/build-tools/generator.h
index 26c9682..736ef63 100644
--- a/src/build-tools/generator.h
+++ b/src/build-tools/generator.h
@@ -39,6 +39,7 @@
#define RET_TAB_COUNT 2
#define METHOD_NAME_TAB_COUNT 4
#define COMMENT_LINE_LENGTH 100
+#define PRIVATE_HEADER "libical-glib-private.h"
/* Store the default value for bare type */
GHashTable *defaultValues;
diff --git a/src/libical-glib/Makefile.am b/src/libical-glib/Makefile.am
index b1ca038..6ec2b6b 100644
--- a/src/libical-glib/Makefile.am
+++ b/src/libical-glib/Makefile.am
@@ -110,6 +110,7 @@ libical_glib_1_0_la_SOURCES = \
privinclude_HEADERS = \
libical-glib.h \
+ libical-glib-private.h \
i-cal-object.h \
$(addsuffix .h, $(all_file_names)) \
$(NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]