diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index a7d8cc793..fcf04e2c7 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -957,9 +957,9 @@ typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFrien * */ typedef void (*NewSubscribtionRequestCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url); /** Callback prototype */ -typedef void (*AuthInfoRequested)(struct _LinphoneCore *lc, const char *realm, const char *username); +typedef void (*AuthInfoRequestedCb)(struct _LinphoneCore *lc, const char *realm, const char *username); /** Callback prototype */ -typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl); +typedef void (*CallLogUpdatedCb)(struct _LinphoneCore *lc, struct _LinphoneCallLog *newcl); /** * Callback prototype * @deprecated use #MessageReceived instead. @@ -969,7 +969,7 @@ typedef void (*CallLogUpdated)(struct _LinphoneCore *lc, struct _LinphoneCallLog * @param from #LinphoneAddress from * @param message incoming message * */ -typedef void (*TextMessageReceived)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message); +typedef void (*TextMessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddress *from, const char *message); /** * Chat message callback prototype * @@ -977,18 +977,18 @@ typedef void (*TextMessageReceived)(LinphoneCore *lc, LinphoneChatRoom *room, co * @param room #LinphoneChatRoom involved in this conversation. Can be be created by the framework in case \link #LinphoneAddress the from \endlink is not present in any chat room. * @param LinphoneChatMessage incoming message * */ -typedef void (*MessageReceived)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message); +typedef void (*MessageReceivedCb)(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMessage *message); /** Callback prototype */ -typedef void (*DtmfReceived)(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf); +typedef void (*DtmfReceivedCb)(struct _LinphoneCore* lc, LinphoneCall *call, int dtmf); /** Callback prototype */ -typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to); +typedef void (*ReferReceivedCb)(struct _LinphoneCore *lc, const char *refer_to); /** Callback prototype */ -typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf); +typedef void (*BuddyInfoUpdatedCb)(struct _LinphoneCore *lc, LinphoneFriend *lf); /** Callback prototype for in progress transfers. The new_call_state is the state of the call resulting of the transfer, at the other party. */ -typedef void (*LinphoneTransferStateChanged)(struct _LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state); +typedef void (*LinphoneTransferStateChangedCb)(struct _LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state); /** Callback prototype for receiving quality statistics for calls*/ -typedef void (*CallStatsUpdated)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats); +typedef void (*CallStatsUpdatedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneCallStats *stats); /** Callback prototype for receiving info messages*/ typedef void (*LinphoneInfoReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, const LinphoneInfoMessage *msg); @@ -1002,15 +1002,15 @@ typedef struct _LinphoneVTable{ LinphoneCallStateCb call_state_changed;/** A text message has been received */ + TextMessageReceivedCb text_received; /** @deprecated, use #message_received instead
A text message has been received */ } LinphoneCoreVTable; /** diff --git a/tools/genwrappers.cc b/tools/genwrappers.cc index 3508937db..55a30e396 100644 --- a/tools/genwrappers.cc +++ b/tools/genwrappers.cc @@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include + using namespace::std; @@ -44,15 +45,17 @@ public: Float, String, Enum, - Class + Class, + Callback }; + static const char *sBasicTypeNames[]; static Type* addType(BasicType bt, const string &name){ Type* ret; if ((ret=mTypes[name])==0){ - cout<<"Adding new "<<(bt==Enum ? "enum" : "class")<<" type '"<mBasic=Enum; + }else if (bt!=Class){ + ret->mBasic=bt; } return ret; } @@ -117,6 +120,19 @@ Type Type::sVoidType(Type::Void); Type Type::sBooleanType(Type::Boolean); Type Type::sFloatType(Type::Float); std::map Type::mTypes; +const char *Type::sBasicTypeNames[]={ + "Void", + "Boolean", + "Integer", + "Float", + "String", + "Enum", + "Class", + "Callback", + "undef", + "undef" +}; + class Argument{ public: @@ -138,6 +154,9 @@ public: const string &getHelp()const{ return mHelp; } + void setHelp(const string &help){ + mHelp=help; + } private: Type *mType; @@ -499,6 +518,7 @@ public: list classes=proj->getClasses(); mCurProj=proj; #ifndef WIN32 + unlink(proj->getName().c_str()); mkdir(proj->getName().c_str(),S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IROTH); #else _mkdir(proj->getName().c_str()); @@ -524,8 +544,8 @@ private: //if (!mCurProj->getName().empty()) // mOutfile<<"namespace "<getName()<<"{"<getName()<getHelp()<getName()< properties=klass->getProperties(); @@ -556,6 +576,8 @@ private: case Type::Void: mOutfile<<"void"; break; + case Type::Callback: + break; } } void writeArgument(Argument *arg, bool isReturn=false){ @@ -607,7 +629,7 @@ private: if (method->getName()=="ref" || method->getName()=="unref") return; mOutfile<<"/**"<getHelp(),1); + writeHelpComment(method->getHelp(),0); mOutfile<getName()<<"#"<getName()<children; cur_node != NULL ; cur_node = cur_node->next){ - if (strcmp((const char*)cur_node->name,(const char*)element_name)==0){ - return cur_node; - } - } - return NULL; -} - static bool isSpace(const char *str){ for(;*str!='\0';++str){ if (!isspace(*str)) return false; @@ -641,35 +652,78 @@ static bool isSpace(const char *str){ return true; } -static string findChildContent(xmlNode *a_node, const char *element_name){ - xmlNode *node=findChild(a_node,element_name); - string res; - if (node) { - xmlChar *text=xmlNodeGetContent(node); - if (!isSpace((const char*)text)) - res=(char*)text; - xmlFree(text); +class XmlNode{ +public: + XmlNode(const xmlNode *node=NULL) : mNode(node){ } - return res; -} + XmlNode getChild(const string &name)const{ + if (mNode==NULL) return XmlNode(); + xmlNode *it; + for(it=mNode->children;it!=NULL;it=it->next){ + if (xmlStrcmp(it->name,(const xmlChar*)name.c_str())==0) + return XmlNode(it); + } + return XmlNode(); + } + XmlNode getChildRecursive(const string &name)const{ + if (mNode==NULL) return XmlNode(); + xmlNode *it; + //find in direct children + for(it=mNode->children;it!=NULL;it=it->next){ + if (xmlStrcmp(it->name,(const xmlChar*)name.c_str())==0) + return XmlNode(it); + } + //recurse into children + for(it=mNode->children;it!=NULL;it=it->next){ + XmlNode res=XmlNode(it).getChildRecursive(name); + if (!res.isNull()) return res; + } + return XmlNode(); + } + list getChildren(const string &name)const{ + xmlNode *it; + list nodes; + + if (mNode==NULL) return nodes; + for(it=mNode->children;it!=NULL;it=it->next){ + if (xmlStrcmp(it->name,(const xmlChar*)name.c_str())==0) + nodes.push_back(XmlNode(it)); + } + if (nodes.empty()) cerr<<"getChildren() no "<content; + if (!isSpace(text)) return string(text); + } + return ""; + } + string getProp(const string &propname)const{ + if (mNode==NULL) return ""; + xmlChar *value; + value=xmlGetProp((xmlNode*)mNode,(const xmlChar*)propname.c_str()); + if (value) return string((const char*)value); + return ""; + } + bool isNull()const{ + return mNode==NULL; + } +private: + const xmlNode *mNode; +}; -#define nullOrEmpty(p) (p==NULL || *p=='\0') - -static Argument *parseArgument(xmlNode *node, bool isReturn){ - string name=findChildContent(node,"declname"); +static Argument *parseArgument(XmlNode node, bool isReturn){ + string name=node.getChild("declname").getText(); Type *type=NULL; - xmlNode *typenode=findChild(node,"type"); - string typecontent=findChildContent(node,"type"); + string typecontent=node.getChild("type").getText(); bool isConst=false; bool isPointer=false; - if (!typenode) { - cout<<"Cannot find type from node."<getBasicType()<<" "<getName()<getBasicType()<<" "<getName()< args; string help; + XmlNode funcnode(node); + XmlNode parameterlist; + list params; + list paramsHelp; + list::iterator it,helpit; - for (cur_node = node->children; cur_node != NULL ; cur_node = cur_node->next){ - if (strcmp((const char*)cur_node->name,"name")==0){ - xmlChar *content=xmlNodeGetContent(cur_node); - name=(const char*)content; - xmlFree(content); - }else if (strcmp((const char*)cur_node->name,"param")==0){ - Argument *a=parseArgument(cur_node,false); - if (a) args.push_back(a); - else return; - }else if (strcmp((const char*)cur_node->name,"detaileddescription")==0){ - help=findChildContent(cur_node,"para"); + name=funcnode.getChild("name").getText(); + params=funcnode.getChildren("param"); + parameterlist=funcnode.getChild("detaileddescription").getChildRecursive("parameterlist"); + if (parameterlist.isNull()) cerr<<"parameterlist not found"<setHelp(item.getChild("parameterdescription").getChild("para").getText()); + }else cerr<<"Undocumented parameter "<getName()<<" in function "<getType()->getName(); methodName=extractMethodName(name,className); if (!methodName.empty() && methodName!="destroy"){ - cout<<"Found "<isConst(),false); method->setHelp(help); @@ -786,32 +865,33 @@ static void parseFunction(Project *proj, xmlNode *node){ } static void parseTypedef(Project *proj, xmlNode *node){ - string typecontent=findChildContent(node,"type"); - string name=findChildContent(node,"name"); + XmlNode tdef(node); + string typecontent=tdef.getChild("type").getText(); + string name=tdef.getChild("name").getText(); if (typecontent.find("enum")==0){ Type::addType(Type::Enum,name); - } + }else if (typecontent.find("void(*")==0){ + // callbacks function, not really well parsed by doxygen + Type::addType(Type::Callback,name); + }else + proj->getClass(name)->setHelp(getHelpBody(node)); } static void parseMemberDef(Project *proj, xmlNode *node){ + XmlNode member(node); string brief; string detailed; - const xmlChar *kind; + string kind; - brief=findChildContent(node,"briefdescription"); - detailed=findChildContent(node,"detaileddescription"); - - if (brief.empty() && detailed.empty()) + if (member.getChild("briefdescription").getText().empty() && + member.getChild("detaileddescription").getChild("para").getText().empty()) return; - kind=xmlGetProp(node,(const xmlChar*)"kind"); - if (kind){ - //cout<<"Kind="<<(const char*)kind<