void checkParameterPassing(Parameter* formalParameter, AST_NODE* actualParameter) { while (formalParameter && actualParameter) { if (actualParameter->nodeType == EXPR_NODE) { processExprNode(actualParameter); if (formalParameter->type->kind == ARRAY_TYPE_DESCRIPTOR) { printErrorMsg(actualParameter, PASS_SCALAR_TO_ARRAY); } } else if (actualParameter->nodeType == CONST_VALUE_NODE) { } else if (actualParameter->nodeType == STMT_NODE) { checkFunctionCall(actualParameter); SymbolTableEntry *entry = retrieveSymbol(actualParameter->semantic_value.identifierSemanticValue.identifierName); if (entry != NULL) { if (formalParameter->type->kind == ARRAY_TYPE_DESCRIPTOR ) { printErrorMsg(actualParameter, PASS_SCALAR_TO_ARRAY); } else { if (getDataType(formalParameter->type) != getDataType(entry->attribute->attr.typeDescriptor)) { printErrorMsgSpecial(actualParameter, formalParameter->parameterName, PARAMETER_TYPE_UNMATCH); } } } } else if (actualParameter->nodeType == IDENTIFIER_NODE) { checkParameterIdentifier(formalParameter, actualParameter); } formalParameter = formalParameter->next; actualParameter = actualParameter->rightSibling; } }
void ImageTargetFileQuartz::setupImageDestOptions() { int bitsPerComponent = ImageIo::dataTypeBytes( getDataType() ) * 8; // setup the dictionary of options for CGImageDestinationAddImage mImageDestOptions = std::shared_ptr<__CFDictionary>( ::CFDictionaryCreateMutable( kCFAllocatorDefault, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks ), cocoa::safeCfRelease ); ::CFDictionarySetValue( mImageDestOptions.get(), kCGImagePropertyIsFloat, ( getDataType() == ImageIo::FLOAT32 ) ? kCFBooleanTrue : kCFBooleanFalse ); ::CFDictionarySetValue( mImageDestOptions.get(), kCGImagePropertyHasAlpha, ( hasAlpha() ) ? kCFBooleanTrue : kCFBooleanFalse ); ::CFNumberRef depthNumber = ::CFNumberCreate( kCFAllocatorDefault, kCFNumberIntType, &bitsPerComponent ); ::CFDictionarySetValue( mImageDestOptions.get(), kCGImagePropertyDepth, depthNumber ); ::CFRelease( depthNumber ); }
QString DateType::generateControl(QString inputString) { QString control = " " + normalize(inputString, "normalized") + "\n"; control.append(" if(normalized.isEmpty()) {\n"); control.append(" ok = false;\n"); control.append(" } else {\n"); control.append( " " + getDataType() + " date_ = " + getDataType() + "::fromString(normalized, QString(\"" + (getName() == "time" ? format.right(6) : format) + "\").left(normalized.length()));\n"); control.append(" ok = date_.isValid();\n"); control.append(" }"); return control; }
void generateMapEntries(std::ostream & stream, MapEntryData ** p, int pCount, std::string indentation = "\t\t\t") { assert(p && pCount >= 0); // Sort p by addresses and pins for(int o = pCount - 1; o >= 1; o--) for(int i = o; i >= 1; i--) if(p[i]->addr < p[i-1]->addr || (p[i]->addr == p[i-1]->addr && p[i]->pb->firstPin < p[i-1]->pb->firstPin)) std::swap(p[i], p[i-1]); // All addresses have to be positive (there are valid addresses for all entires) assert(p[0]->addr >= 0); // Start with address 0, pin 0 int prevAddress = -1; int prevPin = 7; // Generate code for entries for(int i = 0; i < pCount; i++) { // generate padding between pins const int fullBytePad = p[i]->addr - prevAddress - 1; if(fullBytePad > 0) { if(prevPin < 7) { stream << indentation << getDataType(8) << " : " << (7 - prevPin) << " ;\n"; prevPin = 7; } stream << indentation << getDataType(8) << " __pad" << i << " [0x" << std::hex << fullBytePad << std::dec << "];\n"; } const int bitPad = 7 - prevPin + p[i]->pb->firstPin; if(bitPad > 0) stream << indentation << getDataType(8) << " : " << bitPad << ";\n"; // generate pi n code const int pinCount = p[i]->pb->getPinCount(); stream << indentation << getDataType(pinCount) << " " << p[i]->identifier << " : " << pinCount << ";\t\t// " << uc::getPinTypeString(p[i]->ptype) << (char)toupper(p [i]->pb->port) << " (0x" << std::hex << p[i]->addr << std::dec << "), bit " << p[i]->pb->firstPin; if(pinCount > 1) stream << "-" << p[i]->pb->lastPin; stream << "\n"; prevAddress = p[i]->addr; prevPin = p[i]->pb->lastPin; } }
/** returns alignment to use for this variable */ RKVariable::CellAlign RKVariable::getAlignment () { RK_ASSERT (myData ()); if (myData ()->formatting_options && (myData ()->formatting_options->alignment != FormattingOptions::AlignDefault)) { if (myData ()->formatting_options->alignment == FormattingOptions::AlignLeft) return AlignCellLeft; return AlignCellRight; } else { // TODO: use global (configurable) defaults, if not specified if ((getDataType () == DataCharacter) || (getDataType () == DataFactor)) { return AlignCellLeft; } else { return AlignCellRight; } } }
bool CFields::parseFormat(char* string) { m_count = 0; char* argv[32]; size_t argc = parse(string, argv, arraysize(argv)); if (!argc || argc > arraysize(m_fields)) return false; memset(m_fields, 0, sizeof m_fields); for (size_t i = 0; i < argc; i++) { char* arg = argv[i]; if (arg[0] == '[') { if (!nullLast(arg, ']')) return false; m_fields[i].type = dt_translation; m_fields[i].int_number = g_lang.addLang(arg + 1).code; } else m_fields[i].type = getDataType(arg); } m_count = argc; return true; }
Token Lexer::getOperandToken(const std::string & str, Machine & machine) { Token returnToken; if (str.size() < 2) { if (isdigit(str[0])) getHeapLocation(str, 0, returnToken, machine); else if (isalpha(str[0])) getLabel(str, 0, returnToken); return returnToken; } switch (str[0]) { case '#': getConstant(str, 1, returnToken); break; case '@': getPointer(str, 1, returnToken, machine); break; case '$': getDataType(str, 1, returnToken); break; case '?': getComparisonFlagId(str, 1, returnToken); break; case 'n': if ((str.size() == 3) && (str[1] == 'i') && (str[2] == 'l')) { returnToken.type = Token::T_OPERAND_NIL; break; } // else fall into default default: getLocation(str, 0, returnToken, machine); } return returnToken; }
PHP_METHOD(ArrayList, __construct){ zval* temp; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &temp) == FAILURE) { RETURN_NULL(); } // get type char type = 0; try { type = getDataType(temp); } catch (const std::runtime_error& e) { zend_throw_exception(NULL, e.what(), 0 TSRMLS_CC); RETURN_NULL(); } // create object list_object* obj = (list_object*) zend_object_store_get_object(getThis() TSRMLS_CC); obj->type = type; if(type == TYPE_LONG) { obj->object = new ArrayList<long>; } else if (type == TYPE_DOUBLE) { obj->object = new ArrayList<double>; } else if (type == TYPE_BOOLEAN) { obj->object = new ArrayList<char>; } else if (type == TYPE_STRING) { obj->memory_manager = new MemoryManager<char*>; obj->object = new ArrayList<char*>; } else if(type==TYPE_OBJECT) { obj->class_entry = str2class(temp); obj->object = new ArrayList<zval*>; } else { obj->object = new ArrayList<zval*>; } }
std::map<std::string, int> h5n( const string &file ) { H5::H5File h5f(file + "/coord.h5", H5F_ACC_RDONLY); hsize_t n[2]; std::map<std::string, int> map; h5f.openDataSet("T").getSpace().getSimpleExtentDims(n, NULL); map["t"] = n[0]; { auto h5d = h5f.openDataSet("T"); float dt; { auto attr = h5d.openAttribute("dt"); attr.read(attr.getDataType(), &dt); } auto h5s = h5d.getSpace(); const hsize_t two = 2, zero = 0; float tmp[2]; h5s.selectHyperslab( H5S_SELECT_SET, &two, &zero); h5d.read(tmp, H5::PredType::NATIVE_FLOAT, H5::DataSpace(1, &two), h5s); map["outfreq"] = (tmp[1] - tmp[0]) / dt; } h5f.openDataSet("X").getSpace().getSimpleExtentDims(n, NULL); // X gives cell-border coordinates (+1) map["x"] = n[0]-1; map["z"] = n[1]-1; return map; }
int getDataSize(uint8_t index){ char type = getDataType(index); switch(type){ case 'c': // ASCII character sent as 32 bits case 'r': // 32bit RGBA colour case 'i': // 32bit integer case 'f': // 32bit float case 'm': // 4-byte MIDI message return 4; case 'h': // 64bit integer case 'd': // 64bit double return 8; case 'b': // blob // first four bytes is the size return *(uint32_t*)getData(index); case 's': // string case 'S': // symbol { char* str = (char*)getData(index); int8_t size = strnlen(str, (char*)end-str)+1; while(size & 0x03) size++; return size; } case 'T': // TRUE case 'F': // FALSE case 'N': // NIL case 'I': // INFINITUM default: return 0; } }
void TR::ValidateChildTypes::validate(TR::Node *node) { auto opcode = node->getOpCode(); if (opcode.expectedChildCount() != ILChildProp::UnspecifiedChildCount) { const auto expChildCount = opcode.expectedChildCount(); const auto actChildCount = node->getNumChildren(); /* Validate child types. */ for (auto i = 0; i < actChildCount; ++i) { auto childOpcode = node->getChild(i)->getOpCode(); if (childOpcode.getOpCodeValue() != TR::GlRegDeps) { const auto expChildType = opcode.expectedChildType(i); const auto actChildType = childOpcode.getDataType().getDataType(); const auto expChildTypeName = (expChildType >= TR::NumTypes) ? "UnspecifiedChildType" : TR::DataType::getName(expChildType); const auto actChildTypeName = TR::DataType::getName(actChildType); TR::checkILCondition(node, (expChildType >= TR::NumTypes || actChildType == expChildType), comp(), "Child %d has unexpected type %s (expected %s)", i, actChildTypeName, expChildTypeName); } else { /** * Make sure the node is allowed to have a GlRegDeps child * and check that it is the last child. */ TR::checkILCondition(node, opcode.canHaveGlRegDeps() && (i == actChildCount - 1), comp(), "Unexpected GlRegDeps child %d", i); } } } }
QString RKVariable::getRText (int row) { RK_TRACE (OBJECTS); Status cell_state = cellStatus (row); if ((cell_state == ValueUnused) || (cell_state == ValueInvalid)) { return ("NA"); } else if (getDataType () == DataFactor) { return (rQuote (getLabeled (row))); } else if (getDataType () == DataCharacter) { return (rQuote (getText (row))); } else { RK_ASSERT (myData ()->cell_doubles != 0); return (QString::number (myData ()->cell_doubles[row], 'g', MAX_PRECISION)); } }
void RKVariable::setText (int row, const QString &text) { RK_TRACE (OBJECTS); RK_ASSERT (row < getLength ()); if (myData ()->cell_states[row] & RKVarEditData::Invalid) { myData ()->cell_states[row] = RKVarEditData::UnsyncedInvalidState; myData ()->invalid_fields.remove (row); } else { myData ()->cell_states[row] = 0; } if (text.isNull ()) { myData ()->cell_states[row] |= RKVarEditData::NA; } else { if (getDataType () == DataCharacter) { RK_ASSERT (myData ()->cell_strings != 0); myData ()->cell_strings[row] = text; myData ()->cell_states[row] |= RKVarEditData::Valid; } else if (getDataType () == DataFactor) { RK_ASSERT (myData ()->cell_doubles != 0); if (text.isEmpty ()) { myData ()->cell_states[row] |= RKVarEditData::NA; } else if (myData ()->value_labels && myData ()->value_labels->contains (text)) { myData ()->cell_doubles[row] = text.toInt (); myData ()->cell_states[row] |= RKVarEditData::Valid; } else { myData ()->invalid_fields.replace (row, new QString (text)); myData ()->cell_states[row] |= RKVarEditData::Invalid | RKVarEditData::UnsyncedInvalidState; } } else { RK_ASSERT (myData ()->cell_doubles != 0); bool ok; if (text.isEmpty ()) { myData ()->cell_states[row] |= RKVarEditData::NA; } else { myData ()->cell_doubles[row] = text.toDouble (&ok); if (ok) { myData ()->cell_states[row] |= RKVarEditData::Valid; } else { myData ()->invalid_fields.replace (row, new QString (text)); myData ()->cell_states[row] |= RKVarEditData::Invalid | RKVarEditData::UnsyncedInvalidState; } } } } cellChanged (row); }
ir::Value* BuiltinCall::generateIrValue(ir::Builder& builder) { std::vector<ir::Value*> paramValues; for (Expression* param : _parameters) paramValues.push_back(param->generateIrValue(builder)); return builder.createBuiltinCall(_data, Symbol::dataTypeToIrDataType(getDataType()), paramValues, getDataType() != Symbol::DataType::VOID); }
StoragePtr TableFunctionODBC::executeImpl(const ASTPtr & ast_function, const Context & context) const { const ASTFunction & args_func = typeid_cast<const ASTFunction &>(*ast_function); if (!args_func.arguments) throw Exception("Table function 'odbc' must have arguments.", ErrorCodes::LOGICAL_ERROR); ASTs & args = typeid_cast<ASTExpressionList &>(*args_func.arguments).children; if (args.size() != 2) throw Exception("Table function 'odbc' requires exactly 2 arguments: ODBC connection string and table name.", ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); for (int i = 0; i < 2; ++i) args[i] = evaluateConstantExpressionOrIdentifierAsLiteral(args[i], context); std::string connection_string = static_cast<const ASTLiteral &>(*args[0]).value.safeGet<String>(); std::string table_name = static_cast<const ASTLiteral &>(*args[1]).value.safeGet<String>(); Poco::Data::ODBC::SessionImpl session(connection_string, DBMS_DEFAULT_CONNECT_TIMEOUT_SEC); SQLHDBC hdbc = session.dbc().handle(); SQLHSTMT hstmt = nullptr; if (Poco::Data::ODBC::Utility::isError(SQLAllocStmt(hdbc, &hstmt))) throw Poco::Data::ODBC::ODBCException("Could not allocate connection handle."); SCOPE_EXIT(SQLFreeStmt(hstmt, SQL_DROP)); /// TODO Why not do SQLColumns instead? std::string query = "SELECT * FROM " + table_name + " WHERE 1 = 0"; if (Poco::Data::ODBC::Utility::isError(Poco::Data::ODBC::SQLPrepare(hstmt, reinterpret_cast<SQLCHAR *>(&query[0]), query.size()))) throw Poco::Data::ODBC::DescriptorException(session.dbc()); if (Poco::Data::ODBC::Utility::isError(SQLExecute(hstmt))) throw Poco::Data::ODBC::StatementException(hstmt); SQLSMALLINT cols = 0; if (Poco::Data::ODBC::Utility::isError(SQLNumResultCols(hstmt, &cols))) throw Poco::Data::ODBC::StatementException(hstmt); /// TODO cols not checked NamesAndTypesList columns; for (SQLSMALLINT ncol = 1; ncol <= cols; ++ncol) { SQLSMALLINT type = 0; /// TODO Why 301? SQLCHAR column_name[301]; /// TODO Result is not checked. Poco::Data::ODBC::SQLDescribeCol(hstmt, ncol, column_name, sizeof(column_name), NULL, &type, NULL, NULL, NULL); columns.emplace_back(reinterpret_cast<char *>(column_name), getDataType(type)); } auto result = StorageODBC::create(table_name, connection_string, "", table_name, ColumnsDescription{columns}); result->startup(); return result; }
/****************************************************************************** * Sets the value with name val_name to the data in val_data for the currently * opened key. * * Parameters: * val_name - name of the registry value * val_data - registry value data */ HRESULT setValue(LPTSTR val_name, LPTSTR val_data) { HRESULT hRes; DWORD dwDataType, dwParseType; LPBYTE lpbData; BYTE convert[KEY_MAX_LEN]; BYTE *bBigBuffer = 0; DWORD dwLen; if ((val_name == NULL) || (val_data == NULL)) return ERROR_INVALID_PARAMETER; /* Get the data type stored into the value field */ dwDataType = getDataType(&val_data, &dwParseType); // if (dwParseType == REG_EXPAND_SZ) { // } // if (dwParseType == REG_SZ || dwParseType == REG_EXPAND_SZ) { /* no conversion for string */ if (dwParseType == REG_SZ) { /* no conversion for string */ dwLen = _tcslen(val_data); if (dwLen > 0 && val_data[dwLen-1] == _T('"')) { dwLen--; val_data[dwLen] = _T('\0'); } dwLen++; dwLen *= sizeof(TCHAR); REGPROC_unescape_string(val_data); lpbData = val_data; } else if (dwParseType == REG_DWORD) { /* Convert the dword types */ dwLen = convertHexToDWord(val_data, convert); lpbData = convert; } else { /* Convert the hexadecimal types */ int b_len = _tcslen(val_data)+2/3; if (b_len > KEY_MAX_LEN) { bBigBuffer = HeapAlloc (GetProcessHeap(), 0, b_len * sizeof(TCHAR)); if (bBigBuffer == NULL) { return ERROR_REGISTRY_IO_FAILED; } CHECK_ENOUGH_MEMORY(bBigBuffer); dwLen = convertHexCSVToHex(val_data, bBigBuffer, b_len); lpbData = bBigBuffer; } else { dwLen = convertHexCSVToHex(val_data, convert, KEY_MAX_LEN); lpbData = convert; } } hRes = RegSetValueEx(currentKeyHandle, val_name, 0, /* Reserved */dwDataType, lpbData, dwLen); _tprintf(_T(" Value: %s, Data: %s\n"), val_name, lpbData); if (bBigBuffer) HeapFree(GetProcessHeap(), 0, bBigBuffer); return hRes; }
/// /// operator< /// /// NOTA BENE: This is used for SORTING ONLY /// bool Boolean::operator<(const Data& b) const{ // // If of differing data types, sort by the data type itself: // if(getDataType() != b.getDataType()) return getDataType() < b.getDataType(); Boolean* pb = static_cast<Boolean*>(const_cast<Data* const>(&b)); // // Sort MISSING values as LARGER than everything else: // if( _isMissing ) return false; if( pb->_isMissing ) return true; return _value < pb->_value; }
void Cask::CdapOdbc::ColumnsDataReader::getColumnValue(const ColumnBinding& binding) { auto& record = this->queryResult.getRows().at(this->currentRowIndex); std::wstring name; std::wstring typeName; SQLSMALLINT radix = 0; switch (binding.getColumnNumber()) { case 1: // TABLE_CAT case 2: // TABLE_SCHEM case 9: // DECIMAL_DIGITS case 12: // REMARKS case 13: // COLUMN_DEF case 15: // SQL_DATETIME_SUB case 16: // CHAR_OCTET_LENGTH this->fetchNull(binding); break; case 3: // TABLE_NAME this->fetchVarchar(this->tableName.c_str(), binding); break; case 4: // COLUMN_NAME name = record.at(L"name").as_string(); this->fetchVarchar(name.c_str(), binding); break; case 5: // DATA_TYPE case 14: // SQL_DATA_TYPE this->fetchSmallint(getDataType(record.at(L"type")), binding); break; case 6: // TYPE_NAME typeName = getTypeName(record.at(L"type")); this->fetchVarchar(typeName.c_str(), binding); break; case 7: // COLUMN_SIZE this->fetchInt(getColumnSize(record.at(L"type")), binding); break; case 8: // BUFFER_LENGTH this->fetchInt(getBufferLength(record.at(L"type")), binding); break; case 10: // NUM_PREC_RADIX radix = getRadix(record.at(L"type")); if (radix > 0) { this->fetchSmallint(radix, binding); } else { this->fetchNull(binding); } break; case 11: // NULLABLE this->fetchSmallint(getIsNull(record.at(L"type")), binding); break; case 17: // ORDINAL_POSITION this->fetchInt(this->currentRowIndex + 1, binding); break; case 18: // IS_NULLABLE this->fetchVarchar((getIsNull(record.at(L"type")) == SQL_NO_NULLS) ? L"NO" : L"YES", binding); break; } }
void NTupleEventReader::readDataTypes() { TIter nextFile(input->GetListOfFiles()); TChainElement* file = 0; while ((file = (TChainElement*) nextFile()) != 0) { string fileName = file->GetTitle(); DataType::value type = getDataType(fileName); seenDataTypes.at(type) = true; } }
void RKVariable::setNumeric (int from_row, int to_row, double *data) { RK_TRACE (OBJECTS); RK_ASSERT (to_row < getLength ()); if (getDataType () == DataCharacter) { RK_ASSERT (false); // asserting false to catch cases of this use for now. it's not really a problem, though int i = 0; for (int row=from_row; row <= to_row; ++row) { setText (row, QString::number (data[i++], 'g', MAX_PRECISION)); } } else if (getDataType () == DataFactor) { int i = 0; for (int row=from_row; row <= to_row; ++row) { if (myData ()->cell_states[row] & RKVarEditData::Invalid) myData ()->cell_states[row] = RKVarEditData::UnsyncedInvalidState; else myData ()->cell_states[row] = 0; if (isnan (data[i]) || (!myData ()->value_labels) || (!myData ()->value_labels->contains (QString::number (data[i])))) { myData ()->cell_states[row] |= RKVarEditData::NA; } else { myData ()->cell_states[row] |= RKVarEditData::Valid; myData ()->cell_doubles[row] = data[i]; } ++i; } } else { int i = 0; for (int row=from_row; row <= to_row; ++row) { if (myData ()->cell_states[row] & RKVarEditData::Invalid) myData ()->cell_states[row] = RKVarEditData::UnsyncedInvalidState; else myData ()->cell_states[row] = 0; if (isnan (data[i])) { myData ()->cell_states[row] |= RKVarEditData::NA; } else { myData ()->cell_states[row] |= RKVarEditData::Valid; myData ()->cell_doubles[row] = data[i]; } ++i; } } cellsChanged (from_row, to_row); }
RCommandProxy* RCommand::makeProxy () const { RK_TRACE (RBACKEND); RK_ASSERT (status == 0); // Initialization from an already touched command is not a real problem, but certainly no expected usage RK_ASSERT (has_been_run_up_to == 0); RK_ASSERT (getDataType () == RData::NoData); RCommandProxy *ret = new RCommandProxy (_command, _type); ret->id = _id, ret->status = status; ret->has_been_run_up_to = has_been_run_up_to; return ret; }
void ImageSourceFileTinyExr::load( ImageTargetRef target ) { ImageSource::RowFunc rowFunc = setupRowFunc( target ); const size_t numChannels = mExrImage->num_channels; const void *red = nullptr, *green = nullptr, *blue = nullptr, *alpha = nullptr; for( size_t c = 0; c < numChannels; ++c ) { if( strcmp( mExrImage->channel_names[c], "R" ) == 0 ) red = mExrImage->images[c]; else if( strcmp( mExrImage->channel_names[c], "G" ) == 0 ) green = mExrImage->images[c]; else if( strcmp( mExrImage->channel_names[c], "B" ) == 0 ) blue = mExrImage->images[c]; else if( strcmp( mExrImage->channel_names[c], "A" ) == 0 ) alpha = mExrImage->images[c]; } if( ( ! red ) || ( ! green ) || ( ! blue ) ) throw ImageIoExceptionFailedLoadTinyExr( "Unable to locate channels for RGB" ); // load one interleaved row at a time if( getDataType() == ImageIo::FLOAT32 ) { vector<float> rowData( mWidth * mExrImage->num_channels, 0 ); for( int32_t row = 0; row < mHeight; row++ ) { for( int32_t col = 0; col < mWidth; col++ ) { rowData.at( col * numChannels + 0 ) = ((float*)red)[row * mWidth + col]; rowData.at( col * numChannels + 1 ) = ((float*)green)[row * mWidth + col]; rowData.at( col * numChannels + 2 ) = ((float*)blue)[row * mWidth + col]; if( alpha ) rowData.at( col * numChannels + 3 ) = ((float*)alpha)[row * mWidth + col]; } ((*this).*rowFunc)( target, row, rowData.data() ); } } else { // float16 vector<uint16_t> rowData( mWidth * mExrImage->num_channels, 0 ); for( int32_t row = 0; row < mHeight; row++ ) { for( int32_t col = 0; col < mWidth; col++ ) { rowData.at( col * numChannels + 0 ) = ((uint16_t*)red)[row * mWidth + col]; rowData.at( col * numChannels + 1 ) = ((uint16_t*)green)[row * mWidth + col]; rowData.at( col * numChannels + 2 ) = ((uint16_t*)blue)[row * mWidth + col]; if( alpha ) rowData.at( col * numChannels + 3 ) = ((uint16_t*)alpha)[row * mWidth + col]; } ((*this).*rowFunc)( target, row, rowData.data() ); } } FreeEXRImage( mExrImage.get() ); }
QString DateType::generateSetter(QString inputString, QString outputVariable) { QString setter = normalize(inputString, "normalized") + "\n"; setter.append(" bool ok;\n"); setter.append(" " + getDataType() + " date_;"); setter.append(" if(normalized.isEmpty()) {\n"); setter.append(" ok = false;\n"); setter.append(" } else {\n"); setter.append( " date_ = " + getDataType() + "::fromString(normalized, QString(\"" + (getName() == "time" ? format.right(6) : format) + "\").left(normalized.length()));\n"); setter.append(" ok = date_.isValid();\n"); setter.append(" }"); setter.append(" if(ok) {\n"); setter.append(" " + outputVariable + " = date_;\n"); setter.append(" } else {\n"); setter.append(" return;\n"); setter.append(" }"); return setter; }
void IndexBuffer::render(PrimitiveType type) { glBindBuffer(_bufferType, _handle); glDrawElements( TranslatePrimitiveType(type), getElementCount(), getDataType(), 0 ); glBindBuffer(_bufferType, 0); }
bool wrench::gl::Texture::transferFromTexture(IplImage* image) { // TODO: Not sure if this needs to be bound here bind(GL_TEXTURE5); if(nullptr == m_fbo) { m_fbo = new FBO(); m_fbo->init(m_width, m_height); m_fbo->setTextureAttachPoint(*this, GL_COLOR_ATTACHMENT0); } bool compatible = _checkImageCompatibility(image); if(compatible) { const int channelCount = getChannelCount(); m_fbo->bind(); m_fbo->bindDrawBuffer(GL_COLOR_ATTACHMENT0); glReadBuffer(GL_COLOR_ATTACHMENT0); glBindBuffer(GL_PIXEL_PACK_BUFFER, m_PBOId); glBufferData(GL_PIXEL_PACK_BUFFER, m_width * m_height * channelCount * m_dataSize, nullptr, GL_STREAM_READ); glReadPixels(0, 0, m_width, m_height, m_format, m_dataType, 0); if(GL_FLOAT == getDataType()) { float* gpuMem = (float*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); // Actual data transfer for (unsigned int i = 0; i < m_height; i++) { // OpenCV does not guarentee continous memory blocks so it has to be copied row by row memcpy(image->imageData + (i * image->widthStep), gpuMem + (i * m_width * 3), m_width * channelCount * m_dataSize); } } else { char* gpuMem = (char*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); // Actual data transfer for (unsigned int i = 0; i < m_height; i++) { // OpenCV does not guarentee continous memory blocks so it has to be copied row by row memcpy(image->imageData + (i * image->widthStep), gpuMem + (i * m_width * 3), m_width * channelCount * m_dataSize); } } glUnmapBuffer(GL_PIXEL_PACK_BUFFER); // release pointer to mapping buffer glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); } return compatible; }
void checkParameterIdentifier(Parameter *formalParameter, AST_NODE *actualParameter) { SymbolTableEntry *entry = retrieveSymbol(actualParameter->semantic_value.identifierSemanticValue.identifierName); if (entry == NULL) { printErrorMsg(actualParameter, SYMBOL_UNDECLARED); } else if (entry->attribute->attributeKind == FUNCTION_SIGNATURE || entry->attribute->attributeKind == TYPE_ATTRIBUTE) { printErrorMsgSpecial(actualParameter, formalParameter->parameterName, PARAMETER_TYPE_UNMATCH); } else { if (formalParameter->type->kind == ARRAY_TYPE_DESCRIPTOR && entry->attribute->attr.typeDescriptor->kind == SCALAR_TYPE_DESCRIPTOR) { printErrorMsg(actualParameter, PASS_SCALAR_TO_ARRAY); } else if (formalParameter->type->kind == SCALAR_TYPE_DESCRIPTOR && entry->attribute->attr.typeDescriptor->kind == ARRAY_TYPE_DESCRIPTOR) { printErrorMsg(actualParameter, PASS_ARRAY_TO_SCALAR); } else { if (getDataType(formalParameter->type) != getDataType(entry->attribute->attr.typeDescriptor)) { printErrorMsgSpecial(actualParameter, formalParameter->parameterName, PARAMETER_TYPE_UNMATCH); } } } }
wxString &ddTextTableItemFigure::getText(bool extended) { if(showDataType && extended && getOwnerColumn()) { wxString ddType = dataTypes()[getDataType()]; //Should use getDataType() & getPrecision(), because when column is fk, type is not taken from this column, instead from original column (source of fk) bool havePrecision = columnType == dt_numeric || dt_bit || columnType == dt_char || columnType == dt_interval || columnType == dt_varbit || columnType == dt_varchar; if( havePrecision && getPrecision() >= 0) { ddType.Truncate(ddType.Find(wxT("("))); if(getScale() == -1) ddType += wxString::Format(wxT("(%d)"), getPrecision()); else ddType += wxString::Format(wxT("(%d,%d)"), getPrecision(), getScale()); } //Fix to serial is integer at automatically generated foreign key if(getDataType() == dt_serial && getOwnerColumn()->isGeneratedForeignKey()) ddType = dataTypes()[dt_integer]; out = wxString( hdSimpleTextFigure::getText() + wxString(wxT(" : ")) + ddType ); return out; } else if( showAlias && getOwnerColumn() == NULL ) { if(!oneTimeNoAlias) out = wxString( hdSimpleTextFigure::getText() + wxString(wxT(" ( ")) + colAlias + wxString(wxT(" ) ")) ); else { out = wxString( hdSimpleTextFigure::getText() ); oneTimeNoAlias = false; } return out; } else { return hdSimpleTextFigure::getText(); } }
bool Publication::validateHeader(const ros::Header& header, std::string& error_msg) { std::string md5sum, topic, client_callerid; if (!header.getValue("md5sum", md5sum) || !header.getValue("topic", topic) || !header.getValue("callerid", client_callerid)) { std::string msg("Header from subscriber did not have the required elements: md5sum, topic, callerid"); ROS_ERROR("%s", msg.c_str()); error_msg = msg; return false; } // Check whether the topic has been deleted from // advertised_topics through a call to unadvertise(), which could // have happened while we were waiting for the subscriber to // provide the md5sum. if(isDropped()) { std::string msg = std::string("received a tcpros connection for a nonexistent topic [") + topic + std::string("] from [" + client_callerid +"]."); ROS_ERROR("%s", msg.c_str()); error_msg = msg; return false; } if (getMD5Sum() != md5sum && (md5sum != std::string("*") && getMD5Sum() != std::string("*"))) { std::string datatype; header.getValue("type", datatype); std::string msg = std::string("Client [") + client_callerid + std::string("] wants topic ") + topic + std::string(" to have datatype/md5sum [") + datatype + "/" + md5sum + std::string("], but our version has [") + getDataType() + "/" + getMD5Sum() + std::string("]. Dropping connection."); ROS_ERROR("%s", msg.c_str()); error_msg = msg; return false; } return true; }
void NTupleEventReader::readDataTypes() { /* TIter nextFile(input->GetListOfFiles()); TChainElement* file = 0; while ((file = (TChainElement*) nextFile()) != 0) { string fileName = file->GetTitle(); DataType::value type = getDataType(fileName); seenDataTypes.at(type) = true; } */ for (unsigned int index = 0; index < samplefiles.size(); ++index) { DataType::value type = getDataType(samplefiles.at(index)); seenDataTypes.at(type) = true; } }
void RKVariable::extendToLength (int length) { RK_TRACE (OBJECTS); if (length <= 0) length = 1; if (length < (myData ()->allocated_length - 1)) { dimensions[0] = length; return; } int ilength = length + 1; // be a little generous int target = myData ()->allocated_length; if (!target) target = INITIAL_ALLOC; while (target <= ilength) target = target * ALLOC_STEP; RK_DO (qDebug ("resizing from %d to %d", myData ()->allocated_length, target), OBJECTS, DL_DEBUG); // allocate new memory and copy if (getDataType () == RObject::DataCharacter) { RK_ASSERT (myData ()->cell_doubles == 0); QString *new_data = new QString[target]; if (myData ()->allocated_length) { // if not yet allocated, don't mem-move qmemmove (new_data, myData ()->cell_strings, myData ()->allocated_length * sizeof (QString)); } delete [] (myData ()->cell_strings); myData ()->cell_strings = new_data; } else { RK_ASSERT (myData ()->cell_strings == 0); double *new_data = new double[target]; if (myData ()->allocated_length) { // if not yet allocated, don't mem-move qmemmove (new_data, myData ()->cell_doubles, myData ()->allocated_length * sizeof (double)); } delete [] (myData ()->cell_doubles); myData ()->cell_doubles = new_data; } int *new_states = new int[target]; if (myData ()->allocated_length) { // if not yet allocated, don't mem-move qmemmove (new_states, myData ()->cell_states, myData ()->allocated_length * sizeof (int)); } delete [] (myData ()->cell_states); myData ()->cell_states = new_states; // set allocated but unused rows to Unknown for (int i=myData ()->allocated_length; i < target; ++i) { myData ()->cell_states[i] = RKVarEditData::Unknown; } myData ()->allocated_length = target; dimensions[0] = length; }