1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
/* nih-dbus-tool
*
* tests/interface_factory.c - generate tests/interface_code.c
*
* Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
* Copyright © 2009 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2, as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif /* HAVE_CONFIG_H */
#include <stdio.h>
#include <nih/macros.h>
#include <nih/alloc.h>
#include <nih/string.h>
#include "type.h"
#include "interface.h"
#include "property.h"
int
main (int argc,
char *argv[])
{
NihList prototypes;
NihList typedefs;
NihList structs;
nih_local Interface *interface = NULL;
nih_local Property * property = NULL;
nih_local char * code = NULL;
nih_local char * block = NULL;
printf ("#include <dbus/dbus.h>\n"
"\n"
"#include <nih/macros.h>\n"
"#include <nih/alloc.h>\n"
"#include <nih/string.h>\n"
"#include <nih/logging.h>\n"
"#include <nih/error.h>\n"
"\n"
"#include <nih-dbus/dbus_error.h>\n"
"#include <nih-dbus/dbus_message.h>\n"
"#include <nih-dbus/dbus_object.h>\n"
"#include <nih-dbus/dbus_pending_data.h>\n"
"#include <nih-dbus/dbus_proxy.h>\n"
"#include <nih-dbus/errors.h>\n"
"\n"
"#include \"tests/interface_code.h\"\n"
"\n"
"\n");
interface = interface_new (NULL, "com.netsplit.Nih.Test");
interface->symbol = NULL;
property = property_new (interface, "name", "s", NIH_DBUS_READWRITE);
property->symbol = nih_strdup (property, "name");
nih_list_add (&interface->properties, &property->entry);
property = property_new (interface, "size", "u", NIH_DBUS_READWRITE);
property->symbol = nih_strdup (property, "size");
nih_list_add (&interface->properties, &property->entry);
nih_list_init (&prototypes);
nih_list_init (&structs);
interface->name = "com.netsplit.Nih.TestA";
code = interface_proxy_get_all_function (NULL, "my", interface,
&prototypes, &structs);
printf ("extern void my_com_netsplit_Nih_TestA_get_all_notify (DBusPendingCall *pending_call, "
"NihDBusPendingData *pending_data);\n");
printf ("\n");
printf ("%s"
"\n", code);
nih_list_init (&prototypes);
nih_list_init (&typedefs);
nih_list_init (&structs);
interface->name = "com.netsplit.Nih.Test";
code = interface_proxy_get_all_notify_function (NULL, "my", interface,
&prototypes, &typedefs,
&structs);
printf ("%s", code);
printf ("\n"
"\n");
nih_list_init (&prototypes);
nih_list_init (&structs);
code = interface_proxy_get_all_sync_function (NULL, "my", interface,
&prototypes, &structs);
printf ("%s"
"\n", code);
return 0;
}
|