mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 21:28:08 +00:00
Generate enums with the good values in lp_gen_wrappers.
This commit is contained in:
parent
a742a5aa9b
commit
367109341e
3 changed files with 12 additions and 9 deletions
|
|
@ -52,7 +52,7 @@ void CplusplusGenerator::generate(Project *proj){
|
|||
|
||||
void CplusplusGenerator::writeEnumMember(ConstField *cf, bool isLast){
|
||||
writeTabs(1);
|
||||
mOutfile<<cf->getName();
|
||||
mOutfile<<cf->getName()<<"="<<cf->getValue();
|
||||
if (!isLast) mOutfile<<",";
|
||||
if (!cf->getHelp().empty()) mOutfile<<"\t/**< "<<cf->getHelp()<<" */";
|
||||
mOutfile<<endl;
|
||||
|
|
@ -222,7 +222,6 @@ void JavascriptGenerator::writeEnum(Class *klass){
|
|||
list<ConstField*> members=klass->getConstFields();
|
||||
list<ConstField*>::iterator it;
|
||||
string enum_name=getEnumName(klass);
|
||||
int value=0;
|
||||
|
||||
filename<<to_lower(mCurProj->getName())<<"/"<<to_lower(enum_name)<<".js";
|
||||
mOutfile.open(filename.str().c_str());
|
||||
|
|
@ -243,7 +242,7 @@ void JavascriptGenerator::writeEnum(Class *klass){
|
|||
string prefix=ConstField::getCommonPrefix(members);
|
||||
size_t prefix_size=prefix.size();
|
||||
|
||||
for(it=members.begin();it!=members.end();value++){
|
||||
for(it=members.begin();it!=members.end();){
|
||||
ConstField *cf=(*it);
|
||||
if (!cf->getHelp().empty()){
|
||||
writeTabs(1);
|
||||
|
|
@ -254,7 +253,7 @@ void JavascriptGenerator::writeEnum(Class *klass){
|
|||
mOutfile<<"*/"<<endl;
|
||||
}
|
||||
writeTabs(1);
|
||||
mOutfile<<cf->getName().substr(prefix_size,string::npos)<<" : "<<value;
|
||||
mOutfile<<cf->getName().substr(prefix_size,string::npos)<<" : "<<cf->getValue();
|
||||
if (++it!=members.end()) mOutfile<<",";
|
||||
mOutfile<<endl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include <libxml/parser.h>
|
||||
#include <libxml/tree.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
|
@ -335,11 +336,14 @@ static void parseEnum(Project *proj, XmlNode node){
|
|||
klass->setHelp(node.getChild("detaileddescription").getChild("para").getText());
|
||||
list<XmlNode> enumValues=node.getChildren("enumvalue");
|
||||
list<XmlNode>::iterator it;
|
||||
int value = 0;
|
||||
for (it=enumValues.begin();it!=enumValues.end();++it){
|
||||
ConstField *cf=new ConstField(Type::getType("int"),(*it).getChild("name").getText());
|
||||
XmlNode initializer = (*it).getChild("initializer");
|
||||
if (initializer) value=atoi(initializer.getText().c_str());
|
||||
ConstField *cf=new ConstField(Type::getType("int"),(*it).getChild("name").getText(),value);
|
||||
cf->setHelp((*it).getChild("detaileddescription").getChild("para").getText());
|
||||
klass->addConstField(cf);
|
||||
|
||||
value++;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ private:
|
|||
|
||||
class ConstField{
|
||||
public:
|
||||
ConstField(Type *type, const string &name, const string &value="") : mType(type), mName(name), mValue(value){
|
||||
ConstField(Type *type, const string &name, int value) : mType(type), mName(name), mValue(value){
|
||||
}
|
||||
void setHelp(const string & help){
|
||||
mHelp=help;
|
||||
|
|
@ -308,7 +308,7 @@ public:
|
|||
Type *getType()const{
|
||||
return mType;
|
||||
}
|
||||
const string &getValue()const{
|
||||
int getValue()const{
|
||||
return mValue;
|
||||
}
|
||||
static string getCommonPrefix(list<ConstField *> fields){
|
||||
|
|
@ -338,7 +338,7 @@ public:
|
|||
private:
|
||||
Type *mType;
|
||||
string mName;
|
||||
string mValue;
|
||||
int mValue;
|
||||
string mHelp;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue