diff options
Diffstat (limited to 'libpurple/dbus-analyze-functions.py')
-rw-r--r-- | libpurple/dbus-analyze-functions.py | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/libpurple/dbus-analyze-functions.py b/libpurple/dbus-analyze-functions.py index 050da31ad7..2689a6f8bc 100644 --- a/libpurple/dbus-analyze-functions.py +++ b/libpurple/dbus-analyze-functions.py @@ -32,8 +32,8 @@ excluded = [\ "purple_log_read", ] -# This is a list of functions that return a GList* whose elements are -# string, not pointers to objects. +# This is a list of functions that return a GList* or GSList * whose elements +# are strings, not pointers to objects. stringlists = [ "purple_prefs_get_path_list", "purple_prefs_get_string_list", @@ -41,6 +41,32 @@ stringlists = [ "purple_uri_list_extract_uris", ] +# This is a list of functions that return a GList* or GSList* that should +# not be freed. Ideally, this information should be obtained from the Doxygen +# documentation at some point. +constlists = [ + "purple_account_get_status_types", + "purple_accounts_get_all", + "purple_account_option_get_list", + "purple_connections_get_all", + "purple_connections_get_connecting", + "purple_get_conversations", + "purple_get_ims", + "purple_get_chats", + "purple_conv_chat_get_users", + "purple_conv_chat_get_ignored", + "purple_mime_document_get_fields", + "purple_mime_document_get_parts", + "purple_mime_part_get_fields", + "purple_notify_user_info_get_entries", + "purple_request_fields_get_required", + "purple_request_field_list_get_selected", + "purple_request_field_list_get_items", + "purple_savedstatuses_get_all", + "purple_status_type_get_attrs", + "purple_presence_get_statuses", +] + pointer = "#pointer#" myexception = "My Exception" @@ -152,7 +178,7 @@ class Binding: return self.outputpurplestructure(type, name) if type[0] in ["GList", "GSList"]: - return self.outputlist(type, name, const) + return self.outputlist(type, name) raise myexception @@ -254,7 +280,7 @@ class ClientBinding (Binding): self.returncode.append("return (%s*) GINT_TO_POINTER(%s);" % (type[0], name)); self.definepurplestructure(type) - def outputlist(self, type, name, const): + def outputlist(self, type, name): self.functiontype = "%s*" % type[0] self.decls.append("GArray *%s;" % name) self.outputparams.append(('dbus_g_type_get_collection("GArray", G_TYPE_INT)', name)) @@ -390,28 +416,20 @@ class ServerBinding (Binding): # GList*, GSList*, assume that list is a list of objects # unless the function is in stringlists - def outputlist(self, type, name, const): + def outputlist(self, type, name): self.cdecls.append("\tdbus_int32_t %s_LEN;" % name) self.ccodeout.append("\tg_free(%s);" % name) - if const: - const_prefix = "const_" - else: - const_prefix = "" - - if (const): - self.cdecls.append("\tconst %s *list;" % type[0]); - else: - self.cdecls.append("\t%s *list;" % type[0]); + self.cdecls.append("\t%s *list;" % type[0]); if self.function.name in stringlists: self.cdecls.append("\tchar **%s;" % name) self.ccode.append("\tlist = %s;" % self.call) - self.ccode.append("\t%s = (char **)purple_const_%s_to_array(list, &%s_LEN);" % \ + self.ccode.append("\t%s = (char **)purple_%s_to_array(list, FALSE, &%s_LEN);" % \ (name, type[0], name)) self.cparamsout.append("DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &%s, %s_LEN" \ % (name, name)) - if (not const): + if (not (self.function.name in constlists)): type_name = type[0].lower()[1:] self.ccodeout.append("\tg_%s_foreach(list, (GFunc)g_free, NULL);" % type_name) self.ccodeout.append("\tg_%s_free(list);" % type_name) @@ -419,9 +437,9 @@ class ServerBinding (Binding): else: self.cdecls.append("\tdbus_int32_t *%s;" % name) self.ccode.append("\tlist = %s;" % self.call) - self.ccode.append("\t%s = purple_dbusify_const_%s(list, &%s_LEN);" % \ + self.ccode.append("\t%s = purple_dbusify_%s(list, FALSE, &%s_LEN);" % \ (name, type[0], name)) - if (not const): + if (not (self.function.name in constlists)): self.ccode.append("\tg_%s_free(list);" % type[0].lower()[1:]) self.cparamsout.append("DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &%s, %s_LEN" \ % (name, name)) |