本文整理汇总了C++中TypeManager类的典型用法代码示例。如果您正苦于以下问题:C++ TypeManager类的具体用法?C++ TypeManager怎么用?C++ TypeManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeManager类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: check_compatible
PyObject*
check_compatible(PyObject* self, PyObject* args)
{
PyObject *tmcap;
int from, to;
if (!PyArg_ParseTuple(args, "Oii", &tmcap, &from, &to)) {
return NULL;
}
TypeManager *tm = unwrap_TypeManager(tmcap);
if(!tm) {
BAD_TM_ARGUMENT;
return NULL;
}
switch(tm->isCompatible(Type(from), Type(to))){
case TCC_EXACT:
return PyString_FromString("exact");
case TCC_PROMOTE:
return PyString_FromString("promote");
case TCC_CONVERT_SAFE:
return PyString_FromString("safe");
case TCC_CONVERT_UNSAFE:
return PyString_FromString("unsafe");
default:
Py_RETURN_NONE;
}
}
开发者ID:Alexhuszagh,项目名称:numba,代码行数:28,代码来源:_typeconv.cpp
示例2: getReturnType
xqtref_t fn_remove::getReturnType(const fo_expr* caller) const
{
TypeManager* tm = caller->get_type_manager();
return tm->create_type_x_quant(*caller->get_arg(0)->get_return_type(),
SequenceType::QUANT_QUESTION);
}
开发者ID:alyst,项目名称:zorba,代码行数:7,代码来源:func_sequences_impl.cpp
示例3: ZORBA_ASSERT
SequenceType SequenceType::createSchemaAttributeType(
const StaticContext_t& sctx,
const String& uri,
const String& localName,
Quantifier quant)
{
ZORBA_ASSERT(sctx != NULL);
static_context* sctx2 = Unmarshaller::getInternalStaticContext(sctx);
TypeManager* tm = sctx2->get_typemanager();
zstring& ns = Unmarshaller::getInternalString(uri);
zstring& local = Unmarshaller::getInternalString(localName);
store::Item_t qname;
ZORBA_ASSERT(!local.empty());
GENV_ITEMFACTORY->createQName(qname, ns, "", local);
try
{
xqtref_t res = tm->create_schema_attribute_type(qname, quant, QueryLoc::null);
return Unmarshaller::createSequenceType(res.getp());
}
catch (...)
{
return Unmarshaller::createSequenceType(NULL);
}
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:31,代码来源:sequencetype.cpp
示例4: serialize
std::string Serializer::serialize(const TypeManager &typeManager)
{
rapidjson::Document document;
{
rapidjson::Value moduleTypesValue;
moduleTypesValue.SetArray();
for(unsigned int i=0; i<typeManager.numUserTypes(); ++i){
rapidjson::Value moduleTypeValue;
jsonifyModuleType(*typeManager.getUserType(i), moduleTypeValue, document);
moduleTypesValue.PushBack(moduleTypeValue, document.GetAllocator());
}
document.SetObject();
document.AddMember("moduleTypes", moduleTypesValue, document.GetAllocator());
}
//TODO remove this line when rapidjson have fixed their bug (radix separator is decided by locale, instead of set to .)
setlocale(LC_NUMERIC, "POSIX");
//make an std::string from the document
StdStringStreamWrapper streamWrapper;
rapidjson::PrettyWriter<StdStringStreamWrapper> writer(streamWrapper);
document.Accept(writer);
return streamWrapper.stream.str();
}
开发者ID:acelster,项目名称:noise-terrain-gen,代码行数:26,代码来源:serializer.cpp
示例5: createAtomicOrUnionType
SequenceType SequenceType::createAtomicOrUnionType(
const StaticContext_t& sctx,
const String& uri,
const String& localName,
Quantifier quant)
{
TypeManager* tm;
if (sctx == NULL)
{
tm = &GENV_TYPESYSTEM;
}
else
{
static_context* sctx2 = Unmarshaller::getInternalStaticContext(sctx);
tm = sctx2->get_typemanager();
}
zstring& ns = Unmarshaller::getInternalString(uri);
zstring& local = Unmarshaller::getInternalString(localName);
store::Item_t qname;
GENV_ITEMFACTORY->createQName(qname, ns, "", local);
xqtref_t type = tm->create_named_type(qname, quant, QueryLoc::null, false);
if (type->isGenAtomicAny())
return Unmarshaller::createSequenceType(type.getp());
return Unmarshaller::createSequenceType(NULL);
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:31,代码来源:sequencetype.cpp
示例6: set_compatible
PyObject*
set_compatible(PyObject* self, PyObject* args)
{
PyObject *tmcap;
int from, to, by;
if (!PyArg_ParseTuple(args, "Oiii", &tmcap, &from, &to, &by)) {
return NULL;
}
TypeManager *tm = unwrap_TypeManager(tmcap);
if (!tm) {
BAD_TM_ARGUMENT;
return NULL;
}
TypeCompatibleCode tcc;
switch (by) {
case 'p': // promote
tcc = TCC_PROMOTE;
break;
case 's': // safe convert
tcc = TCC_CONVERT_SAFE;
break;
case 'u': // unsafe convert
tcc = TCC_CONVERT_UNSAFE;
break;
default:
PyErr_SetString(PyExc_ValueError, "Unknown TCC");
return NULL;
}
tm->addCompatibility(Type(from), Type(to), tcc);
Py_RETURN_NONE;
}
开发者ID:Alexhuszagh,项目名称:numba,代码行数:33,代码来源:_typeconv.cpp
示例7: createJSONArrayType
SequenceType SequenceType::createJSONArrayType(Quantifier q)
{
TypeManager* tm = &GENV_TYPESYSTEM;
xqtref_t res = tm->create_json_type(store::StoreConsts::jsonArray, q);
return Unmarshaller::createSequenceType(res.getp());
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:8,代码来源:sequencetype.cpp
示例8: select_overload
PyObject*
select_overload(PyObject* self, PyObject* args)
{
PyObject *tmcap, *sigtup, *ovsigstup;
int allow_unsafe;
if (!PyArg_ParseTuple(args, "OOOi", &tmcap, &sigtup, &ovsigstup,
&allow_unsafe)) {
return NULL;
}
TypeManager *tm = unwrap_TypeManager(tmcap);
if (!tm) {
BAD_TM_ARGUMENT;
}
Py_ssize_t sigsz = PySequence_Size(sigtup);
Py_ssize_t ovsz = PySequence_Size(ovsigstup);
Type *sig = new Type[sigsz];
Type *ovsigs = new Type[ovsz * sigsz];
for (int i = 0; i < sigsz; ++i) {
sig[i] = Type(PyNumber_AsSsize_t(PySequence_Fast_GET_ITEM(sigtup,
i), NULL));
}
for (int i = 0; i < ovsz; ++i) {
PyObject *cursig = PySequence_Fast_GET_ITEM(ovsigstup, i);
for (int j = 0; j < sigsz; ++j) {
long tid = PyNumber_AsSsize_t(PySequence_Fast_GET_ITEM(cursig,
j), NULL);
ovsigs[i * sigsz + j] = Type(tid);
}
}
int selected = -42;
int matches = tm->selectOverload(sig, ovsigs, selected, sigsz, ovsz,
(bool) allow_unsafe);
delete [] sig;
delete [] ovsigs;
if (matches > 1) {
PyErr_SetString(PyExc_TypeError, "Ambigous overloading");
return NULL;
} else if (matches == 0) {
PyErr_SetString(PyExc_TypeError, "No compatible overload");
return NULL;
}
return PyLong_FromLong(selected);
}
开发者ID:Alexhuszagh,项目名称:numba,代码行数:53,代码来源:_typeconv.cpp
示例9: createElementType
SequenceType SequenceType::createElementType(
const StaticContext_t& sctx,
const String& nodeUri,
const String& nodeLocalName,
const String& typeUri,
const String& typeLocalName,
bool nillable,
Quantifier quant)
{
TypeManager* tm;
if (sctx == NULL)
{
tm = &GENV_TYPESYSTEM;
}
else
{
static_context* sctx2 = Unmarshaller::getInternalStaticContext(sctx);
tm = sctx2->get_typemanager();
}
zstring& nodeNS = Unmarshaller::getInternalString(nodeUri);
zstring& nodeLocal = Unmarshaller::getInternalString(nodeLocalName);
store::Item_t nodeQName;
if (!nodeLocal.empty())
GENV_ITEMFACTORY->createQName(nodeQName, nodeNS, "", nodeLocal);
zstring& typeNS = Unmarshaller::getInternalString(typeUri);
zstring& typeLocal = Unmarshaller::getInternalString(typeLocalName);
store::Item_t typeQName;
xqtref_t contentType;
if (!typeLocal.empty())
{
GENV_ITEMFACTORY->createQName(typeQName, typeNS, "", typeLocal);
contentType = tm->create_named_type(typeQName, QUANT_ONE, QueryLoc::null, false);
if (contentType == NULL)
return Unmarshaller::createSequenceType(NULL);
}
xqtref_t res = tm->create_node_type(store::StoreConsts::elementNode,
nodeQName,
contentType,
quant,
nillable,
false);
return Unmarshaller::createSequenceType(res.getp());
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:52,代码来源:sequencetype.cpp
示例10: createNamespaceType
SequenceType SequenceType::createNamespaceType(Quantifier quant)
{
TypeManager* tm = &GENV_TYPESYSTEM;
xqtref_t res = tm->create_node_type(store::StoreConsts::namespaceNode,
NULL,
NULL,
quant,
false,
false);
return Unmarshaller::createSequenceType(res.getp());
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:13,代码来源:sequencetype.cpp
示例11: validateSimpleContent
void SchemaValidatorImpl::validateSimpleContent(
store::Item *typeQName,
zstring newValue,
std::vector<store::Item_t>& resultList)
{
TypeManager* typeManager = theSctx->get_typemanager();
Schema* schema = typeManager->getSchema();
ZORBA_ASSERT( schema );
const xqtref_t& targetType =
schema->createXQTypeFromTypeName(typeManager, typeQName);
schema->parseUserSimpleTypes(newValue, targetType, resultList, QueryLoc::null,
false);
}
开发者ID:alyst,项目名称:zorba,代码行数:15,代码来源:revalidateUtils.cpp
示例12: getReturnType
xqtref_t fn_data::getReturnType(const fo_expr* caller) const
{
const QueryLoc& loc = caller->get_loc();
TypeManager* tm = caller->get_type_manager();
RootTypeManager& RTM = GENV_TYPESYSTEM;
xqtref_t argType = caller->get_arg(0)->get_return_type();
if (TypeOps::is_subtype(tm, *argType, *RTM.ANY_ATOMIC_TYPE_STAR, loc))
return argType; // includes () case
SequenceType::Quantifier q = argType->get_quantifier();
if (argType->type_kind() == XQType::NODE_TYPE_KIND)
{
const NodeXQType& nType = static_cast<const NodeXQType&>(*argType);
store::StoreConsts::NodeKind nodeKind = nType.get_node_kind();
if (nodeKind == store::StoreConsts::piNode ||
nodeKind == store::StoreConsts::commentNode)
{
return tm->create_builtin_atomic_type(store::XS_STRING, q);
}
if (nodeKind == store::StoreConsts::documentNode ||
nodeKind == store::StoreConsts::textNode)
{
return tm->create_builtin_atomic_type(store::XS_UNTYPED_ATOMIC, q);
}
xqtref_t cType = nType.get_content_type();
if (cType != NULL)
{
if (cType->isList())
{
const XQType* itemType = static_cast<const UserDefinedXQType*>(cType.getp())->
getListItemType();
return tm->create_type(*itemType, SequenceType::QUANT_STAR);
}
else if (TypeOps::is_equal(tm, *cType, *RTM.UNTYPED_ATOMIC_TYPE_ONE))
{
return tm->create_builtin_atomic_type(store::XS_UNTYPED_ATOMIC, q);
}
else if (TypeOps::is_equal(tm, *cType, *RTM.UNTYPED_TYPE))
{
return tm->create_builtin_atomic_type(store::XS_UNTYPED_ATOMIC, q);
}
else if (TypeOps::is_subtype(tm, *cType, *RTM.ANY_ATOMIC_TYPE_STAR, loc))
{
return tm->create_type(*cType, q);
}
}
}
return RTM.ANY_ATOMIC_TYPE_STAR;
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:58,代码来源:func_accessors_impl.cpp
示例13: isPossibleSimpleContentRevalidation
bool SchemaValidatorImpl::isPossibleSimpleContentRevalidation(
store::Item* typeQName)
{
TypeManager* typeManager = theSctx->get_typemanager();
//StaticContextConsts::validation_mode_t mode = theSctx->validation_mode();
Schema* schema = typeManager->getSchema();
if ( !schema )
{
// no schema available no change to pul
return false;
}
xqtref_t schemaType = schema->createXQTypeFromTypeName(typeManager, typeQName);
if ( schemaType.getp() )
return isPossibleSimpleContentRevalImpl(schemaType);
else
return false;
}
开发者ID:alyst,项目名称:zorba,代码行数:19,代码来源:revalidateUtils.cpp
示例14: createDocumentType
SequenceType SequenceType::createDocumentType(
const SequenceType& contentType,
Quantifier quant)
{
const XQType* contentType2 = Unmarshaller::getInternalType(contentType);
TypeManager* tm = (contentType2 == NULL ?
&GENV_TYPESYSTEM :
contentType2->get_manager());
store::Item_t qname;
xqtref_t res = tm->create_node_type(store::StoreConsts::documentNode,
qname,
contentType2,
quant,
false,
false);
return Unmarshaller::createSequenceType(res.getp());
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:21,代码来源:sequencetype.cpp
示例15: main
int main() {
TypeManager tm;
Type t_int32 = tm.get("int32");
Type t_float = tm.get("float");
Type t_int64 = tm.get("int64");
tm.addConversion(t_int32, t_float);
tm.addConversion(t_float, t_int32);
tm.addConversion(t_float, t_int64);
tm.addPromotion(t_int32, t_int64);
cout << "int32 -> float "
<< TCCString(tm.isCompatible(tm.get("int32"), tm.get("float")))
<< EOL;
cout << "int32 -> int64 "
<< TCCString(tm.isCompatible(tm.get("int32"), tm.get("int64")))
<< EOL;
Type sig[] = {t_int32, t_float};
Type ovsigs[] = {
t_float, t_float,
t_int64, t_int64,
t_int32, t_float,
};
int sel = tm.selectOverload(sig, ovsigs, 2, 3);
cout << "Selected " << sel << '\n';
return 0;
}
开发者ID:ASPP,项目名称:numba,代码行数:33,代码来源:test.cpp
示例16: ZORBA_ASSERT
void SchemaValidatorImpl::validateAfterUpdate(
store::Item* item,
zorba::store::PUL* pul,
const QueryLoc& loc)
{
ZORBA_ASSERT(item->isNode());
TypeManager* typeManager = theSctx->get_typemanager();
StaticContextConsts::validation_mode_t mode = theSctx->validation_mode();
if (mode == StaticContextConsts::skip_validation)
return;
bool isLax = (mode == StaticContextConsts::lax_validation);
Schema* schema = typeManager->getSchema();
if ( !schema )
{
// no schema available no change to pul
return;
}
EventSchemaValidator schemaValidator =
EventSchemaValidator(typeManager,
schema->getGrammarPool(),
isLax,
theLoc);
switch ( item->getNodeKind() )
{
case store::StoreConsts::documentNode:
{
//cout << "Validate after update document" << "\n"; cout.flush();
schemaValidator.startDoc();
store::NsBindings bindings;
namespace_context nsCtx = namespace_context(theSctx, bindings);
std::vector<store::Item_t> typedValues;
processChildren(pul,
nsCtx,
typeManager,
schemaValidator,
item->getChildren(),
typedValues,
loc);
schemaValidator.endDoc();
//cout << "End Validate after update doc" << "\n"; cout.flush();
return;
}
case store::StoreConsts::elementNode:
{
//cout << "Validate after update element" << "\n"; cout.flush();
schemaValidator.startDoc();
processElement(pul,
typeManager,
schemaValidator,
item,
loc);
schemaValidator.endDoc();
//cout << "End Validate after update elem" << "\n"; cout.flush();
return;
}
default:
throw XQUERY_EXCEPTION(
err::XQDY0061,
ERROR_PARAMS( ZED( NotDocOrElementNode ) ),
ERROR_LOC( theLoc )
);
}
}
开发者ID:alyst,项目名称:zorba,代码行数:79,代码来源:revalidateUtils.cpp
示例17: forletwin_clause
forlet_clause::forlet_clause(
static_context* sctx,
CompilerCB* ccb,
const QueryLoc& loc,
flwor_clause::ClauseKind kind,
var_expr* varExpr,
expr* domainExpr,
var_expr* posVarExpr,
var_expr* scoreVarExpr,
bool isAllowingEmpty,
bool lazy)
:
forletwin_clause(sctx, ccb, loc, kind, varExpr, domainExpr),
thePosVarExpr(posVarExpr),
theScoreVarExpr(scoreVarExpr),
theAllowingEmpty(isAllowingEmpty),
theLazyEval(lazy)
{
if (thePosVarExpr != NULL)
thePosVarExpr->set_flwor_clause(this);
if (theScoreVarExpr != NULL)
theScoreVarExpr->set_flwor_clause(this);
if (varExpr != NULL && sctx != NULL)
{
RootTypeManager& rtm = GENV_TYPESYSTEM;
TypeManager* tm = sctx->get_typemanager();
xqtref_t declaredType = varExpr->get_type();
if (declaredType != NULL)
{
if (kind == flwor_clause::for_clause && declaredType->is_empty())
{
RAISE_ERROR(err::XPTY0004, loc,
ERROR_PARAMS(ZED(BadType_23o), "empty-sequence"));
}
xqtref_t domainType = domainExpr->get_return_type();
if (!TypeOps::is_equal(tm, *rtm.ITEM_TYPE_STAR, *declaredType, loc))
{
if (kind == flwor_clause::for_clause)
{
SequenceType::Quantifier domQuant = domainType->get_quantifier();
SequenceType::Quantifier declQuant = declaredType->get_quantifier();
if (theAllowingEmpty &&
(declQuant == SequenceType::QUANT_ONE ||
declQuant == SequenceType::QUANT_PLUS))
{
declaredType = tm->create_type(*declaredType, SequenceType::QUANT_PLUS);
}
else
{
declaredType = tm->create_type(*declaredType, domQuant);
}
}
if (!TypeOps::is_subtype(tm, *domainType, *declaredType, loc))
{
xqtref_t varType = TypeOps::intersect_type(*domainType, *declaredType, tm);
if (TypeOps::is_equal(tm, *varType, *rtm.NONE_TYPE, loc))
{
RAISE_ERROR(err::XPTY0004, loc,
ERROR_PARAMS(ZED(BadType_23o), *domainType, ZED(NoTreatAs_4), *declaredType));
}
domainExpr = theCCB->theEM->
create_treat_expr(sctx,
domainExpr->get_udf(),
loc,
domainExpr,
declaredType,
TREAT_TYPE_MATCH);
set_expr(domainExpr);
}
}
}
}
}
开发者ID:zorba-processor,项目名称:zorba,代码行数:84,代码来源:flwor_expr.cpp
示例18: deepEqualNodes
bool deepEqualNodes(
const QueryLoc& loc,
static_context* sctx,
const store::Item* item1,
const store::Item* item2,
XQPCollator* collator,
int timezone,
bool raiseError)
{
if (item1->getNodeKind() != item2->getNodeKind())
return false;
switch (item1->getNodeKind())
{
case store::StoreConsts::documentNode:
{
return deepEqualChildren(loc,
sctx,
item1->getChildren(),
item2->getChildren(),
collator,
timezone,
raiseError);
break;
}
case store::StoreConsts::elementNode:
{
if (! item1->getNodeName()->equals(item2->getNodeName()))
return false;
if (!deepEqualAttributes(loc,
sctx,
item1->getAttributes(),
item2->getAttributes(),
collator,
timezone,
raiseError))
return false;
if (item1->haveSimpleContent())
{
if (!item2->haveSimpleContent())
return false;
store::Item_t value1, value2;
store::Iterator_t ite1, ite2;
item1->getTypedValue(value1, ite1);
item2->getTypedValue(value2, ite2);
if (ite1 == NULL && ite2 == NULL)
{
return deepEqual(loc, sctx, value1, value2, collator, timezone, raiseError);
}
else if (ite1 != NULL && ite2 != NULL)
{
ite1->open();
ite2->open();
while (1)
{
bool c1Valid = ite1->next(value1);
bool c2Valid = ite2->next(value2);
if (!c1Valid && !c2Valid)
return true;
else if (!c1Valid || !c2Valid)
return false;
else if (!deepEqual(loc, sctx, value1, value2, collator, timezone, raiseError))
return false;
}
}
else
{
return false;
}
}
else if (item2->haveSimpleContent())
{
return false;
}
else
{
store::Item* typename1 = item1->getType();
store::Item* typename2 = item2->getType();
if (typename1->equals(typename2))
{
return deepEqualChildren(loc,
sctx,
item1->getChildren(),
item2->getChildren(),
collator,
timezone,
raiseError);
}
else
{
TypeManager* tm = sctx->get_typemanager();
xqtref_t type1 =
//.........这里部分代码省略.........
开发者ID:alyst,项目名称:zorba,代码行数:101,代码来源:deep_equality.cpp
注:本文中的TypeManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论