|
From: <tei...@us...> - 2003-11-20 16:38:03
|
Update of /cvsroot/ccmtools/ccmtools/CppGenerator
In directory sc8-pr-cvs1:/tmp/cvs-serv12541
Modified Files:
CppRemoteGeneratorImpl.java
Log Message:
started with generation of sequence adapters
Index: CppRemoteGeneratorImpl.java
===================================================================
RCS file: /cvsroot/ccmtools/ccmtools/CppGenerator/CppRemoteGeneratorImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -C2 -d -r1.25 -r1.26
*** CppRemoteGeneratorImpl.java 20 Nov 2003 14:28:49 -0000 1.25
--- CppRemoteGeneratorImpl.java 20 Nov 2003 16:37:25 -0000 1.26
***************
*** 732,736 ****
MTypedefDef idl_typedef = (MTypedefDef)idl_type;
MStructDef idl_struct = (MStructDef)idl_typedef;
! ret.add(convertStructParameterFromCorbaToCpp(p, idl_struct));
}
else {
--- 732,748 ----
MTypedefDef idl_typedef = (MTypedefDef)idl_type;
MStructDef idl_struct = (MStructDef)idl_typedef;
! ret.add(convertStructParameterFromCorbaToCpp(p, idl_struct, false));
! }
! else if(idl_type instanceof MAliasDef) {
! MAliasDef alias = (MAliasDef)idl_type;
! if(alias.getIdlType() instanceof MSequenceDef) {
!
! ret.add(convertSequenceParameterFromCorbaToCpp(p, alias));
! }
! else {
! // all other alias types
! // TODO
! return "// unhandled idl alias type in convertParameterToCpp()";
! }
}
else {
***************
*** 743,746 ****
--- 755,760 ----
}
+
+
protected String convertPrimitiveParameterFromCorbaToCpp(MParameterDef p)
{
***************
*** 762,773 ****
}
! protected String convertStructParameterFromCorbaToCpp(MParameterDef p, MStructDef idl_struct)
{
MParameterMode direction = p.getDirection();
List ret = new ArrayList();
! ret.add(" CCM_Local::"
+ idl_struct.getIdentifier() + " parameter_"
! + p.getIdentifier() + ";");
if(direction != MParameterMode.PARAM_OUT) {
--- 776,798 ----
}
! protected String convertStructParameterFromCorbaToCpp(MParameterDef p,
! MStructDef idl_struct,
! boolean isSequenceItem)
{
MParameterMode direction = p.getDirection();
+
+ String item ="";
+ String index = "";
+ String indent = "";
+ if(isSequenceItem) {
+ item = "_item";
+ index = "[i]";
+ indent = " ";
+ }
List ret = new ArrayList();
! ret.add(indent + " CCM_Local::"
+ idl_struct.getIdentifier() + " parameter_"
! + p.getIdentifier() + item +";");
if(direction != MParameterMode.PARAM_OUT) {
***************
*** 779,791 ****
if(member_idl instanceof MPrimitiveDef
|| member_idl instanceof MStringDef) {
! ret.add(" "
! + "parameter_" + p.getIdentifier() + "." + member.getIdentifier()
! + " = CCM::CORBA" + base_type + "_to_" + base_type
! + "(" + p.getIdentifier() + "." + member.getIdentifier() + ");");
}
else {
// all other idl_types
// TODO
! ret.add("// unhandled idl type in convertStructFromCorbaToCpp()");
}
}
--- 804,818 ----
if(member_idl instanceof MPrimitiveDef
|| member_idl instanceof MStringDef) {
! ret.add(indent + " "
! + "parameter_" + p.getIdentifier() + item + "."
! + member.getIdentifier() + " = CCM::CORBA"
! + base_type + "_to_" + base_type + "("
! + p.getIdentifier() + index + "."
! + member.getIdentifier() + ");");
}
else {
// all other idl_types
// TODO
! ret.add(indent + " // unhandled idl type in convertStructFromCorbaToCpp()");
}
}
***************
*** 794,797 ****
--- 821,854 ----
}
+ protected String convertSequenceParameterFromCorbaToCpp(MParameterDef p,
+ MAliasDef alias)
+ {
+ MSequenceDef idl_sequence = (MSequenceDef)alias.getIdlType();
+ MIDLType sequence_type = ((MTyped)idl_sequence).getIdlType();
+ List ret = new ArrayList();
+
+ if(sequence_type instanceof MStructDef) {
+ MStructDef idl_struct = (MStructDef)sequence_type;
+
+ ret.add(" CCM_Local::" + alias.getIdentifier() + " parameter_"
+ + p.getIdentifier() + ";");
+
+ if(p.getDirection() != MParameterMode.PARAM_OUT) {
+ ret.add(" for(unsigned long i=0; i<" + p.getIdentifier() + ".length(); i++) {");
+ ret.add(convertStructParameterFromCorbaToCpp(p,idl_struct, true));
+ ret.add(" parameter_" + p.getIdentifier()
+ + ".push_back(parameter_" + p.getIdentifier() + "_item);");
+ ret.add(" }");
+ }
+ }
+ else {
+ // all other idl types
+ // TODO
+ return "// unhandled idl type in convertSequenceParameterFromCorbaToCpp()";
+ }
+
+
+ return join("\n", ret) + "\n";
+ }
/**
|