def writeCORBASequenceToSimple(out, type, cname, sarray, slength, fromCall=0, needAlloc=0): addRet = 0 if sarray == None: out.out(simplecxx.typeToSimpleCXX(type) + ' _myreturn;') addRet = 1 sarray = '_myreturn' # Do the easy part first... if fromCall: out.out(slength + ' = ' + cname + '.length();') else: out.out(slength + ' = ' + cname + '->length();') if needAlloc: out.out(sarray + ' = new ' +\ simplecxx.typeToSimpleCXX(type, extrapointer=-1) + '[' +\ slength + '];') # Allocate a temp var out.ci_count = out.ci_count + 1 ciname = '_ci%u' % out.ci_count out.out('size_t ' + ciname + ';') out.out('for (' + ciname + ' = 0; ' + ciname + ' < ' + slength +\ '; ' + ciname + '++)') out.out('{') out.inc_indent() assignfrom = cname + '[' + ciname + ']' assignto = sarray + '[' + ciname + ']' writeCORBAValueToSimple(out, type.unalias().seqType(), assignfrom, assignto) out.dec_indent() out.out('}') if addRet: out.out('return _myreturn;')
def visitAttribute(self, node): typename = simplecxx.typeToSimpleCXX(node.attrType(), is_ret=1) typenameC = simplecxx.typeToSimpleCXX(node.attrType(), is_const=1) possibleWarnUnused = simplecxx.shouldWarnIfUnused(node.attrType()) for n in node.declarators(): self.cxxheader.out('virtual ' + typename + ' ' + n.simplename + '(' + ') throw(std::exception&) ' + possibleWarnUnused + ' = 0;') if not node.readonly(): self.cxxheader.out('virtual void ' + n.simplename + '(' + typenameC + ' attr' + ') throw(std::exception&) = 0;')
def visitAttribute(self, node): typename = simplecxx.typeToSimpleCXX(node.attrType(), is_ret=1) typenameC = simplecxx.typeToSimpleCXX(node.attrType(), is_const=1) possibleWarnUnused = simplecxx.shouldWarnIfUnused(node.attrType()); for n in node.declarators(): self.cxxheader.out('virtual ' + typename + ' ' + n.simplename + '(' + ') throw(std::exception&) ' + possibleWarnUnused + ' = 0;') if not node.readonly(): self.cxxheader.out('virtual void ' + n.simplename + '(' + typenameC + ' attr' + ') throw(std::exception&) = 0;')
def visitException(self, node): self.cxxheader.out('PUBLIC_' + self.masterGuard + '_PRE ') self.cxxheader.out('class PUBLIC_' + self.masterGuard + '_POST ' + node.simplename + ' : public std::exception') self.cxxheader.out('{') self.cxxheader.out('public:') self.cxxheader.inc_indent() constructorArgs = '' constructorSave = '' for n in node.members(): if constructorArgs == '': constructorSave = ' : ' else: constructorArgs = constructorArgs + ', ' for dn in n.declarators(): constructorSave = constructorSave + ('%s(_%s)' % (dn.simplename, dn.simplename)) constructorArgs = constructorArgs + simplecxx.typeToSimpleCXX(n.memberType(), is_const=1) +\ ' _' + dn.simplename if dn.sizes() != None: constructorArgs = constructorArgs + string.join(map(lambda x: '[%s]'%x, dn.sizes()), '') self.cxxheader.out(' ' + node.simplename + '(' + constructorArgs + ')' + constructorSave + '{}') self.cxxheader.out(' ~' + node.simplename + '() throw() {}') for n in node.members(): n.accept(self) self.cxxheader.dec_indent() self.cxxheader.out('};')
def visitException(self, node): self.cxxheader.out('PUBLIC_' + self.masterGuard + '_PRE ') self.cxxheader.out('class PUBLIC_' + self.masterGuard + '_POST ' + node.simplename + ' : public std::exception') self.cxxheader.out('{') self.cxxheader.out('public:') self.cxxheader.inc_indent() constructorArgs = '' constructorSave = '' for n in node.members(): if constructorArgs == '': constructorSave = ' : ' else: constructorArgs = constructorArgs + ', ' for dn in n.declarators(): constructorSave = constructorSave + ( '%s(_%s)' % (dn.simplename, dn.simplename)) constructorArgs = constructorArgs + simplecxx.typeToSimpleCXX(n.memberType(), is_const=1) +\ ' _' + dn.simplename if dn.sizes() != None: constructorArgs = constructorArgs + string.join( map(lambda x: '[%s]' % x, dn.sizes()), '') self.cxxheader.out(' ' + node.simplename + '(' + constructorArgs + ')' + constructorSave + '{}') self.cxxheader.out(' ~' + node.simplename + '() throw() {}') for n in node.members(): n.accept(self) self.cxxheader.dec_indent() self.cxxheader.out('};')
def visitMember(self, node): alln = '' needcomma = 0 for n in node.declarators(): if needcomma: alln = alln + ', ' needcomma = 1 alln = alln + n.simplename sa = n.sizes() if sa != None: for s in sa: alln = alln + '[%u]'%s alln = simplecxx.typeToSimpleCXX(node.memberType(), is_ret=1) +\ ' ' + alln + ';' self.cxxheader.out(alln)
def visitOperation(self, node): rtype = simplecxx.typeToSimpleCXX(node.returnType(), is_ret=1) if node.simplename == 'query_interface': rtype = 'void*' call = 'virtual ' + rtype call = call + ' ' + node.simplename + '(' needcomma = 0 for n in node.parameters(): if needcomma: call = call + ', ' needcomma = 1 if n.is_out(): numpoint = 1 else: numpoint = 0 call = call + simplecxx.typeToSimpleCXX(n.paramType(), numpoint, not n.is_out()) +\ ' ' + n.simplename # Every operation can throw, e.g. in an I/O error, not just those that # list exceptions with raises. call = call + ') throw(std::exception&)' +\ simplecxx.shouldWarnIfUnused(node.returnType()) + ' = 0;' self.cxxheader.out(call)
def visitMember(self, node): alln = '' needcomma = 0 for n in node.declarators(): if needcomma: alln = alln + ', ' needcomma = 1 alln = alln + n.simplename sa = n.sizes() if sa != None: for s in sa: alln = alln + '[%u]' % s alln = simplecxx.typeToSimpleCXX(node.memberType(), is_ret=1) +\ ' ' + alln + ';' self.cxxheader.out(alln)
def visitTypedef(self, node): alln = '' needcomma = 0 for n in node.declarators(): if needcomma: alln = alln + ', ' needcomma = 1 alln = alln + n.simplename sa = n.sizes() if sa != None: for s in sa: alln = alln + '[%u]'%s # We always alias to the array part of a sequence. alln = 'typedef ' + simplecxx.typeToSimpleCXX(node.aliasType()) +\ ' ' + alln + ';' self.cxxheader.out(alln)
def visitTypedef(self, node): alln = '' needcomma = 0 for n in node.declarators(): if needcomma: alln = alln + ', ' needcomma = 1 alln = alln + n.simplename sa = n.sizes() if sa != None: for s in sa: alln = alln + '[%u]' % s # We always alias to the array part of a sequence. alln = 'typedef ' + simplecxx.typeToSimpleCXX(node.aliasType()) +\ ' ' + alln + ';' self.cxxheader.out(alln)
def writeCORBAValueToSimple(out, type, cname, sname, fromCall=0): type = type.unalias() tk = type.kind() addRet = 0 if sname == None: out.out(simplecxx.typeToSimpleCXX(type) + ' _myreturn;') addRet = 1 sname = '_myreturn' if tk == idltype.tk_null or tk == idltype.tk_void: raise "Can't convert a null/void" elif tk == idltype.tk_short: castAndAssign(out, sname, 'int16_t', cname) elif tk == idltype.tk_long: castAndAssign(out, sname, 'int32_t', cname) elif tk == idltype.tk_ushort: castAndAssign(out, sname, 'uint16_t', cname) elif tk == idltype.tk_ulong: castAndAssign(out, sname, 'uint32_t', cname) elif tk == idltype.tk_float: castAndAssign(out, sname, 'float', cname) elif tk == idltype.tk_double: castAndAssign(out, sname, 'double', cname) elif tk == idltype.tk_boolean: castAndAssign(out, sname, 'bool', cname) elif tk == idltype.tk_char: castAndAssign(out, sname, 'char', cname) elif tk == idltype.tk_octet: castAndAssign(out, sname, 'uint8_t', cname) elif tk == idltype.tk_any: raise 'Any is not supported' elif tk == idltype.tk_TypeCode: raise 'TypeCode is not supported' elif tk == idltype.tk_Principal: raise 'Principal is not supported' elif tk == idltype.tk_array or tk == idltype.tk_alias: # If we get here, it must be an array... convertArrayC2S(out, cname, sname, type.decl().sizes(), type.decl().alias().aliasType()) elif tk == idltype.tk_objref: convertObjRefC2S(out, type, cname, sname) elif tk == idltype.tk_struct: convertStructureC2S(out, type, cname, sname) elif tk == idltype.tk_sequence: raise "Internal error: you are not supposed to call " +\ "writeCORBAValueToSimple() on a sequence!" elif tk == idltype.tk_enum: # A simple cast will do here, because we match the values... castAndAssign(out, sname, type.decl().simplecxxscoped, cname) elif tk == idltype.tk_union: raise 'Union is not supported' elif tk == idltype.tk_string: convertStringC2S(out, cname, sname, fromCall) elif tk == idltype.tk_except: raise 'Can\'t pass an exception as a type.' elif tk == idltype.tk_longlong: castAndAssign(out, sname, 'int64_t', cname) elif tk == idltype.tk_ulonglong: castAndAssign(out, sname, 'uint64_t', cname) elif tk == idltype.tk_longdouble: castAndAssign(out, sname, 'long double', cname) elif tk == idltype.tk_wchar: castAndAssign(out, sname, 'wchar_t', cname) elif tk == idltype.tk_wstring: convertWStringC2S(out, cname, sname, fromCall) elif tk == idltype.tk_fixed: raise 'Fixed precision is not supported.' elif tk == idltype.tk_value: raise 'valuetype is not supported.' elif tk == idltype.tk_value_box: raise 'valuetype is not supported.' elif tk == idltype.tk_native: raise 'native is not supported.' elif tk == idltype.tk_abstract_interface or \ tk == idltype.tk_local_interface: raise 'Passing interfaces is not supported.' else: raise 'Unknown type kind %u' % tk if addRet: out.out('return _myreturn;')
def declareSimpleStorage(self, type, name): self.cci.out(simplecxx.typeToSimpleCXX(type) + ' ' + name + ';')
def visitAttribute(self, at): active = self.active_interface downcastStr = '_downcast_' + string.join(active.scopedName(), '_') +\ '()' psemi = '' pfq = 'CCI::' + active.corbacxxscoped + '::' if self.doing_header: psemi = ';' pfq = '' typename = simplecxx.typeToSimpleCXX(at.attrType()) typenameC = simplecxx.typeToSimpleCXX(at.attrType(), is_const=1) if simplecxx.doesTypeNeedLength(at.attrType()): extra_getter_params = 'uint32_t* _length_attr' extra_setter_params = ', uint32_t _length_attr' else: extra_getter_params = '' extra_setter_params = '' for n in at.declarators(): self.cci.out(typename + ' ' + pfq + n.simplename + '(' + extra_getter_params + ') throw(std::exception&)' + psemi) if not self.doing_header: self.cci.out('{') self.cci.inc_indent() self.cci.out('try') self.cci.out('{') self.cci.inc_indent() # 1) Declare storage... self.declareCORBAStorage(at.attrType(), '_corba_value') # 2) Call the getter and assign... self.cci.out('_corba_value = ' + downcastStr + '->' +\ n.simplename + '();') self.cci.ci_count = 0 self.declareSimpleStorage(at.attrType(), '_simple_value') if simplecxx.doesTypeNeedLength(at.attrType()): self.CORBASequenceToSimple(at.attrType(), '_corba_value', '_simple_value', '(*_length_attr)', needAlloc=1) conversionutils.destroyCORBASequence(self.cci,\ at.attrType(),\ '_corba_value') else: self.CORBAValueToSimple(at.attrType(), '_corba_value',\ '_simple_value') conversionutils.destroyCORBAValue(self.cci,\ at.attrType(),\ '_corba_value') self.cci.out('return _simple_value;') self.cci.dec_indent() self.cci.out('}') self.cci.out('catch (CORBA::Exception& cce)') self.cci.out('{') self.cci.inc_indent() self.cci.out( 'throw std::exception(/*"A CORBA error occurred"*/);') self.cci.dec_indent() self.cci.out('}') self.cci.dec_indent() self.cci.out('}') if not at.readonly(): self.cci.out('void ' + pfq + n.simplename + '(' + typenameC + ' attr' + extra_setter_params + ') throw(std::exception&)' + psemi) if not self.doing_header: self.cci.out('{') self.cci.inc_indent() self.cci.out('try') self.cci.out('{') self.cci.inc_indent() self.cci.ci_count = 0 self.declareCORBAStorage(at.attrType(), '_corba_value') if simplecxx.doesTypeNeedLength(at.attrType()): self.simpleSequenceToCORBA(at.attrType(), 'attr', '_length_attr', '_corba_value') else: self.simpleValueToCORBA(at.attrType(), 'attr', \ '_corba_value') # Finally, call the setter... self.cci.out(downcastStr + '->' + n.simplename +\ '(_corba_value);') self.cci.dec_indent() self.cci.out('}') self.cci.out('catch (CORBA::Exception& cce)') self.cci.out('{') self.cci.inc_indent() self.cci.out('throw std::exception(' +\ '/*"A CORBA error occurred"*/);') self.cci.dec_indent() self.cci.out('}') self.cci.dec_indent() self.cci.out('}')
def visitOperation(self, op): active = self.active_interface downcastStr = '_downcast_' + string.join(active.scopedName(), '_') +\ '()' psemi = '' pfq = 'CCI::' + active.corbacxxscoped + '::' if self.doing_header: psemi = ';' pfq = '' # Firstly, get the return type... rtype = simplecxx.typeToSimpleCXX(op.returnType()) if op.simplename == 'query_interface': rtype = 'void*' # Next, build up all the parameters... parstr = '' callstr = '' needcomma = 0 for p in op.parameters(): if needcomma: parstr = parstr + ', ' else: needcomma = 1 if p.is_out(): extrapointer = 1 else: extrapointer = 0 if simplecxx.doesTypeNeedLength(p.paramType()): parstr = parstr + 'uint32_t' if p.is_out(): parstr = parstr + '*' parstr = parstr + ' _length_' + p.simplename + ', ' parstr = parstr + simplecxx.typeToSimpleCXX(p.paramType(), \ extrapointer, not p.is_out()) +\ ' ' + p.simplename if simplecxx.doesTypeNeedLength(op.returnType()): if needcomma: parstr = parstr + ', ' parstr = parstr + 'uint32_t* _length__return' self.cci.out(rtype + ' ' + pfq + op.simplename + '(' + parstr +\ ') throw(std::exception&)' + psemi) if self.doing_header: return self.cci.ci_count = 0 if op.simplename == 'add_ref': self.writeAddRef() elif op.simplename == 'release_ref': self.writeReleaseRef() elif op.simplename == 'query_interface': self.writeQueryInterface() else: self.cci.out('{') self.cci.inc_indent() # All in parameters get converted to CORBA parameters for p in op.parameters(): if callstr != '': callstr = callstr + ',' callstr = callstr + '_corba_' + p.simplename self.declareCORBAStorage(p.paramType(), '_corba_' + p.simplename) # If it isn't an in parameter, leave it for now... if not p.is_in(): continue if simplecxx.doesTypeNeedLength(p.paramType()): sname = p.simplename slength = '_length_' + p.simplename if p.is_out(): sname = '(*' + p.simplename + ')' slength = '(*_length_' + p.simplename + ')' self.simpleSequenceToCORBA(p.paramType(), sname, slength, \ '_corba_' + p.simplename) else: sname = p.simplename if p.is_out(): sname = '(*' + sname + ')' self.simpleValueToCORBA(p.paramType(), sname, \ '_corba_' + p.simplename) # Declare storage for the return value... rt = op.returnType() returns = (rt.kind() != idltype.tk_void) retprefix = '' if returns: self.declareCORBAStorage(rt, '_corba_return') retprefix = '_corba_return = ' self.cci.out('try') self.cci.out('{') self.cci.inc_indent() # Next, make the call... self.cci.out(retprefix + downcastStr + '->' +\ op.simplename + '(' + callstr + ');') for p in op.parameters(): if p.is_out(): if p.is_in(): if simplecxx.doesTypeNeedLength(p.paramType()): conversionutils.destroySimpleSequence(\ self.cci, p.paramType(), '(*' + p.simplename + ')', '(*_length_' + p.simplename + ')') else: conversionutils.destroySimpleValue(\ self.cci, \ p.paramType(), \ '(*' + p.simplename + ')') # Assign the simple value from the CORBA value. if simplecxx.doesTypeNeedLength(p.paramType()): sname = '(*' + p.simplename + ')' slength = '(*_length_' + p.simplename + ')' self.CORBASequenceToSimple(p.paramType(),\ '_corba_' + p.simplename,\ sname, slength, needAlloc=1) else: sname = '(*' + p.simplename + ')' self.CORBAValueToSimple(p.paramType(),\ '_corba_' + p.simplename,\ sname) if p.is_in(): # Free the CORBA value... if simplecxx.doesTypeNeedLength(p.paramType()): conversionutils.destroyCORBASequence(\ self.cci, \ p.paramType(), \ '_corba_' + p.simplename) else: conversionutils.destroyCORBAValue(\ self.cci, \ p.paramType(), \ '_corba_' + p.simplename) if returns: self.declareSimpleStorage(rt, '_simple_return') if simplecxx.doesTypeNeedLength(rt): self.CORBASequenceToSimple(rt, '_corba_return', '_simple_return', '(*_length__return)', needAlloc=1) conversionutils.destroyCORBASequence(\ self.cci, rt, '_corba_return') else: self.CORBAValueToSimple(rt, '_corba_return', '_simple_return') conversionutils.destroyCORBAValue(\ self.cci, rt, '_corba_return') self.cci.out('return _simple_return;') self.cci.dec_indent() self.cci.out('}') self.cci.out('catch (CORBA::Exception& e)') self.cci.out('{') self.cci.inc_indent() self.cci.out('throw std::exception(/*"A CORBA exception ' +\ 'occurred."*/);') self.cci.dec_indent() self.cci.out('}') self.cci.dec_indent() self.cci.out('}')
def visitAttribute(self, at): active = self.active_interface downcastStr = '_downcast_' + string.join(active.scopedName(), '_') +\ '()' psemi = '' pfq = 'CCI::' + active.corbacxxscoped + '::' if self.doing_header: psemi = ';' pfq = '' typename = simplecxx.typeToSimpleCXX(at.attrType()) typenameC = simplecxx.typeToSimpleCXX(at.attrType(), is_const=1) if simplecxx.doesTypeNeedLength(at.attrType()): extra_getter_params = 'uint32_t* _length_attr' extra_setter_params = ', uint32_t _length_attr' else: extra_getter_params = '' extra_setter_params = '' for n in at.declarators(): self.cci.out(typename + ' ' + pfq + n.simplename + '(' + extra_getter_params + ') throw(std::exception&)' + psemi) if not self.doing_header: self.cci.out('{') self.cci.inc_indent() self.cci.out('try') self.cci.out('{') self.cci.inc_indent() # 1) Declare storage... self.declareCORBAStorage(at.attrType(), '_corba_value') # 2) Call the getter and assign... self.cci.out('_corba_value = ' + downcastStr + '->' +\ n.simplename + '();') self.cci.ci_count = 0 self.declareSimpleStorage(at.attrType(), '_simple_value') if simplecxx.doesTypeNeedLength(at.attrType()): self.CORBASequenceToSimple(at.attrType(), '_corba_value', '_simple_value', '(*_length_attr)', needAlloc=1) conversionutils.destroyCORBASequence(self.cci,\ at.attrType(),\ '_corba_value') else: self.CORBAValueToSimple(at.attrType(), '_corba_value',\ '_simple_value') conversionutils.destroyCORBAValue(self.cci,\ at.attrType(),\ '_corba_value') self.cci.out('return _simple_value;') self.cci.dec_indent() self.cci.out('}') self.cci.out('catch (CORBA::Exception& cce)') self.cci.out('{') self.cci.inc_indent() self.cci.out('throw std::exception(/*"A CORBA error occurred"*/);') self.cci.dec_indent() self.cci.out('}') self.cci.dec_indent() self.cci.out('}') if not at.readonly(): self.cci.out('void ' + pfq + n.simplename + '(' + typenameC + ' attr' + extra_setter_params + ') throw(std::exception&)' + psemi) if not self.doing_header: self.cci.out('{') self.cci.inc_indent() self.cci.out('try') self.cci.out('{') self.cci.inc_indent() self.cci.ci_count = 0 self.declareCORBAStorage(at.attrType(), '_corba_value') if simplecxx.doesTypeNeedLength(at.attrType()): self.simpleSequenceToCORBA(at.attrType(), 'attr', '_length_attr', '_corba_value') else: self.simpleValueToCORBA(at.attrType(), 'attr', \ '_corba_value') # Finally, call the setter... self.cci.out(downcastStr + '->' + n.simplename +\ '(_corba_value);') self.cci.dec_indent() self.cci.out('}') self.cci.out('catch (CORBA::Exception& cce)') self.cci.out('{') self.cci.inc_indent() self.cci.out('throw std::exception(' +\ '/*"A CORBA error occurred"*/);') self.cci.dec_indent() self.cci.out('}') self.cci.dec_indent() self.cci.out('}')
def visitOperation(self, op): active = self.active_interface downcastStr = '_downcast_' + string.join(active.scopedName(), '_') +\ '()' psemi = '' pfq = 'CCI::' + active.corbacxxscoped + '::' if self.doing_header: psemi = ';' pfq = '' # Firstly, get the return type... rtype = simplecxx.typeToSimpleCXX(op.returnType()) if op.simplename == 'query_interface': rtype = 'void*' # Next, build up all the parameters... parstr = '' callstr = '' needcomma = 0 for p in op.parameters(): if needcomma: parstr = parstr + ', ' else: needcomma = 1 if p.is_out(): extrapointer = 1 else: extrapointer = 0 if simplecxx.doesTypeNeedLength(p.paramType()): parstr = parstr + 'uint32_t' if p.is_out(): parstr = parstr + '*' parstr = parstr + ' _length_' + p.simplename + ', ' parstr = parstr + simplecxx.typeToSimpleCXX(p.paramType(), \ extrapointer, not p.is_out()) +\ ' ' + p.simplename if simplecxx.doesTypeNeedLength(op.returnType()): if needcomma: parstr = parstr + ', ' parstr = parstr + 'uint32_t* _length__return' self.cci.out(rtype + ' ' + pfq + op.simplename + '(' + parstr +\ ') throw(std::exception&)' + psemi) if self.doing_header: return self.cci.ci_count = 0 if op.simplename == 'add_ref': self.writeAddRef() elif op.simplename == 'release_ref': self.writeReleaseRef() elif op.simplename == 'query_interface': self.writeQueryInterface() else: self.cci.out('{') self.cci.inc_indent() # All in parameters get converted to CORBA parameters for p in op.parameters(): if callstr != '': callstr = callstr + ',' callstr = callstr + '_corba_' + p.simplename self.declareCORBAStorage(p.paramType(), '_corba_' + p.simplename) # If it isn't an in parameter, leave it for now... if not p.is_in(): continue if simplecxx.doesTypeNeedLength(p.paramType()): sname = p.simplename slength = '_length_' + p.simplename if p.is_out(): sname = '(*' + p.simplename + ')' slength = '(*_length_' + p.simplename + ')' self.simpleSequenceToCORBA(p.paramType(), sname, slength, \ '_corba_' + p.simplename) else: sname = p.simplename if p.is_out(): sname = '(*' + sname + ')' self.simpleValueToCORBA(p.paramType(), sname, \ '_corba_' + p.simplename) # Declare storage for the return value... rt = op.returnType() returns = (rt.kind() != idltype.tk_void) retprefix = '' if returns: self.declareCORBAStorage(rt, '_corba_return') retprefix = '_corba_return = ' self.cci.out('try') self.cci.out('{') self.cci.inc_indent() # Next, make the call... self.cci.out(retprefix + downcastStr + '->' +\ op.simplename + '(' + callstr + ');') for p in op.parameters(): if p.is_out(): if p.is_in(): if simplecxx.doesTypeNeedLength(p.paramType()): conversionutils.destroySimpleSequence(\ self.cci, p.paramType(), '(*' + p.simplename + ')', '(*_length_' + p.simplename + ')') else: conversionutils.destroySimpleValue(\ self.cci, \ p.paramType(), \ '(*' + p.simplename + ')') # Assign the simple value from the CORBA value. if simplecxx.doesTypeNeedLength(p.paramType()): sname = '(*' + p.simplename + ')' slength = '(*_length_' + p.simplename + ')' self.CORBASequenceToSimple(p.paramType(),\ '_corba_' + p.simplename,\ sname, slength, needAlloc=1) else: sname = '(*' + p.simplename + ')' self.CORBAValueToSimple(p.paramType(),\ '_corba_' + p.simplename,\ sname) if p.is_in(): # Free the CORBA value... if simplecxx.doesTypeNeedLength(p.paramType()): conversionutils.destroyCORBASequence(\ self.cci, \ p.paramType(), \ '_corba_' + p.simplename) else: conversionutils.destroyCORBAValue(\ self.cci, \ p.paramType(), \ '_corba_' + p.simplename) if returns: self.declareSimpleStorage(rt, '_simple_return') if simplecxx.doesTypeNeedLength(rt): self.CORBASequenceToSimple(rt, '_corba_return', '_simple_return', '(*_length__return)', needAlloc=1) conversionutils.destroyCORBASequence(\ self.cci, rt, '_corba_return') else: self.CORBAValueToSimple(rt, '_corba_return', '_simple_return') conversionutils.destroyCORBAValue(\ self.cci, rt, '_corba_return') self.cci.out('return _simple_return;') self.cci.dec_indent() self.cci.out('}') self.cci.out('catch (CORBA::Exception& e)') self.cci.out('{') self.cci.inc_indent() self.cci.out('throw std::exception(/*"A CORBA exception ' +\ 'occurred."*/);'); self.cci.dec_indent() self.cci.out('}') self.cci.dec_indent() self.cci.out('}')
def visitConst(self, node): # Note: Can't have a const sequence, so don't call doesTypeNeedLenth self.cxxheader.out('static const ' +\ simplecxx.typeToSimpleCXX(node.constType()) +\ ' ' + node.simplename + ' = ' +\ simplecxx.enumOrInt(node.value()) + ';')