void SkAnimateBase::onEndElement(SkAnimateMaker& maker) { fChanged = false; setTarget(maker); if (field.size()) { SkASSERT(fTarget); fFieldInfo = fTarget->getMember(field.c_str()); field.reset(); } if (lval.size()) { // lval must be of the form x[y] const char* lvalStr = lval.c_str(); const char* arrayEnd = strchr(lvalStr, '['); if (arrayEnd == NULL) return; //should this return an error? size_t arrayNameLen = arrayEnd - lvalStr; SkString arrayStr(lvalStr, arrayNameLen); SkASSERT(fTarget); //this return an error? fFieldInfo = fTarget->getMember(arrayStr.c_str()); SkString scriptStr(arrayEnd + 1, lval.size() - arrayNameLen - 2); SkAnimatorScript::EvaluateInt(maker, this, scriptStr.c_str(), &fFieldOffset); } }
void SocketHelperFunctions::marshallArrayOfSizeAndTypeIntoBuffer(void* arr, uint64_t size, std::pair<llvm::Type::TypeID, unsigned> typeIDAndBitwidthPointedTo, char* outputBuffer) { std::cout << "DEBUG" << ": marshalling array of type " << typeIDAndBitwidthPointedTo.first << ((typeIDAndBitwidthPointedTo.second) ? ":" + std::to_string((unsigned long long)typeIDAndBitwidthPointedTo.second) : "") << ", size " << size << std::endl; unsigned arrayStrLen = 0U; std::shared_ptr<char> arrayStr((char*)calloc(MAX_ARR_SIZE, sizeof(char)), &free); char max_element[100]; sprintf(max_element, ";%La", std::numeric_limits<long double>::max()); const auto max_element_size = strlen(max_element) + 1; // marshal number of elements in array (total) arrayStrLen += sprintf(arrayStr.get(), ":%" PRIu64, size); // marshal elements switch (typeIDAndBitwidthPointedTo.first) { case llvm::Type::FloatTyID: for (uint64_t i = 0; i < size; i++) { if (arrayStrLen < MAX_ARR_SIZE - max_element_size) arrayStrLen += sprintf(arrayStr.get() + arrayStrLen, ";%la", *((float*)arr)); else error("ERROR, array in marshalled form is bigger than array buffer"); arr = (float*)arr + 1; } case llvm::Type::DoubleTyID: for (uint64_t i = 0; i < size; i++) { if (arrayStrLen < MAX_ARR_SIZE - max_element_size) arrayStrLen += sprintf(arrayStr.get() + arrayStrLen, ";%la", *((double*)arr)); else error("ERROR, array in marshalled form is bigger than array buffer"); arr = (double*)arr + 1; } break; case llvm::Type::X86_FP80TyID: case llvm::Type::FP128TyID: for (uint64_t i = 0; i < size; i++) { if (arrayStrLen < MAX_ARR_SIZE - max_element_size) arrayStrLen += sprintf(arrayStr.get() + arrayStrLen, ";%La", *((long double*)arr)); else error("ERROR, array in marshalled form is bigger than array buffer"); arr = (long double*)arr + 1; } break; case llvm::Type::IntegerTyID: // Note: LLVM does not differentiate between signed/unsiged int types switch (typeIDAndBitwidthPointedTo.second) { case 8: for (uint64_t i = 0; i < size; i++) { if (arrayStrLen < MAX_ARR_SIZE - max_element_size) arrayStrLen += sprintf(arrayStr.get() + arrayStrLen, ";%" PRIx8, *((int8_t*)arr)); else error("ERROR, array in marshalled form is bigger than array buffer"); arr = (int8_t*) arr + 1; } break; case 16: for (uint64_t i = 0; i < size; i++) { if (arrayStrLen < MAX_ARR_SIZE - max_element_size) arrayStrLen += sprintf(arrayStr.get() + arrayStrLen, ";%" PRIx16, *((int16_t*)arr)); else error("ERROR, array in marshalled form is bigger than array buffer"); arr = (int16_t*) arr + 1; } break; case 32: for (uint64_t i = 0; i < size; i++) { if (arrayStrLen < MAX_ARR_SIZE - max_element_size) arrayStrLen += sprintf(arrayStr.get() + arrayStrLen, ";%" PRIx32, *((int32_t*)arr)); else error("ERROR, array in marshalled form is bigger than array buffer"); arr = (int32_t*) arr + 1; } break; case 64: for (uint64_t i = 0; i < size; i++) { if (arrayStrLen < MAX_ARR_SIZE - max_element_size) arrayStrLen += sprintf(arrayStr.get() + arrayStrLen, ";%" PRIx64, *((int64_t*)arr)); else error("ERROR, array in marshalled form is bigger than array buffer"); arr = (int64_t*) arr + 1; } break; default: for (uint64_t i = 0; i < size; i++) { if (arrayStrLen < MAX_ARR_SIZE - max_element_size) arrayStrLen += sprintf(arrayStr.get() + arrayStrLen, ";%x", *((int*)arr)); else error("ERROR, array in marshalled form is bigger than array buffer"); arr = (int*) arr + 1; } break; } break; default: error(std::string("ERROR, LLVM TypeID " + std::to_string((long long)typeIDAndBitwidthPointedTo.first) + " is not supported for arrays").c_str()); } strcat(outputBuffer, arrayStr.get()); }