void DataSourceMetaData::addSimpleField(const char * name, const char * xpath, ITypeInfo * type, unsigned flag) { ITypeInfo * promoted = type->queryPromotedType(); unsigned size = promoted->getSize(); unsigned thisBits = 0; if (size == UNKNOWN_LENGTH) { isStoredFixedWidth = false; switch (type->getTypeCode()) { case type_set: minRecordSize += sizeof(bool) + sizeof(size32_t); break; case type_varstring: minRecordSize += 1; break; case type_packedint: minRecordSize += 1; break; case type_varunicode: minRecordSize += sizeof(UChar); break; default: minRecordSize += sizeof(size32_t); break; } } else if (type->getTypeCode() == type_bitfield) { thisBits = type->getBitSize(); if (thisBits > bitsRemaining) { size = type->queryChildType()->getSize(); minRecordSize += size; bitsRemaining = size * 8; } bitsRemaining -= thisBits; } else minRecordSize += size; if (thisBits == 0) bitsRemaining = 0; fields.append(*new DataSourceMetaItem(flag, name, xpath, type)); }
void DataSourceMetaData::addSimpleField(const char * name, const char * xpath, ITypeInfo * type) { ITypeInfo * promoted = type->queryPromotedType(); unsigned size = promoted->getSize(); unsigned thisBits = 0; if (size == UNKNOWN_LENGTH) isStoredFixedWidth = false; else if (type->getTypeCode() == type_bitfield) { thisBits = type->getBitSize(); if (thisBits > bitsRemaining) { size = type->queryChildType()->getSize(); storedFixedSize += size; bitsRemaining = size * 8; } bitsRemaining -= thisBits; } else storedFixedSize += size; if (thisBits == 0) bitsRemaining = 0; fields.append(*new DataSourceMetaItem(FVFFnone, name, xpath, type)); }
void CChildSetColumnInfo::setColumn(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * _value) { OwnedHqlExpr address = getColumnAddress(translator, ctx, selector, boolType, 0); OwnedHqlExpr addressSize = getColumnAddress(translator, ctx, selector, sizetType, sizeof(bool)); OwnedHqlExpr addressData = getColumnAddress(translator, ctx, selector, queryType(), sizeof(bool)+sizeof(size32_t)); OwnedHqlExpr isAllTarget = convertAddressToValue(address, boolType); OwnedHqlExpr lengthTarget = convertAddressToValue(addressSize, sizetType); ITypeInfo * columnType = column->queryType(); ITypeInfo * elementType = columnType->queryChildType(); OwnedHqlExpr value = ensureExprType(_value, columnType); OwnedHqlExpr inlineSize; switch (value->getOperator()) { case no_list: if ((value->numChildren() != 0) && ::isFixedSize(elementType)) inlineSize.setown(getSizetConstant(value->numChildren() * elementType->getSize())); break; } if (inlineSize) { checkAssignOk(translator, ctx, selector, inlineSize, sizeof(size32_t)+sizeof(bool)); Owned<IHqlCppSetBuilder> builder = translator.createInlineSetBuilder(elementType, isAllTarget, inlineSize, addressData); builder->buildDeclare(ctx); translator.buildSetAssign(ctx, builder, value); CHqlBoundTarget boundTarget; boundTarget.length.set(lengthTarget); builder->buildFinish(ctx, boundTarget); } else { CHqlBoundExpr bound; if ((value->getOperator() == no_list) && value->numChildren()) { CHqlBoundTarget tempTarget; translator.createTempFor(ctx, columnType, tempTarget, typemod_none, FormatNatural); translator.buildExprAssign(ctx, tempTarget, value); bound.setFromTarget(tempTarget); } else translator.buildExpr(ctx, value, bound); ensureSimpleLength(translator, ctx, bound); OwnedHqlExpr isAll = bound.getIsAll(); OwnedHqlExpr length = translator.getBoundLength(bound); OwnedHqlExpr size = createValue(no_translated, LINK(sizetType), translator.getBoundSize(bound)); checkAssignOk(translator, ctx, selector, size, sizeof(size32_t)+sizeof(bool)); translator.assignBoundToTemp(ctx, isAllTarget, isAll); translator.assignBoundToTemp(ctx, lengthTarget, length); translator.buildBlockCopy(ctx, addressData, bound); ensureSimpleLength(translator, ctx, bound); OwnedHqlExpr boundSize = translator.getBoundSize(bound); associateSizeOf(ctx, selector, boundSize, sizeof(size32_t)+sizeof(bool)); } }