in graveyard/src/wcg/actions.cpp [82:233]
void add_member_declaration(string_list* decl_specs,
member_declarator_list* member_decl_list)
{
/* int nVarType; */
/* int nConvVarType; */
unsigned char nQualifier = 0;
Variable Var;
bool bIsCtor = false;
/* find current access qualifier */
switch (g_currentaccessspecifier)
{
case KW_private:
nQualifier |= Q_PRIVATE;
break;
case KW_protected:
nQualifier |= Q_PROTECTED;
break;
case KW_public:
/* nothing to be done */
break;
default:;
}
Var.SetQualification(nQualifier);
/* find variable type and qualifiers */
if (decl_specs)
{
for (string_list::iterator tlit = decl_specs->begin();
tlit != decl_specs->end(); tlit++)
{
if (VAR_UNKNOWN != get_var_type((*tlit)->c_str()))
/* this is variable type not a qualifier */
{
Var.SetType(get_var_type((*tlit)->c_str()));
}
else if (is_defined_class((*tlit)->c_str())) /* user types */
{
Var.SetType(VAR_USER, (*tlit)->c_str());
}
else
{
/* handle other variable qualifiers here */
}
}
}
else /* constructor or destructor */
{
bIsCtor = true;
}
for (member_declarator_list::iterator it = member_decl_list->begin();
it != member_decl_list->end(); it++)
{
if ((*it)->method) /* a method declaration */
{
if (g_currentclasstype == BEANCLASS)
{
/* just ignore this method because we donot wrap methods
* in a bean class
*/
cout << "Ignoring methods in a bean class" << endl;
}
else
{
Method* pMethod = new Method();
if (bIsCtor) /* constructor or destructor - no return type */
{
cout << "Ignoring constructor or destructor" << endl;
/* we dont wrap constructors or destructors. */
}
else /* other methods */
{
pMethod->AddReturnType(new Variable(Var));
pMethod->SetQualification(nQualifier);
pMethod->SetMethodName(*((*it)->declarator_id));
/* set parameters */
if ((*it)->params)
{
for (param_decl_list::iterator pit = (*it)->params->
begin(); pit != (*it)->params->end(); pit++)
{
Var.Reset();
if ((*pit)->decl_specs)
{
for (string_list::iterator slit =
(*pit)->decl_specs->begin();
slit != (*pit)->decl_specs->end(); slit++)
{
if (VAR_UNKNOWN != get_var_type((*slit)->
c_str()))
/* this is variable type not a
* qualifier
*/
{
Var.SetType(get_var_type((*slit)->
c_str()));
}
else if (is_defined_class((*slit)->
c_str()))
/* user types */
{
Var.SetType(VAR_USER, (*slit)->
c_str());
}
else
{
/* handle other variable qualifiers
* here
*/
}
}
}
if ((*pit)->param)
{
Var.SetVarName((*pit)->param->decl_id);
}
/* Add as a parameter to the method */
pMethod->AddParameter(new Variable(Var));
}
}
if (g_pCurrentWSClass)
{
g_pCurrentWSClass->AddMethod(pMethod);
}
}
}
}
else /* variable declaration */
{
Variable* pVar = new Variable(Var);
pVar->SetVarName(*((*it)->declarator_id));
/* check for arrays */
/* TODO */
if (g_currentclasstype == BEANCLASS)
{
if (g_pCurrentBeanClass)
{
g_pCurrentBeanClass->AddVariable(pVar);
}
else
{
cout << "Ignoring variables in the other classes than \
bean classes" << endl;
}
}
else
{
cout << "Ignoring variables in web service class : we dont \
wrap them :)" << endl;
}
}
}
}