You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.1 KiB
Django/Jinja
46 lines
1.1 KiB
Django/Jinja
#include "{{ cls.name }}Client_c.h"
|
|
#include "rpc/rpc_client_c_impl.h"
|
|
#include "ipc/IpcMarshaller.h"
|
|
|
|
#include <stdexcept>
|
|
|
|
extern "C" {
|
|
|
|
struct {{ cls.name }}Client {
|
|
IpcMarshaller* marshaller;
|
|
|
|
{{ cls.name }}Client(IpcMarshaller* m) : marshaller(m) {}
|
|
};
|
|
|
|
{{ cls.name }}Client* {{ cls.name|lower }}_client_create(IpcMarshallerHandle* marshaller) {
|
|
if (!marshaller || !marshaller->marshaller) {
|
|
return nullptr;
|
|
}
|
|
try {
|
|
return new {{ cls.name }}Client(marshaller->marshaller);
|
|
} catch (...) {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
void {{ cls.name|lower }}_client_destroy({{ cls.name }}Client* client) {
|
|
if (client) {
|
|
delete client;
|
|
}
|
|
}
|
|
|
|
{% for m in cls.methods %}
|
|
{{ m.return_type }} {{ cls.name|lower }}_{{ m.name }}({{ cls.name }}Client* client{% for a in m.args %}, {{ a.type }} {{ a.name }}{% endfor %}) {
|
|
if (!client || !client->marshaller) {
|
|
return -1;
|
|
}
|
|
try {
|
|
return client->marshaller->template callTyped<{{ m.return_type }}>("{{ cls.name }}.{{ m.name }}"{% for a in m.args %}, {{ a.name }}{% endfor %});
|
|
} catch (...) {
|
|
return -1;
|
|
}
|
|
}
|
|
{% endfor %}
|
|
|
|
} // extern "C"
|