Exemplo n.º 1
0
void XMLWriter::putChildQObjectItem(QString name, QObject *item, QDomElement *parentNode)
{   
    QDomElement itemNode = m_doc->createElement(name);
    itemNode.setAttribute("ClassName",extractClassName(item));
    itemNode.setAttribute("Type","Object");
    if (parentNode) parentNode->appendChild(itemNode);
    saveProperties(item,&itemNode);
}
Exemplo n.º 2
0
QDomElement XMLWriter::putQObjectItem(QString name, QObject *item)
{
    Q_UNUSED(name)
    QDomElement itemNode = m_doc->createElement("object");
    itemNode.setAttribute("ClassName",extractClassName(item));
    itemNode.setAttribute("Type","Object");
    saveProperties(item,&itemNode);
    return itemNode;
}
    void AutoReg::registerTestCase( ITestCase* testCase,
                                    char const* classOrQualifiedMethodName,
                                    NameAndDesc const& nameAndDesc,
                                    SourceLineInfo const& lineInfo ) {

        getMutableRegistryHub().registerTest
            ( makeTestCase( testCase,
                            extractClassName( classOrQualifiedMethodName ),
                            nameAndDesc.name,
                            nameAndDesc.description,
                            lineInfo ) );
    }
 AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept {
     try {
         getMutableRegistryHub()
                 .registerTest(
                     makeTestCase(
                         invoker,
                         extractClassName( classOrMethod ),
                         nameAndTags.name,
                         nameAndTags.tags,
                         lineInfo));
     } catch (...) {
         // Do not throw when constructing global objects, instead register the exception to be processed later
         getMutableRegistryHub().registerStartupException();
     }
 }
Exemplo n.º 5
0
void RpcGenerator::generateDispatcherCc(google::protobuf::compiler::GeneratorContext *generator_context,
                        const google::protobuf::ServiceDescriptor *descriptor) const
{
  string header =  descriptor->name() + "_Dispatcher.pb.h";
  string cpp = descriptor->name() + "_Dispatcher.pb.cc";

  io::ZeroCopyOutputStream *output = generator_context->Open(cpp.c_str());
  io::Printer printer(output, '$');

  printer.Print("#include \"");
  printer.Print(header.c_str());
  printer.Print("\"\n\n");
  printer.Print("#include <iostream>\n");
  printer.Print("#include <memory>\n");
  printer.Print("#include <google/protobuf/stubs/common.h>\n");
  printer.Print("using google::protobuf::uint64;\n");

  // Add include for external serializers
  set<string> externalTypes = this->extractExternalTypes(descriptor);

  for(set<string>::const_iterator it = externalTypes.begin();
      it != externalTypes.end(); ++it)
  {
    string cls = extractClassName(*it);
    transform(cls.begin(), cls.end(), cls.begin(),
      ::tolower);

    printer.Print("#include <$cls$serializer.h>\n", "cls", cls);
  }

  // Add constructor implemention
  printer.Print("$service$_Dispatcher::$service$_Dispatcher($service$ *service)\n",
     "service", descriptor->full_name());

  printer.Print(" : ProtoCall::Runtime::ServiceDispatcher(service)\n{\n\n}\n\n");

  printer.Print("void $service$_Dispatcher::$dispatchSignature$\n{\n",
      "service", descriptor->full_name(), "dispatchSignature",
      dispatchSignature);

  this->generateDispatchMethodBody(descriptor, printer);

  printer.Print("}\n");

  this->generateRelyMethod(descriptor, printer);
  this->generateImplementsMethod(descriptor, printer);
}
Exemplo n.º 6
0
void RpcGenerator::generateResponseHandlerCpp(google::protobuf::compiler::GeneratorContext *generator_context,
    const google::protobuf::ServiceDescriptor *descriptor) const
{
  string cls = descriptor->name() + "_Handler";
  string cpp = cls + ".pb.cc";

  io::ZeroCopyOutputStream *output =
      generator_context->Open(cpp.c_str());
  io::Printer printer(output, '$');

  printer.Print("// Generated by the RPC compiler.  DO NOT EDIT!\n\n");

  printer.Print("#include \"$class$.pb.h\"\n\n", "class", cls);

  // Add includes for external deserializers
  set<string> externalTypes = this->extractExternalTypes(descriptor);

  for(set<string>::const_iterator it = externalTypes.begin();
      it != externalTypes.end(); ++it)
  {
    string cls = extractClassName(*it);
    transform(cls.begin(), cls.end(), cls.begin(),
      ::tolower);

    printer.Print("#include <$cls$deserializer.h>\n", "cls", cls);
  }

  // Constructor
  printer.Print("$class$::$class$() \n{\n}\n", "class", cls);

  printer.Print("void $class$::$signature$ {\n", "class", cls, "signature",
      handleSignature);

  printer.Indent();
  printer.Print("switch(methodId) {\n");
  printer.Indent();

  for(int j=0; j<descriptor->method_count(); j++) {
    const MethodDescriptor *method = descriptor->method(j);

    string methodName = method->full_name();
    int methodId = RpcPlugin::generateExtensionNumber(methodName);
    string inputTypeName = method->input_type()->name();
    string outputTypeName = method->output_type()->name();

    if (isVoidType(outputTypeName))
      continue;

    ostringstream methodIdStr;
    methodIdStr << methodId;
    printer.Print("case $methodId$ : {\n", "methodId", methodIdStr.str());
    printer.Indent();
    printer.Print("// $methodName$\n", "methodName",  methodName);

    printer.Print("targetResponse->CopyFrom(const_cast<const google::protobuf::Message&>(*incomingResponse));\n");

    printer.Print("::google::protobuf::Message *mutableResponse "
        "= const_cast< google::protobuf::Message *>(targetResponse);\n");
    printer.Print("$responseType$ *responseType ="
        "static_cast<$responseType$ *>(mutableResponse);\n",
        "responseType", outputTypeName);
    printer.Print("responseType->setErrorCode(errorCode);\n");
    printer.Print("responseType->setErrorString(errorString);\n");


    const Descriptor *responseType = method->output_type();
    this->generateReceiveVtkBlock("targetResponse", "channel", responseType,
        printer);

    // Receive any external objects
    this->generateReceiveExternalBlock("targetResponse", "channel", responseType,
            printer);

    // Now call the users callback
    printer.Print("callback->Run();\n");

    printer.Outdent();
    printer.Print("break;\n");
    printer.Print("}\n");
  }
  printer.Outdent();
  printer.Print("}\n");
  printer.Outdent();
  printer.Print("}\n");
}