DDS_StdString be_argument::SyncStreamIn(const DDS_StdString& in, pbbool isStubSide) const { if (BeType()->IsOpaqueType() && isStubSide) { return BeType()->UnionStreamIn(LocalName(), in); } else return BeType()->SyncStreamIn(LocalName(), in, MakeVarType(((be_argument *)this)->direction())); }
void be_exception::GenerateCopyConstructor (be_ClientImplementation & source) { ostream & os = source.Stream (); os << ScopedName () << "::" << LocalName () << " (const " << LocalName () << " & that)" << nl << " : DDS::UserException (that)" << nl << "{" << nl << " *this = that;" << nl << "}" << nl << nl; }
void be_structure::GenerateMemcpyCopyConstructor(be_ClientHeader& source) { ostream & os = source.Stream(); be_Tab tab(source); os << tab << LocalName() << "(const " << LocalName() << "& that)" << nl; os << tab << "{" << nl << tab.indent() << tab << "memcpy(this, &that, sizeof(" << LocalName() << "));" << nl << tab.outdent() << tab << "}" << nl; }
void be_exception::GenerateAssignmentOperator (be_ClientImplementation& source) { ostream & os = source.Stream (); DDS_StdString that (""); be_Type * btype; if (nmembers ()) { that = " that"; } os << ScopedName () << " & " << ScopedName () << "::operator = (const " << LocalName () << " &" << that << ")" << nl; os << "{" << nl; UTL_Scope * s = (UTL_Scope*)narrow((long) & UTL_Scope::type_id); assert (s); UTL_ScopeActiveIterator *it; // Iterate through decls for ( it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls); ! it->is_done (); it->next () ) { AST_Decl * adecl = it->item (); assert (adecl); be_field *bfield = (be_field *) adecl->narrow ((long) & be_field::type_id); if (bfield) { btype = bfield->get_be_type (); if (btype && btype->IsArrayType ()) { // Need to copy array elements os << " " << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ()) << "_copy (" << bfield->get_local_name () << ", that." << bfield->get_local_name () << ");" << nl; } else { os << " " << bfield->get_local_name () << " = that." << bfield->get_local_name() << ";" << nl; } } } delete it; os << " return *this;" << nl; os << "}" << nl << nl; }
string &CurPath2ComputerName(const string& CurDir, string &strComputerName, string &strTail) { string strNetDir; strComputerName.clear(); strTail.clear(); if (!CurDir.compare(0, 2, L"\\\\")) { strNetDir = CurDir; } else { string LocalName(CurDir.data(), 2); api::WNetGetConnection(LocalName, strNetDir); } if (!strNetDir.compare(0, 2, L"\\\\")) { strComputerName = strNetDir.substr(2); size_t pos; if (!FindSlash(pos,strComputerName)) strComputerName.clear(); else { strTail = strComputerName.substr(pos + 1); strComputerName.resize(pos); } } return strComputerName; }
void be_exception::GenerateConvenienceConstructor (be_ClientHeader& source) { ostream & os = source.Stream (); const char * argPrefix = "_"; pbbool first = pbtrue; be_Tab tab (source); os << tab << LocalName () << " ("; UTL_Scope * s = (UTL_Scope*)narrow ((long) & UTL_Scope::type_id); assert (s); // Iterate through decls UTL_ScopeActiveIterator *it; for ( it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls); !it->is_done (); it->next () ) { AST_Decl * adecl = it->item(); assert (adecl); be_field * bfield = be_field::_narrow (adecl); be_Type * btype; if (bfield) { btype = bfield->get_be_type (); if (!first) { os << ", "; } first = pbfalse; if (btype && btype->IsStringType ()) { // Strings are special case os << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->InTypeName ()); } else { os << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ()); } os << " " << argPrefix << (char*) bfield->get_local_name (); } } delete it; os << ");" << nl; }
void be_structure::GenerateDefaultConstructor(be_ClientHeader& source) { ostream & os = source.Stream(); be_Tab tab(source); os << tab << LocalName() << "()" << nl; os << tab << "{" << nl << tab << "}" << nl; }
void be_attribute::GenerateGetDispatcher ( be_ServerImplementation & source, const DDS_StdString & implClassName ) { be_CppName name (LocalName ()); DDS_StdString strName ("_get_" + LocalName ()); be_CppName getName (strName); be_Dispatcher dispatcher ( name, getName, implClassName, be_ArgumentList (), source, fieldType ); dispatcher.Generate (); }
void be_structure::GenerateAuxTypes (be_ClientHeader& source) { if (BE_Globals::isocpp_new_types) return; DDS_StdString varName = LocalName () + "_var"; DDS_StdString outName = LocalName () + "_out"; ostream & os = source.Stream (); be_Tab tab (source); if (m_isFixedLength) { os << tab << "typedef DDS_DCPSStruct_var < " << LocalName() << "> " << varName << ";" << nl; os << tab << "typedef " << LocalName () << "&" << outName << ";" << nl; } else { os << tab << "typedef DDS_DCPSStruct_var < " << LocalName() << "> " << varName << ";" << nl; os << tab << "typedef DDS_DCPSStruct_out < " << LocalName() << "> " << outName << ";" << nl; } }
void be_attribute::GenerateSetDispatcher ( be_ServerImplementation & source, const DDS_StdString & implClassName ) { be_CppName name (LocalName ()); DDS_StdString strName ("_set_" + LocalName ()); be_CppName setName (strName); be_Argument arg ("_nval_", *fieldType, VT_InParam); be_ArgumentList list (arg); be_Dispatcher dispatcher ( name, setName, implClassName, list, source ); dispatcher.Generate (); }
be_attribute::be_attribute ( idl_bool ro, AST_Type *ft, UTL_ScopedName *n, const UTL_Pragmas &p ) : AST_Decl (AST_Decl::NT_attr, n, p), AST_Field (AST_Decl::NT_attr, ft, n, p), AST_Attribute (ro, ft, n, p), fieldType (0), m_getDispatchDone (FALSE), m_setDispatchDone (FALSE) { assert(field_type()); isAtModuleScope(pbfalse); if (field_type()) { fieldType = (be_DispatchableType*)field_type()->narrow((long) & be_Type::type_id); assert(fieldType); const char * typeName = fieldType->TypeName (); if (typeName && strcmp (typeName, "DDS::Any") == 0) { BE_Globals::inc_any = pbtrue; } } else { DDSError((DDS_StdString)"unknown field type for attribute " + LocalName()); } enclosingScope = be_Type::EnclosingScopeString(this); setOpKey = (DDS_StdString) "_set_" + LocalName(); getOpKey = (DDS_StdString) "_get_" + LocalName(); }
void be_attribute::GenerateImpureRequestCall(be_ClientImplementation& source) { be_AttStubGenerator getStub ( enclosingScope, getOpKey, LocalName (), GetSignature (AT_Implementation, InterfaceBasename (), pbfalse), fieldType, FALSE ); getStub.Generate(source); if (!readonly()) { DDS_StdString setArg ("_nval_"); DDS_StdString setSignature = SetSignature ( AT_Implementation, InterfaceBasename(), FALSE, setArg ); be_AttStubGenerator setStub ( enclosingScope, setOpKey, LocalName(), setSignature, fieldType, pbtrue ); setStub.Generate(source); } }
void be_operation::GenerateSyncDispatcher (be_ServerImplementation & source, const DDS_StdString & implclassname) { be_Dispatcher dispatcher ( LocalName (), implclassname, arguments, source, returnType ); dispatcher.Generate (); }
void be_operation::GenerateImpureRequestCall (be_ClientImplementation & source) { be_OpStubGenerator stub ( stubClassname, opKey, LocalName (), StubSignature (OP_Implementation), returnType, is_oneway (), arguments, exceptions (), context (), local_name ()->get_string () ); stub.Generate (source); }
void be_operation::GenerateSyncCall (be_ServerImplementation & source) { const DDS_StdString opret ("_ret_"); pbbool firstArg = pbtrue; ostream & os = source.Stream (); be_Tab tab (source); TList < be_argument * >::iterator ait; os << tab; if (HasReturn ()) { os << opret << " = "; } os << "_servant_->" << LocalName () << "("; // PASS ALL ARGS for (ait = arguments.begin (); ait != arguments.end (); ait++) { if (!firstArg) { os << ", "; } firstArg = pbfalse; os << (*ait)->LocalName (); } if (firstArg) { os << XBE_Ev::arg (XBE_ENV_VAR1); } else { os << XBE_Ev::arg (XBE_ENV_VARN); } os << ");" << nl; }
be_operation::be_operation ( AST_Type * rt, AST_Operation::Flags fl, UTL_ScopedName * n, const UTL_Pragmas & p ) : AST_Decl (AST_Decl::NT_op, n, p), UTL_Scope (AST_Decl::NT_op, n, p), AST_Operation (rt, fl, n, p), returnType (0), n_InArgs (0), n_OutArgs (0), n_InOutArgs (0), n_Args (0) { assert (return_type ()); isAtModuleScope (pbfalse); if (return_type ()) { returnType = (be_DispatchableType *) return_type ()-> narrow ((long) &be_DispatchableType::type_id); const char * typeName = returnType->TypeName (); if (typeName && strcmp (typeName, "DDS::Any") == 0) { BE_Globals::inc_any = pbtrue; } } else { DDSError ((DDS_StdString) "unknown return type for operation " + LocalName ()); } enclosingScope = be_Type::EnclosingScopeString (this); stubClassname = enclosingScope + DDSStubExtension; opKey = NameToString (name (), "_"); }
DDS_StdString be_operation::StubSignature (OP_SignatureType sigType) { UTL_ScopeActiveIterator * i = new UTL_ScopeActiveIterator (this, IK_decls); ostringstream os; pbbool first = pbtrue; DDS_StdString ret; AST_Decl * d; // Generate return type assert (returnType); if (sigType == OP_Implementation) { os << returnType->MakeSignature (VT_Return, "") << " " << nl; } else { os << returnType->MakeSignature (VT_Return, iface->ScopedName ()) << " "; } // Op name if (sigType == OP_Implementation) { os << iface->Scope (iface->StubClassname ()) << "::" << LocalName (); } else { os << LocalName (); } // Generate parameter list os << " ("; for (; !(i->is_done ()); i->next ()) { be_argument * arg; d = i->item (); arg = (be_argument *) d->narrow ((long) &be_argument::type_id); if (arg) { if (!first) { os << ", "; } first = pbfalse; os << arg->Signature (iface->ScopedName ()); os << " " << *arg->local_name (); } } delete i; #if defined (CONTEXT_SUPPORT) // Add context if (context ()) { if (!first) { os << ", "; } first = pbfalse; os << BE_Globals::CorbaScope ("Context_ptr"); os << " " << DDSCtxVar; } #endif if (!first) { os << XBE_Ev::arg (XBE_ENV_ARGN); } else { os << XBE_Ev::arg (XBE_ENV_ARG1); } os << ")" << ends; ret = os.str().c_str(); return ret; }
void be_exception::Generate (be_ClientImplementation& source) { ostream & os = source.Stream(); be_Tab tab (source); UTL_String * repID = get_decl_pragmas().get_repositoryID(); const DDS_StdString corbaException = "DDS::Exception"; // convenience constructor if (nmembers()) { GenerateConvenienceConstructor(source); } // copy constructor GenerateCopyConstructor (source); // assignment operator GenerateAssignmentOperator (source); be_CodeGenerator::Generate (source); // name and id assert (repID); os << "const char * " << ScopedName () << "::m_name = \"" << LocalName () << "\";" << nl << nl; os << "const char * " << ScopedName () << "::m_id = \"" << repID->get_string () << "\";" << nl << nl; // downcast os << tab << ScopedName () << " * "; os << ScopedName () << "::"; os << "_downcast (DDS::Exception * e)" << nl; os << tab << "{" << nl; tab.indent (); os << tab << "if (e && (e->_rep_id () == m_id))" << nl; os << tab << "{" << nl; tab.indent (); os << tab << "return static_cast < " << LocalName () << "*> (e);" << nl; tab.outdent (); os << tab << "}" << nl; os << tab << "return 0;" << nl; tab.outdent (); os << tab << "}" << nl << nl; // const downcast os << tab << "const " << ScopedName() << " * "; os << ScopedName () << "::"; os << "_downcast (const DDS::Exception * e)" << nl; os << tab << "{" << nl; tab.indent (); os << tab << "if (e && (e->_rep_id () == m_id))" << nl; os << tab << "{" << nl; tab.indent (); os << tab << "return static_cast < " << LocalName () << "*> ((" << LocalName () << "*) e);" << nl; tab.outdent (); os << tab << "}" << nl; os << tab << "return 0;" << nl; tab.outdent (); os << tab << "}" << nl << nl; // _clone os << tab << corbaException << " * " << ScopedName (); os << "::_clone () const" << nl; os << tab << "{" << nl; tab.indent (); os << tab << "return (" << corbaException << "*) new "; os << ScopedName () << " (*this);" << nl; tab.outdent (); os << tab << "}" << nl << nl; // raise os << tab << "void " << ScopedName () << "::_raise (" << XBE_Ev::arg (XBE_ENV_ARG1) << ") const" << nl; os << tab << "{" << nl; tab.indent (); os << tab; XBE_Ev::throwex (os, "*this"); os << nl; tab.outdent (); os << tab << "}" << nl << nl; // factory os << tab << "DDS::Exception * " << ScopedName() << "::factory ()" << nl; os << tab << "{" << nl; tab.indent (); os << tab << "return new " << ScopedName () << ";" << nl; tab.outdent (); os << tab << "}" << nl << nl; // initilaizer os << "DDS::ExceptionInitializer " << ScopedName() << "::m_initializer ("; os << "\"" << repID->get_string () << "\""; os << ", " << ScopedName () << "::factory);" << nl; }
void be_exception::Generate (be_ClientHeader & source) { if (!Generated ()) { ostream & os = source.Stream (); be_Tab tab (source); DDS_StdString lname = LocalName (); Generated (pbtrue); be_root::AddGlobalDeclarations (this); be_root::AddAnyOps (*this); be_root::AddStreamOps (*this); be_root::AddTypedef (*this); be_root::AddTypecode (*this); GenerateOpenClassDefinition (source); GenerateClassDeclarations (source); SetAccess (source, CA_PUBLIC); // now define nested types be_CodeGenerator::Generate (source); // generate _downcast os << tab << "static " << lname << "* _downcast (" << "DDS::Exception *);" << nl; os << tab << "static const " << lname << "* _downcast (" << "const DDS::Exception *);" << nl; // generate factory and builder os << tab << "static DDS::Exception * factory ();" << nl; os << tab << "static DDS::ExceptionInitializer m_initializer;" << nl << nl; // generate inline default constructor os << tab << lname << " () {};" << nl; // generate convenience constructor if (nmembers()) { GenerateConvenienceConstructor (source); } // generate copy constructor os << tab << lname << " (const " << lname << " &);" << nl; // generate assignment operator os << tab << lname << "& operator = " << "(const " << lname << " &);" << nl; // generate duplicate os << tab << "virtual DDS::Exception * _clone () const;" << nl; // generate raise os << tab << "virtual void _raise (" << XBE_Ev::arg (XBE_ENV_ARG1) << ") const;" << nl; // generate name os << tab << "virtual const char * _name () const { return m_name; };" << nl; // generate repository id os << tab << "virtual const char * _rep_id () const { return m_id; };" << nl; // generate virtual destructor os << tab << "virtual ~" << lname << " () {}" << nl; GenerateMembers (source); SetAccess (source, CA_PRIVATE); os << tab << "static const char * m_name;" << nl; os << tab << "static const char * m_id;" << nl; GenerateCloseClassDefinition (source); be_root::GenerateDependants ( source, SequenceMemberTypeName (), EnclosingScope () ); } }
void be_structure::Generate (be_ClientHeader& source) { if (BE_Globals::ignore_interfaces && IsInterfaceDependant ()) { return; } if (!Generated()) { be_root::AddAnyOps(*this); be_root::AddPutGetOps(*this); be_root::AddStreamOps(*this); be_root::AddTypedef(*this); be_root::AddTypecode(*this); ostream & os = source.Stream(); DDS_StdString scopedName = ScopedName(); DDS_StdString relativeName; be_Tab tab(source); TList<be_field *>::iterator mit; be_field * field; Generated (pbtrue); be_root::GenerateDependants(source, SequenceMemberTypeName(), EnclosingScope()); g_cppScopeStack.Push(m_cppType); // struct definition os << nl; os << tab << "struct " << DLLMACRO << LocalName () << nl; os << tab << "{" << nl; source.Indent (); // declare nested types be_CodeGenerator::Generate(source); // member declarations for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; relativeName = BE_Globals::RelativeScope (scopedName, field->StructMemberTypeName ()); os << tab << relativeName << " " << field->get_local_name() << ";" << nl; } source.Outdent(); source.Stream() << tab << "};" << nl << nl; g_cppScopeStack.Pop(); GenerateAuxTypes (source); be_root::GenerateDependants(source, SequenceMemberTypeName(), EnclosingScope()); } }
DDS_StdString be_attribute::GetSignature(AT_SignatureType sigType, const DDS_StdString& className, pbbool pureVirtual) { DDS_StdString ret; assert(fieldType); if (fieldType) { ostringstream os; // Output the type switch (sigType) { case AT_Implementation: os << fieldType->MakeSignature(VT_Return) << "\n"; os << className << "::"; break; case AT_Declaration: os << fieldType->MakeSignature(VT_Return, className) << "\t"; break; case AT_TieImplementation: os << fieldType->MakeSignature(VT_Return, "") << " "; break; case AT_Invoke: case AT_TieInvoke: // nothing break; default: assert(0); break; } os << LocalName() << "("; switch (sigType) { case AT_Declaration: os << XBE_Ev::arg (XBE_ENV_ARG1); break; case AT_Implementation: case AT_TieImplementation: os << XBE_Ev::arg (XBE_ENV_ARG1); break; case AT_Invoke: os << XBE_Ev::arg (XBE_ENV_VAR1); break; case AT_TieInvoke: // nothing break; default: assert(0); break; } os << ")" << ends; ret = os.str().c_str(); } return ret; }
void be_exception::GenerateConvenienceConstructor (be_ClientImplementation & source) { ostream & os = source.Stream (); const char * argPrefix = "_"; pbbool first = pbtrue; be_Tab tab (source); be_Type * btype; os << ScopedName () << "::" << LocalName () << " ("; UTL_Scope * s = (UTL_Scope*)narrow ((long) & UTL_Scope::type_id); assert (s); // Iterate through decls UTL_ScopeActiveIterator * it; for ( it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls); !it->is_done (); it->next () ) { AST_Decl * adecl = it->item (); assert (adecl); be_field *bfield = (be_field *)adecl->narrow ((long) & be_field::type_id); if (bfield) { btype = bfield->get_be_type (); if (!first) { os << ", "; } first = pbfalse; if (btype && btype->IsStringType ()) { // Strings are special case os << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->InTypeName ()); } else { os << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ()); } os << " " << argPrefix << (char*) bfield->get_local_name (); } } delete it; os << ")" << nl; // Iterate thru members initializing if (nmembers ()) { source.Indent (); first = pbtrue; for ( it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls); !it->is_done (); it->next () ) { AST_Decl * adecl = it->item (); assert (adecl); be_field *bfield = (be_field *)adecl->narrow ((long) & be_field::type_id); if (bfield) { btype = bfield->get_be_type (); // Array members are assigned in body of method if (btype && ! btype->IsArrayType ()) { if (first) { first = pbfalse; os << " : " << nl; } else { os << "," << nl; } os << " " << (char*) bfield->get_local_name () << "(" << argPrefix << (char*) bfield->get_local_name () << ")"; } } } delete it; source.Outdent (); } os << nl; os << tab << "{" << nl; for ( it = new UTL_ScopeActiveIterator (s, UTL_Scope::IK_decls); ! it->is_done (); it->next () ) { AST_Decl * adecl = it->item (); assert (adecl); be_field *bfield = (be_field *) adecl->narrow ((long) & be_field::type_id); if (bfield) { btype = bfield->get_be_type (); if (btype && btype->IsArrayType ()) { // Need to copy array elements os << " " << (char*) BE_Globals::RelativeScope (ScopedName (), bfield->StructMemberTypeName ()) << "_copy (" << argPrefix << bfield->get_local_name () << ", " << bfield->get_local_name () << ");" << nl; } } } delete it; os << "}" << nl << nl; }
DDS_StdString be_attribute::SetSignature(AT_SignatureType sigType, const DDS_StdString& className, pbbool pureVirtual, const DDS_StdString& argName) { DDS_StdString ret; if (fieldType) { ostringstream os; if ( sigType == AT_Implementation || sigType == AT_Declaration || sigType == AT_TieImplementation ) { os << "void "; } if (sigType == AT_Implementation) { os << className << "::"; } os << LocalName() << "("; if ( sigType == AT_TieImplementation || sigType == AT_Declaration || sigType == AT_Implementation ) { os << fieldType->MakeSignature(VT_InParam, className); os << " "; } os << argName; switch (sigType) { case AT_Declaration: case AT_Implementation: case AT_TieImplementation: os << XBE_Ev::arg (XBE_ENV_ARGN); break; case AT_Invoke: os << XBE_Ev::arg (XBE_ENV_VARN); break; case AT_TieInvoke: // nothing break; default: assert(0); } os << ")" << ends; ret = os.str().c_str(); } return ret; }
DDS_StdString be_operation::BaseSignature (const DDS_StdString & implclassname) { UTL_ScopeActiveIterator * i = new UTL_ScopeActiveIterator (this, IK_decls); ostringstream os; pbbool first = pbtrue; DDS_StdString ret; AST_Decl * d; bool fullScope = (iface->BaseClassname () != implclassname); // GENERATE RETURN TYPE assert (returnType); if (fullScope) { os << returnType->MakeSignature (VT_Return, "") << " "; } else { os << returnType->MakeSignature (VT_Return, iface->ScopedName ()) << " "; } os << LocalName (); // GENERATE PARAMETER LIST os << " ("; for (; !(i->is_done ()); i->next ()) { be_argument *arg; d = i->item (); arg = (be_argument *) d->narrow ((long) &be_argument::type_id); if (arg) { if (!first) os << ", "; first = pbfalse; if (fullScope) { os << arg->Signature (""); } else { os << arg->Signature (iface->ScopedName ()); } os << " " << *arg->local_name (); } } delete i; #if defined(CONTEXT_SUPPORT) // // add context // if (context ()) { if (!first) { os << ", "; } first = pbfalse; os << BE_Globals::CorbaScope ("Context_ptr"); os << " " << DDSCtxVar; } #endif if (!first) { os << XBE_Ev::arg (XBE_ENV_ARGN); } else { os << XBE_Ev::arg (XBE_ENV_ARG1); } os << ")" << ends; ret = os.str().c_str(); return ret; }
DDS_StdString be_operation::ScopedBaseRequestCall () { UTL_ScopeActiveIterator * i = new UTL_ScopeActiveIterator (this, IK_decls); ostringstream os; pbbool first = pbtrue; DDS_StdString ret; AST_Decl * d; DDS_StdString ifaceBasename_nocolons = NoColons (iface->ScopedName ()); if (ifaceBasename_nocolons.length ()) { os << ifaceBasename_nocolons << "::" << LocalName (); } else { os << LocalName (); } // GENERATE PARAMETER LIST os << "("; for (; !(i->is_done ()); i->next ()) { be_argument * arg; d = i->item (); arg = (be_argument *) d->narrow ((long) &be_argument::type_id); if (arg) { if (!first) { os << ", "; } first = pbfalse; os << " " << arg->LocalName (); } } delete i; // ADD CONTEXT if (context ()) { if (!first) os << ", "; first = pbfalse; os << " " << DDSCtxVar; } // THIS IS FOR PROPERTIES if (!first) os << ", "; os << "0"; first = pbfalse; os << ")" << ends; ret = os.str().c_str(); return ret; }
DDS_StdString be_argument::Releaser() const { return BeType()->Releaser(LocalName()); }
DDS_StdString be_operation::DirectSignature ( OP_SignatureType sigType, const DDS_StdString & implclassname ) { UTL_ScopeActiveIterator *i = new UTL_ScopeActiveIterator (this, IK_decls); ostringstream os; pbbool first = pbtrue; DDS_StdString ret; AST_Decl *d; // GENERATE RETURN TYPE if (sigType != OP_Invoke) { assert (returnType); os << returnType->MakeSignature (VT_Return, "") << " "; } if (sigType != OP_Declaration) { os << implclassname << "::"; } // OP NAME os << LocalName (); // GENERATE PARAMETER LIST os << "("; for (; !(i->is_done ()); i->next ()) { be_argument *arg; d = i->item (); arg = (be_argument *) d->narrow ((long) &be_argument::type_id); if (arg) { if (!first) os << ", "; first = pbfalse; if (sigType != OP_Invoke) { os << arg->Signature (""); } os << " " << *arg->local_name (); } } delete i; #if defined(CONTEXT_SUPPORT) // ADD CONTEXT if (context ()) { if (!first) { os << ", "; } first = pbfalse; if (sigType != OP_Invoke) { os << BE_Globals::CorbaScope ("Context_ptr"); } os << " " << DDSCtxVar; } #endif if (sigType == OP_Invoke) { if (!first) { os << XBE_Ev::arg (XBE_ENV_VARN); } else { os << XBE_Ev::arg (XBE_ENV_VAR1); } } else { if (!first) { os << XBE_Ev::arg (XBE_ENV_ARGN); } else { os << XBE_Ev::arg (XBE_ENV_ARG1); } } os << ")" << ends; ret = os.str ().c_str (); return ret; }
void be_structure::Generate (be_ClientHeader& source) { if (BE_Globals::ignore_interfaces && IsInterfaceDependant ()) { return; } if (!Generated()) { be_root::AddAnyOps(*this); be_root::AddPutGetOps(*this); be_root::AddStreamOps(*this); be_root::AddTypedef(*this); be_root::AddTypecode(*this); ostream & os = source.Stream(); DDS_StdString scopedName = ScopedName(); DDS_StdString relativeName; be_Tab tab(source); TList<be_field *>::iterator mit; be_field * field; Generated (pbtrue); be_root::GenerateDependants(source, SequenceMemberTypeName(), EnclosingScope()); g_cppScopeStack.Push(m_cppType); // struct definition os << nl; os << tab << (BE_Globals::isocpp_new_types ? "class " : "struct ") << DLLMACRO << LocalName () << (BE_Globals::isocpp_new_types ? " OSPL_DDS_FINAL" : "") << nl; os << tab << "{" << nl; if (BE_Globals::isocpp_new_types) os << tab << "public:" << nl; source.Indent(); // declare nested types source.Indent(); be_CodeGenerator::Generate(source); // member accessor functions for isocpp new types if (BE_Globals::isocpp_new_types) { /** @internal * @todo OSPL-3369 Repetition; the sort of code people go to hell * for (rightfully); is_sequency is already evideantally a stupid name; &c... */ // Constructors if (m_fields.size() > 0) { os << tab << LocalName() << "() {}" << nl; os << tab << "explicit " << LocalName() << "(" << nl; for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; bool is_sequency = !(field->get_be_type()->IsPrimitiveType() || field->get_be_type()->IsEnumeratedType()); relativeName = BE_Globals::RelativeScope (scopedName, field->StructMemberTypeName ()); TList<be_field *>::iterator final_field = m_fields.end(); --final_field; os << tab << tab << (is_sequency ? "const " : "") << relativeName << (is_sequency ? "& " : " ") << field->get_local_name(); if (mit == final_field) os << ")"; else os <<"," << nl; } os << tab << ":" << nl; for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; TList<be_field *>::iterator final_field = m_fields.end(); --final_field; os << tab << tab << tab << field->get_local_name() << "_(" << field->get_local_name() << ")" << (mit == final_field ? " {}" : ",") << nl; } } // C++ 11 move constructor, copy consructor, and assignement ops source.Outdent(); os << "#ifdef OSPL_DDS_CXX11" << nl; os << "# ifdef OSPL_CXX11_NO_FUNCTION_DEFAULTS" << nl; source.Indent(); os << tab << LocalName() << "(const " << LocalName() << "& _other)" << nl; if (m_fields.size() > 0) { os << tab << ":" << nl; for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; TList<be_field *>::iterator final_field = m_fields.end(); --final_field; os << tab << tab << tab << field->get_local_name() << "_(_other." << field->get_local_name() << "_)" << (mit == final_field ? "" : ",") << nl; } } os << tab << "{}" << nl; os << tab << LocalName() << "(" << LocalName() << "&& _other)" << nl; if (m_fields.size() > 0) { os << tab << ":" << nl; for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; TList<be_field *>::iterator final_field = m_fields.end(); --final_field; os << tab << tab << tab << field->get_local_name() << "_(::std::move(_other." << field->get_local_name() << "_))" << (mit == final_field ? "" : ",") << nl; } } os << tab << "{}" << nl; os << tab << LocalName() << "& operator=(" << LocalName() << "&& _other)" << nl; os << tab << "{" << nl ; if (m_fields.size() > 0) { os << tab << tab << "if (this != &_other)" << nl; os << tab << tab << "{" << nl; for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; TList<be_field *>::iterator final_field = m_fields.end(); --final_field; os << tab << tab << tab << field->get_local_name() << "_ = ::std::move(_other." << field->get_local_name() << "_);" << nl; } os << tab << tab << "}" << nl; } os << tab << tab << "return *this;" << nl; os << tab << "}" << nl; os << tab << LocalName() << "& operator=(const " << LocalName() << "& _other)" << nl; os << tab << "{" << nl ; if (m_fields.size() > 0) { os << tab << tab << "if (this != &_other)" << nl; os << tab << tab << "{" << nl; for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; TList<be_field *>::iterator final_field = m_fields.end(); --final_field; os << tab << tab << tab << field->get_local_name() << "_ = _other." << field->get_local_name() << "_;" << nl; } os << tab << tab << "}" << nl; } os << tab << tab << "return *this;" << nl; os << tab << "}" << nl; source.Outdent(); os << "# else" << nl; source.Indent(); os << tab << LocalName() << "(const " << LocalName() << "& _other) = default;" << nl; os << tab << LocalName() << "(" << LocalName() << "&& _other) = default;" << nl; os << tab << LocalName() << "& operator=(" << LocalName() << "&& _other) = default;" << nl; os << tab << LocalName() << "& operator=(const " << LocalName() << "& _other) = default;" << nl; source.Outdent(); os << "# endif" << nl; os << "#endif" << nl; source.Indent(); for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; bool is_sequency = !(field->get_be_type()->IsPrimitiveType() || field->get_be_type()->IsEnumeratedType()); relativeName = BE_Globals::RelativeScope (scopedName, field->StructMemberTypeName ()); // const get accessor os << tab << (is_sequency ? "const " : "") << relativeName << (is_sequency ? "& " : " ") << field->get_local_name() << "() const { return this->" << field->get_local_name() << "_; }" << nl; // reference get accessor os << tab << relativeName << "& " << field->get_local_name() << "() { return this->" << field->get_local_name() << "_; }" << nl; // const set accessor os << tab << "void " << field->get_local_name() << (is_sequency ? "(const " : "(") << relativeName << (is_sequency ? "&" : "") << " _val_) { this->" << field->get_local_name() << "_ = _val_; }" << nl; source.Outdent(); if (!(field->get_be_type()->IsPrimitiveType() && !field->get_be_type()->IsEnumeratedType())) { os << "#ifdef OSPL_DDS_CXX11" << nl; source.Indent(); // C++ 11 move assignement op os << tab << "void " << field->get_local_name() << "(" << relativeName << "&& _val_) { this->" << field->get_local_name() << "_ = _val_; }" << nl; source.Outdent(); os << "#endif" << nl; } source.Indent(); } } if (BE_Globals::gen_equality) { os << tab << "bool operator==(const " << LocalName() << "& _other) const" << nl << tab << "{" << nl << tab << tab << "return "; DDS_StdString relName; for(mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; relName = BE_Globals::RelativeScope (scopedName, field->get_local_name()); TList<be_field *>::iterator final_field = m_fields.end(); --final_field; if(mit != m_fields.begin()) os << tab << tab; os << relName << (BE_Globals::isocpp_new_types ? "_" : "") << " == _other." << relName << (BE_Globals::isocpp_new_types ? "_" : "") << (mit != final_field ? " &&" : ";") << nl; } os << tab << "}" << nl; os << tab << "bool operator!=(const " << LocalName() << "& other) const" << nl << tab << "{" << nl << tab << tab << "return !(*this == other);" << nl << tab << "}" << nl; } // member declarations for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; relativeName = BE_Globals::RelativeScope (scopedName, field->StructMemberTypeName ()); os << tab << relativeName << " " << field->get_local_name() << (BE_Globals::isocpp_new_types ? "_" : "") << ";" << nl; } source.Outdent(); source.Outdent(); source.Stream() << tab << "};" << nl << nl; g_cppScopeStack.Pop(); if (BE_Globals::isocpp_test_methods) { //Get base filename and append _testmethod.h DDS_StdString BaseFilename; BaseFilename = StripExtension(source.Filename()); BaseFilename += "_testmethod.h"; //Open or append to file be_Source testsource; ostream & ts = testsource.Stream(); if(!testsource.Open(BaseFilename)) cerr << "Cannot open: " << BaseFilename << endl; testsource.Indent(); ts << "namespace {" << nl << "template <>" << nl << "::std::vector< ::" << ScopedName() << " > generate_test_values< ::" << ScopedName() << " >()" << nl << "{" << nl; ts << tab << "::std::vector< ::" << ScopedName() << " > values;" << nl << tab << "::" << ScopedName() << " next;" << nl << tab << "::std::size_t biggest = 0;" << nl; for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; relativeName = field->StructMemberTypeName (); ts << tab <<"::std::vector< " << field->StructMemberTypeName() << " > " << field->get_local_name() << "_ = generate_test_values< " << field->StructMemberTypeName() << " >();" << nl; ts << tab << "if(" << field->get_local_name() << "_.size() > biggest)" << nl << tab << tab << "biggest = " << field->get_local_name() << "_.size();" << nl; } ts << tab << "for(::std::size_t i = 0; i < biggest; ++i)" << nl << tab << "{" << nl; for (mit = m_fields.begin(); mit != m_fields.end(); mit++) { field = *mit; relativeName = BE_Globals::RelativeScope(scopedName, field->StructMemberTypeName ()); ts << tab << tab << "next." << field->get_local_name() << "_ = " << field->get_local_name() << "_[i < " << field->get_local_name() << "_.size()? i : " << field->get_local_name() << "_.size() -1];" << nl; } ts << tab << tab << "values.push_back(next);" << nl << tab << "}" << nl << tab << "return values;" << nl; ts << "} }" << nl << nl; testsource.Outdent(); testsource.Close(); } GenerateAuxTypes (source); be_root::GenerateDependants(source, SequenceMemberTypeName(), EnclosingScope()); } }
//--------------------------------------------------------------------------- bool File_DcpCpl::FileHeader_Begin() { XMLDocument document; if (!FileHeader_Begin_XML(document)) return false; XMLElement* Root=document.FirstChildElement(); const char *NameSpace; if (!Root || strcmp(LocalName(Root, NameSpace), "CompositionPlaylist")) { Reject("DcpCpl"); return false; } bool IsDcp=false, IsImf=false; if (!strcmp(NameSpace, "http://www.digicine.com/PROTO-ASDCP-CPL-20040511#") || !strcmp(NameSpace, "http://www.smpte-ra.org/schemas/429-7/2006/CPL")) { IsDcp=true; } else if (IsSmpteSt2067_3(NameSpace)) { IsImf=true; } else { Reject("DcpCpl"); return false; } Accept("DcpCpl"); Fill(Stream_General, 0, General_Format, IsDcp?"DCP CPL":"IMF CPL"); Config->File_ID_OnlyRoot_Set(false); ReferenceFiles=new File__ReferenceFilesHelper(this, Config); //Parsing main elements for (XMLElement* CompositionPlaylist_Item=Root->FirstChildElement(); CompositionPlaylist_Item; CompositionPlaylist_Item=CompositionPlaylist_Item->NextSiblingElement()) { //CompositionTimecode if (IsImf && MatchQName(CompositionPlaylist_Item, "CompositionTimecode", NameSpace)) { sequence* Sequence=new sequence; Sequence->StreamKind=Stream_Other; Sequence->Infos["Type"]=__T("Time code"); Sequence->Infos["Format"]=__T("CPL TC"); Sequence->Infos["TimeCode_Striped"]=__T("Yes"); bool IsDropFrame=false; for (XMLElement* CompositionTimecode_Item=CompositionPlaylist_Item->FirstChildElement(); CompositionTimecode_Item; CompositionTimecode_Item=CompositionTimecode_Item->NextSiblingElement()) { const char* Text=CompositionTimecode_Item->GetText(); if (!Text) continue; const char *CtItemNs, *CtItemName = LocalName(CompositionTimecode_Item, CtItemNs); if (!CtItemNs || strcmp(CtItemNs, NameSpace)) continue; // item has wrong namespace //TimecodeDropFrame if (!strcmp(CtItemName, "TimecodeDropFrame")) { if (strcmp(Text, "") && strcmp(Text, "0")) IsDropFrame=true; } //TimecodeRate if (!strcmp(CtItemName, "TimecodeRate")) Sequence->Infos["FrameRate"].From_UTF8(Text); //TimecodeStartAddress if (!strcmp(CtItemName, "TimecodeStartAddress")) Sequence->Infos["TimeCode_FirstFrame"].From_UTF8(Text); } //Adaptation if (IsDropFrame) { std::map<string, Ztring>::iterator Info=Sequence->Infos.find("TimeCode_FirstFrame"); if (Info!=Sequence->Infos.end() && Info->second.size()>=11 && Info->second[8]!=__T(';')) Info->second[8]=__T(';'); } Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); Stream_Prepare(Stream_Other); Fill(Stream_Other, StreamPos_Last, Other_ID, Sequence->StreamID); for (std::map<string, Ztring>::iterator Info=Sequence->Infos.begin(); Info!=Sequence->Infos.end(); ++Info) Fill(Stream_Other, StreamPos_Last, Info->first.c_str(), Info->second); } //ReelList / SegmentList if (MatchQName(CompositionPlaylist_Item, IsDcp?"ReelList":"SegmentList", NameSpace)) { for (XMLElement* ReelList_Item=CompositionPlaylist_Item->FirstChildElement(); ReelList_Item; ReelList_Item=ReelList_Item->NextSiblingElement()) { //Reel if (MatchQName(ReelList_Item, IsDcp?"Reel":"Segment", NameSpace)) { for (XMLElement* Reel_Item=ReelList_Item->FirstChildElement(); Reel_Item; Reel_Item=Reel_Item->NextSiblingElement()) { //AssetList if (MatchQName(Reel_Item, IsDcp?"AssetList":"SequenceList", NameSpace)) { for (XMLElement* AssetList_Item=Reel_Item->FirstChildElement(); AssetList_Item; AssetList_Item=AssetList_Item->NextSiblingElement()) { const char *AlItemNs, *AlItemName = LocalName(AssetList_Item, AlItemNs); if (!AlItemNs) continue; //File //if ((IsDcp && (!strcmp(AssetList_Item->Value(), "MainPicture") || !strcmp(AssetList_Item->Value(), "MainSound"))) // || (IsImf && (!strcmp(AssetList_Item->Value(), "cc:MainImageSequence") || !strcmp(AssetList_Item->Value(), "cc:MainImage")))) if (strcmp(AlItemName, "MarkerSequence")) //Ignoring MarkerSequence for the moment. TODO: check what to do with MarkerSequence { sequence* Sequence=new sequence; Ztring Asset_Id; if (IsDcp && !strcmp(NameSpace, AlItemNs)) { if (!strcmp(AlItemName, "MainPicture")) Sequence->StreamKind=Stream_Video; else if (!strcmp(AlItemName, "MainSound")) Sequence->StreamKind=Stream_Audio; } else if (IsImf && IsSmpteSt2067_2(AlItemNs)) { if (!strcmp(AlItemName, "MainImageSequence")) Sequence->StreamKind=Stream_Video; else if (!strcmp(AlItemName, "MainAudioSequence")) Sequence->StreamKind=Stream_Audio; } for (XMLElement* File_Item=AssetList_Item->FirstChildElement(); File_Item; File_Item=File_Item->NextSiblingElement()) { //Id if (MatchQName(File_Item, "Id", NameSpace) && Asset_Id.empty()) Asset_Id.From_UTF8(File_Item->GetText()); //ResourceList if (IsImf && MatchQName(File_Item, "ResourceList", NameSpace)) { for (XMLElement* ResourceList_Item=File_Item->FirstChildElement(); ResourceList_Item; ResourceList_Item=ResourceList_Item->NextSiblingElement()) { //Resource if (MatchQName(ResourceList_Item, "Resource", NameSpace)) { Ztring Resource_Id; resource* Resource=new resource; for (XMLElement* Resource_Item=ResourceList_Item->FirstChildElement(); Resource_Item; Resource_Item=Resource_Item->NextSiblingElement()) { const char* ResText=Resource_Item->GetText(); if (!ResText) continue; const char *ResItemNs, *ResItemName = LocalName(Resource_Item, ResItemNs); if (!ResItemNs || strcmp(ResItemNs, NameSpace)) continue; // item has wrong namespace //EditRate if (!strcmp(ResItemName, "EditRate")) { Resource->EditRate=atof(ResText); const char* EditRate2=strchr(ResText, ' '); if (EditRate2!=NULL) { float64 EditRate2f=atof(EditRate2); if (EditRate2f) Resource->EditRate/=EditRate2f; } } //EntryPoint if (!strcmp(ResItemName, "EntryPoint")) { Resource->IgnoreEditsBefore=atoi(ResText); if (Resource->IgnoreEditsAfter!=(int64u)-1) Resource->IgnoreEditsAfter+=Resource->IgnoreEditsBefore; } //Id if (!strcmp(ResItemName, "Id") && Resource_Id.empty()) Resource_Id.From_UTF8(ResText); //SourceDuration if (!strcmp(ResItemName, "SourceDuration")) Resource->IgnoreEditsAfter=Resource->IgnoreEditsBefore+atoi(ResText); //TrackFileId if (!strcmp(ResItemName, "TrackFileId")) Resource->FileNames.push_back(Ztring().From_UTF8(ResText)); } if (Resource->FileNames.empty()) Resource->FileNames.push_back(Resource_Id); Sequence->AddResource(Resource); } } } } if (Sequence->Resources.empty()) { resource* Resource=new resource; Resource->FileNames.push_back(Asset_Id); Sequence->AddResource(Resource); } Sequence->StreamID=ReferenceFiles->Sequences_Size()+1; ReferenceFiles->AddSequence(Sequence); } } } } } } } } Element_Offset=File_Size; //Getting files names FileName Directory(File_Name); Ztring DirPath = Directory.Path_Get(); if (!DirPath.empty()) DirPath += PathSeparator; Ztring Assetmap_FileName=DirPath+__T("ASSETMAP.xml"); bool IsOk=false; if (File::Exists(Assetmap_FileName)) IsOk=true; else { Assetmap_FileName.resize(Assetmap_FileName.size()-4); //Old fashion, without ".xml" if (File::Exists(Assetmap_FileName)) IsOk=true; } if (IsOk) { MediaInfo_Internal MI; MI.Option(__T("File_KeepInfo"), __T("1")); Ztring ParseSpeed_Save=MI.Option(__T("ParseSpeed_Get"), __T("")); Ztring Demux_Save=MI.Option(__T("Demux_Get"), __T("")); MI.Option(__T("ParseSpeed"), __T("0")); MI.Option(__T("Demux"), Ztring()); MI.Option(__T("File_IsReferenced"), __T("1")); size_t MiOpenResult=MI.Open(Assetmap_FileName); MI.Option(__T("ParseSpeed"), ParseSpeed_Save); //This is a global value, need to reset it. TODO: local value MI.Option(__T("Demux"), Demux_Save); //This is a global value, need to reset it. TODO: local value if (MiOpenResult && (MI.Get(Stream_General, 0, General_Format)==__T("DCP AM") || MI.Get(Stream_General, 0, General_Format)==__T("IMF AM"))) { MergeFromAm(((File_DcpAm*)MI.Info)->Streams); } } ReferenceFiles->FilesForStorage=true; //All should be OK... return true; }
DDS_StdString be_operation::ReplySignature (ExceptionStatus excStat, OP_SignatureType sigType) { UTL_ScopeActiveIterator *i = new UTL_ScopeActiveIterator (this, IK_decls); ostringstream os; DDS_StdString ret = ""; AST_Decl *d; DDS_StdString op_suffix = ""; // VOID RETURN if (sigType == OP_Declaration || sigType == OP_Implementation) { os << "void "; } if (excStat == OP_NoException) { // no suffix } else if (excStat == OP_Exception) { op_suffix = "_exc"; } else { op_suffix = "_retry"; } // OP NAME os << "handle_" << LocalName () << op_suffix; // GENERATE PARAMETER LIST os << "("; os << "DDS::Codec::RequestId rid, "; os << "DDS::Stub_ptr stub"; if (excStat == OP_NoException) { // GENERATE RETURN if (HasReturn ()) { assert (returnType); os << ", "; if (returnType->IsFixedLength () && returnType->IsStructuredType ()) { os << returnType->MakeSignature (VT_InOutParam, ""); } else { os << returnType->MakeSignature (VT_Return, ""); } } for (; !(i->is_done ()); i->next ()) { be_argument *arg; d = i->item (); arg = (be_argument *) d->narrow ((long) &be_argument::type_id); if (arg) { if (arg->is_out_arg () || arg->is_inout_arg ()) { be_Type *argtype = be_Type::_narrow (arg->field_type ()); os << ", "; if (sigType != OP_Invoke) { if (argtype->IsFixedLength () && argtype->IsStructuredType ()) { os << argtype->MakeSignature (VT_InOutParam, ""); } else { os << argtype->MakeSignature (VT_Return, ""); } } os << " " << *arg->local_name (); } } } delete i; os << ")" << ends; } else if (excStat == OP_Exception) { os << ", DDS::Exception & exception)" << ends; } else // (excStat == OP_Retry) { os << ")" << ends; } ret = os.str ().c_str(); return ret; }