当前位置: 首页>>代码示例>>C++>>正文


C++ Struct::addMember方法代码示例

本文整理汇总了C++中Struct::addMember方法的典型用法代码示例。如果您正苦于以下问题:C++ Struct::addMember方法的具体用法?C++ Struct::addMember怎么用?C++ Struct::addMember使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Struct的用法示例。


在下文中一共展示了Struct::addMember方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getCapabilities

void Dispatcher::getCapabilities (Struct &str) const
{
  // parent::getCapabilities (str);  just in case..
  str.addMember("specUrl",
               RpcString("http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php"));
  str.addMember("specVersion", Integer(20010516));
}
开发者ID:MrMC,项目名称:ulxmlrpcpp,代码行数:7,代码来源:ulxr_dispatcher.cpp

示例2: ParameterException

MethodResponse
  Dispatcher::system_getCapabilities(const MethodCall &calldata,
                                     const Dispatcher *disp)
{
  if (calldata.numParams() > 1)
    throw ParameterException(InvalidMethodParameterError,
                             "No parameters allowed for \"system.listMethods\"");

  Struct sysCap;
  disp->getCapabilities(sysCap);

  Struct opStr;
  opStr.addMember("faults_interop", sysCap);
  return MethodResponse (opStr);
}
开发者ID:MrMC,项目名称:ulxmlrpcpp,代码行数:15,代码来源:ulxr_dispatcher.cpp

示例3: FormLinkageStructParse


//.........这里部分代码省略.........
    if ((lst->size() == 2) || ((lst->size() == 3) && (next_index == 3))) {
        return true;
    }

    /* Parse the struct members. */

    Node *members_node = (*lst)[next_index];

    if (!members_node->is_list) {
        Error *e = new Error(IncorrectArgType, members_node,
                             "struct", "a list", "1", "an atom");
        ctx->er->addError(e);
        return false;
    }

    std::vector<Node *> *members = members_node->list;

    std::vector<Variable *> members_internal;
    for (std::vector<Node *>::iterator b = members->begin(),
                                       e = members->end();
            b != e;
            ++b) {
        Variable *var = new Variable();
        var->type = NULL;

        FormParameterParse(units, var, (*b), true, true, false);
        if (!var->type) {
            Error *e = new Error(InvalidType, (*b));
            ctx->er->addError(e);
            delete var;
            return false;
        }

        if (var->type->base_type == BaseType::Void) {
            Error *e = new Error(TypeNotAllowedInStruct, (*b), "void");
            ctx->er->addError(e);
            delete var;
            return false;
        }

        members_internal.push_back(var);
    }

    /* Convert the members to LLVM types and add the struct to the
     * module. */

    std::vector<llvm::Type*> members_llvm;
    for (std::vector<Variable *>::iterator b = members_internal.begin(),
                                           e = members_internal.end();
            b != e;
            ++b) {
        llvm::Type *type = ctx->toLLVMType((*b)->type, NULL, false);
        if (!type) {
            return false;
        }
        members_llvm.push_back(type);
    }

    std::string symbol;
    ctx->ns()->nameToSymbol(name, &symbol);

    /* If the struct does not already exist in context, then there has
     * been some strange error. */
    Struct *st = ctx->getStruct(name);
    if (!st) {
        Error *e = new Error(UnableToParseForm, top);
        ctx->er->addError(e);
        return false;
    }

    /* If it does exist, but is not opaque, then it cannot be
     * redefined. */
    if (!st->is_opaque) {
        Error *e = new Error(RedeclarationOfStruct, top, name);
        ctx->er->addError(e);
        return false;
    }

    /* Get the struct's type, cast it to a  StructType, and add the
     * members. */
    llvm::StructType *opaque_struct_type =
        llvm::cast<llvm::StructType>(st->type);
    opaque_struct_type->setBody(llvm::ArrayRef<llvm::Type*>(members_llvm));
    st->is_opaque = false;

    st->internal_name.clear();
    st->internal_name.append(symbol.c_str());

    st->linkage = linkage;

    for (std::vector<Variable *>::iterator b = members_internal.begin(),
                                           e = members_internal.end();
            b != e;
            ++b) {
        st->addMember((*b)->name.c_str(), (*b)->type);
        delete (*b);
    }

    return true;
}
开发者ID:BitPuffin,项目名称:dale,代码行数:101,代码来源:Struct.cpp


注:本文中的Struct::addMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。