Commit 8bd249e8 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Xsd generated now uses our own coding style.

parent 6b143b0c
......@@ -20,28 +20,19 @@
#include "conference/participant.h"
#include "local-conference-event-handler.h"
#include "object/object-p.h"
#if __clang__ || __GNUC__ >= 4
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#include "xml/conference-info.h"
#if __clang__ || __GNUC__ >= 4
#pragma GCC diagnostic pop
#endif
/* Needs to be included after xml/conference-info.h because of _() macro definition that breaks everything */
#include "private.h"
// =============================================================================
using namespace std;
using namespace conference_info;
LINPHONE_BEGIN_NAMESPACE
using namespace Xsd::ConferenceInfo;
class LocalConferenceEventHandlerPrivate : public ObjectPrivate {
public:
void notifyFullState(string notify, LinphoneEvent *lev);
......@@ -94,15 +85,15 @@ LocalConferenceEventHandler::~LocalConferenceEventHandler() {
string LocalConferenceEventHandler::subscribeReceived(LinphoneEvent *lev) {
L_D(LocalConferenceEventHandler);
string entity = d->conf->getMe()->getAddress().asStringUriOnly();
Conference_type confInfo = Conference_type(entity);
Users_type users;
ConferenceType confInfo = ConferenceType(entity);
UsersType users;
confInfo.setUsers(users);
xml_schema::NamespaceInfomap map;
Xsd::XmlSchema::NamespaceInfomap map;
map[""].name = "urn:ietf:params:xml:ns:conference-info";
for (const auto &participant : d->conf->getParticipants()) {
User_type user = User_type();
User_roles_type roles;
UserType user = UserType();
UserRolesType roles;
user.setRoles(roles);
user.setEntity(participant->getAddress().asStringUriOnly());
user.getRoles()->getEntry().push_back(participant->isAdmin() ? "admin" : "participant");
......@@ -111,7 +102,7 @@ string LocalConferenceEventHandler::subscribeReceived(LinphoneEvent *lev) {
}
stringstream notify;
serializeConference_info(notify, confInfo, map);
serializeConferenceInfo(notify, confInfo, map);
//d->notifyFullState(notify.str(), lev);
return notify.str();
}
......@@ -119,21 +110,21 @@ string LocalConferenceEventHandler::subscribeReceived(LinphoneEvent *lev) {
string LocalConferenceEventHandler::notifyParticipantAdded(const Address &addr) {
L_D(LocalConferenceEventHandler);
string entity = d->conf->getMe()->getAddress().asStringUriOnly();
Conference_type confInfo = Conference_type(entity);
Users_type users;
ConferenceType confInfo = ConferenceType(entity);
UsersType users;
confInfo.setUsers(users);
User_type user = User_type();
User_roles_type roles;
UserType user = UserType();
UserRolesType roles;
user.setRoles(roles);
user.setEntity(addr.asStringUriOnly());
user.getRoles()->getEntry().push_back("participant");
user.setState("full");
confInfo.getUsers()->getUser().push_back(user);
xml_schema::NamespaceInfomap map;
Xsd::XmlSchema::NamespaceInfomap map;
stringstream notify;
serializeConference_info(notify, confInfo, map);
serializeConferenceInfo(notify, confInfo, map);
//d->notifyAllExcept(notify.str(), addr);
return notify.str();
}
......@@ -141,18 +132,18 @@ string LocalConferenceEventHandler::notifyParticipantAdded(const Address &addr)
string LocalConferenceEventHandler::notifyParticipantRemoved(const Address &addr) {
L_D(LocalConferenceEventHandler);
string entity = d->conf->getMe()->getAddress().asStringUriOnly();
Conference_type confInfo = Conference_type(entity);
Users_type users;
ConferenceType confInfo = ConferenceType(entity);
UsersType users;
confInfo.setUsers(users);
User_type user = User_type();
UserType user = UserType();
user.setEntity(addr.asStringUriOnly());
user.setState("deleted");
confInfo.getUsers()->getUser().push_back(user);
xml_schema::NamespaceInfomap map;
Xsd::XmlSchema::NamespaceInfomap map;
stringstream notify;
serializeConference_info(notify, confInfo, map);
serializeConferenceInfo(notify, confInfo, map);
//d->notifyAllExcept(notify.str(), addr);
return notify.str();
}
......@@ -160,21 +151,21 @@ string LocalConferenceEventHandler::notifyParticipantRemoved(const Address &addr
string LocalConferenceEventHandler::notifyParticipantSetAdmin(const Address &addr, bool isAdmin) {
L_D(LocalConferenceEventHandler);
string entity = d->conf->getMe()->getAddress().asStringUriOnly();
Conference_type confInfo = Conference_type(entity);
Users_type users;
ConferenceType confInfo = ConferenceType(entity);
UsersType users;
confInfo.setUsers(users);
User_type user = User_type();
User_roles_type roles;
UserType user = UserType();
UserRolesType roles;
user.setRoles(roles);
user.setEntity(addr.asStringUriOnly());
user.getRoles()->getEntry().push_back(isAdmin ? "admin" : "participant");
user.setState("partial");
confInfo.getUsers()->getUser().push_back(user);
xml_schema::NamespaceInfomap map;
Xsd::XmlSchema::NamespaceInfomap map;
stringstream notify;
serializeConference_info(notify, confInfo, map);
serializeConferenceInfo(notify, confInfo, map);
//d->notifyAllExcept(notify.str(), addr);
return notify.str();
}
......
......@@ -18,28 +18,19 @@
#include "remote-conference-event-handler.h"
#include "object/object-p.h"
#if __clang__ || __GNUC__ >= 4
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
#include "xml/conference-info.h"
#if __clang__ || __GNUC__ >= 4
#pragma GCC diagnostic pop
#endif
/* Needs to be included after xml/conference-info.h because of _() macro definition that breaks everything */
#include "private.h"
// =============================================================================
using namespace std;
using namespace conference_info;
LINPHONE_BEGIN_NAMESPACE
using namespace Xsd::ConferenceInfo;
class RemoteConferenceEventHandlerPrivate : public ObjectPrivate {
public:
LinphoneCore *core = nullptr;
......@@ -89,7 +80,7 @@ void RemoteConferenceEventHandler::unsubscribe() {
void RemoteConferenceEventHandler::notifyReceived(string xmlBody) {
L_D(RemoteConferenceEventHandler);
istringstream data(xmlBody);
unique_ptr<Conference_type> confInfo = parseConference_info(data, xml_schema::Flags::dont_validate);
unique_ptr<ConferenceType> confInfo = parseConferenceInfo(data, Xsd::XmlSchema::Flags::dont_validate);
if (confInfo->getEntity() == d->confAddr.asString()) {
for (const auto &user : confInfo->getUsers()->getUser()) {
LinphoneAddress *cAddr = linphone_core_interpret_url(d->core, user.getEntity()->c_str());
......
This diff is collapsed.
This diff is collapsed.
#if __clang__ || __GNUC__ >= 4
#pragma GCC diagnostic pop
#endif
......@@ -30,21 +30,6 @@ def find_xsdcxx():
xsdcxx = find_executable("xsd")
return xsdcxx
def get_prologue():
return """
#if __clang__ || __GNUC__ >= 4
\t#pragma GCC diagnostic push
\t#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
"""
def get_epilogue():
return """
#if __clang__ || __GNUC__ >= 4
\t#pragma GCC diagnostic pop
#endif
"""
def generate(name):
xsdcxx = find_xsdcxx()
if xsdcxx is None:
......@@ -56,6 +41,8 @@ def generate(name):
source_file = name + ".xsd"
print("Generating code from " + source_file)
source_file = os.path.join("xml", source_file)
prologue_file = os.path.join("xml", "prologue.txt")
epilogue_file = os.path.join("xml", "epilogue.txt")
work_dir = os.path.join(script_dir, "..")
os.chdir(work_dir)
p = Popen([xsdcxx,
......@@ -67,15 +54,43 @@ def generate(name):
"--std", "c++11",
"--type-naming", "java",
"--function-naming", "java",
"--location-regex-trace",
"--show-sloc",
"--hxx-suffix", ".h",
"--ixx-suffix", ".h",
"--cxx-suffix", ".cpp",
"--prologue", get_prologue(),
"--epilogue", get_epilogue(),
"--location-regex", "%http://.+/(.+)%$1%",
"--output-dir", "xml",
"--show-sloc",
"--prologue-file", prologue_file,
"--epilogue-file", epilogue_file,
"--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-([^,-]+)-?([^,-]*)%\\u$1\\u$2\\u$3\\u$4%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-?([^,-]*)%\\u$1\\u$2\\u$3%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-?([^,-]*)%\\u$1\\u$2%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-([^,-]+)-?([^,-]*),([^,]+)%\\u$1\\u$2\\u$3\\u$4\\l\\u$5%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-?([^,-]*),([^,]+)%\\u$1\\u$2\\u$3\\l\\u$4%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-?([^,-]*),([^,]+)%\\u$1\\u$2\\l\\u$3%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-([^,-]+)-?([^,-]*),([^,]+),([^,]+)%\\u$1\\u$2\\u$3\\u$4\\l\\u$5\\u$6%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-?([^,-]*),([^,]+),([^,]+)%\\u$1\\u$2\\u$3\\l\\u$4\\u$5%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-?([^,-]*),([^,]+),([^,]+)%\\u$1\\u$2\\l\\u$3\\u$4%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-([^,-]+)-?([^,-]*),([^,]+),([^,]+),([^,]+)%\\u$1\\u$2\\u$3\\u$4\\l\\u$5\\u$6\\u$7%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-([^,-]+)-?([^,-]*),([^,]+),([^,]+),([^,]+)%\\u$1\\u$2\\u$3\\l\\u$4\\u$5\\u$6%",
"--type-regex", "%(?:[^ ]* )?([^,-]+)-?([^,-]*),([^,]+),([^,]+),([^,]+)%\\u$1\\u$2\\l\\u$3\\u$4\\u$5%",
"--accessor-regex", "%([^,-]+)-([^,-]+)-?([^,-]*)%get\\u$1\\u$2\\u$3%",
"--accessor-regex", "%([^,-]+)-?([^,-]*)%get\\u$1\\u$2%",
"--accessor-regex", "%([^,-]+)-([^,-]+)-?([^,-]*),([^,]+)%get\\u$1\\u$2\\u$3\\l\\u$4%",
"--accessor-regex", "%([^,-]+)-?([^,-]*),([^,]+)%get\\u$1\\u$2\\l\\u$3%",
"--accessor-regex", "%([^,-]+)-([^,-]+)-?([^,-]*),([^,]+),([^,]+)%get\\u$1\\u$2\\u$3\\l\\u$4\\u$5%",
"--accessor-regex", "%([^,-]+)-?([^,-]*),([^,]+),([^,]+)%get\\u$1\\u$2\\l\\u$3\\u$4%",
"--modifier-regex", "%([^,-]+)-([^,-]+)-?([^,-]*)%set\\u$1\\u$2\\u$3%",
"--modifier-regex", "%([^,-]+)-?([^,-]*)%set\\u$1\\u$2%",
"--modifier-regex", "%([^,-]+)-([^,-]+)-?([^,-]*),([^,]+)%set\\u$1\\u$2\\u$3\\l\\u$4%",
"--modifier-regex", "%([^,-]+)-?([^,-]*),([^,]+)%set\\u$1\\u$2\\l\\u$3%",
"--modifier-regex", "%([^,-]+)-([^,-]+)-?([^,-]*),([^,]+),([^,]+)%set\\u$1\\u$2\\u$3\\l\\u$4\\u$5%",
"--modifier-regex", "%([^,-]+)-?([^,-]*),([^,]+),([^,]+)%set\\u$1\\u$2\\l\\u$3\\u$4%",
"--parser-regex", "%([^-]+)-?([^-]*)%parse\\u$1\\u$2%",
"--serializer-regex", "%([^-]+)-?([^-]*)%serialize\\u$1\\u$2%",
"--namespace-map", "http://www.w3.org/2001/XMLSchema=LinphonePrivate::Xsd::XmlSchema",
"--namespace-map", "urn:ietf:params:xml:ns:conference-info=LinphonePrivate::Xsd::ConferenceInfo",
"--namespace-map", "urn:ietf:params:xml:ns:resource-lists=LinphonePrivate::Xsd::ResourceLists",
source_file
], shell=False)
p.communicate()
......
#if __clang__ || __GNUC__ >= 4
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsuggest-override"
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment