コード例 #1
0
ファイル: SourceLocation.cpp プロジェクト: AlanCal/rstudio
FileLocation SourceLocation::getSpellingLocation() const
{
   std::string file;
   unsigned line, column;
   if (getSpellingLocation(&file, &line, &column))
      return FileLocation(FilePath(file), line, column);
   else
      return FileLocation();
}
コード例 #2
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
TypeNode* handleSequenceType(TypeNode* type_expr)
{
    SequenceTypeNode* tn = new SequenceTypeNode(type_expr);
    tn->setLocation(FileLocation(yylineno));
    return tn;
#if 0
    const EquelleType et = type_expr->type();
    if (!et.isBasic()) {
        yyerror("cannot create a Sequence of non-basic types.");
    }
    TypeNode* node = new TypeNode(EquelleType(et.basicType(), Sequence, et.gridMapping(), et.subsetOf()));
    node->setLocation(FileLocation(yylineno));
    return node;
#endif
}
コード例 #3
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
SequenceNode* handleStencilAssignment(FuncCallLikeNode* lhs, ExpressionNode* rhs)
{
    SequenceNode* retval = new SequenceNode();
    retval->setLocation(FileLocation(yylineno));

    StencilNode* stencil = dynamic_cast<StencilNode*>(lhs);
    if (stencil == nullptr) {
        std::string err_msg = "Internal error: The stencil \"" + lhs->name() + "\" does not appear to be properly defined";
        yyerror(err_msg.c_str());
    }

#if 0
    // If the type is a collection of invalids (no pun intended)
    // we can safely set it to the type of the rhs
    EquelleType lhs_et = SymbolTable::variableType(stencil->name());
    if (lhs_et.basicType() == Invalid
        && lhs_et.compositeType() == Collection
        && lhs_et.isStencil()) {
        EquelleType lhs_et = rhs->type();
        lhs_et.setMutable(true);
        SymbolTable::setVariableType(stencil->name(), lhs_et);
        // TODO: set dimensions correctly here
        TypeNode* lhs_type = new TypeNode(lhs_et);
        retval->pushNode(new VarDeclNode(stencil->name(), lhs_type));
    }
#endif
    retval->pushNode(new StencilAssignmentNode(stencil, rhs));
    return retval;
}
コード例 #4
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
ExpressionNode* handleIdentifier(const std::string& name)
{
    VarNode* node = new VarNode(name);
    node->setLocation(FileLocation(yylineno));
    return node;
#if 0
    if (SymbolTable::isVariableDeclared(name)) {
        return new VarNode(name);
    } else {
        if (SymbolTable::isFunctionDeclared(name)) {
            return new FuncRefNode(name);
        } else {
            // This is a small problem: we want the error below, to catch
            // usage of undeclared identifiers, but the function start section
            // would then generate errors, because we are not yet in the function
            // scope.

            // std::string e("unknown identifier ");
            // e += name;
            // yyerror(e.c_str());
            return new JustAnIdentifierNode(name);
        }
    }
#endif
}
コード例 #5
0
ChildFFMpegLoader::ChildFFMpegLoader(std::unique_ptr<VideoSoundData> &&data)
: AbstractAudioFFMpegLoader(
	FileLocation(),
	QByteArray(),
	base::byte_vector())
, _parentData(std::move(data)) {
}
コード例 #6
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
StencilNode* handleStencilAccess(const std::string& name, FuncArgsNode* args)
{
    StencilNode* node = new StencilNode(name, args);
    node->setLocation(FileLocation(yylineno));
    return node;
#if 0
    if (!SymbolTable::isVariableDeclared(name)) {
        std::string err_msg = "Could not find the stencil variable " + name;
        yyerror(err_msg.c_str());
    }

    auto argtypes = args->argumentTypes();
    for (int i=0; i<argtypes.size(); ++i) {
        if (!isStencilType(argtypes[i].basicType())) {
            std::stringstream err_msg;
            err_msg << "Cannot access a stencil with a non-stencil index in variable \""
                    << name << "\"" << std::endl;
            yyerror(err_msg.str().c_str());
        }
        else if (argtypes[i].basicType() != StencilI + i) {
            std::stringstream err_msg;
            err_msg << "Got index " << basicTypeString(argtypes[i].basicType())
                    << " but expected " << basicTypeString(BasicType(StencilI + i))
                    << " for variable \"" << name << "\"" << std::endl;
            yyerror(err_msg.str().c_str());
        }
    }
    return new StencilNode(name, args);
#endif
}
コード例 #7
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
FuncStartNode* handleFuncAssignmentStart(const std::string& name, FuncArgsNode* args)
{
    FuncStartNode* node = new FuncStartNode(name, args);
    node->setLocation(FileLocation(yylineno));
    return node;
#if 0
    // We are dealing with a function
    if (SymbolTable::isFunctionDeclared(name)) {
        // Set the scope name for the following block (the function itself)
        // Will be "undone" in handleFuncAssignment
        SymbolTable::setCurrentFunction(name);
        return new FuncStartNode(name, args);
    }
    // We are dealing with a defined stencil variable
    else if (SymbolTable::isVariableDeclared(name)) {
        return handleStencilAccess(name, args);
    }
    // We are dealing with an undefined stencil variable
    else {
        EquelleType type(Invalid, Collection);
        type.setStencil(true);
        SymbolTable::declareVariable(name, type);
        return handleStencilAccess(name, args);
    }
#endif
}
コード例 #8
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
Node* handleDeclarationAssign(const std::string& name, TypeNode* type, ExpressionNode* expr)
{
    SequenceNode* seq = new SequenceNode;
    seq->pushNode(handleDeclaration(name, type));
    seq->pushNode(handleAssignment(name, expr));
    seq->setLocation(FileLocation(yylineno));
    return seq;
}
コード例 #9
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
UnitNode* handleUnitPower(UnitNode* unit, const double num)
{
    const int n = static_cast<int>(num);
    if (n != num) {
        yyerror("Powers of units (to the right of '^') can only be integers.");
    }
    UnitNode* node = new PowerUnitNode(unit, n);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #10
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
FuncCallStatementNode* handleFuncCallStatement(FuncCallLikeNode* fcall_like)
{
    FuncCallNode* fcall = dynamic_cast<FuncCallNode*>(fcall_like);
    if (fcall == nullptr) {
        std::string err_msg = "Internal error: The function \"" + fcall_like->name() + "\" does not appear to be properly defined";
        yyerror(err_msg.c_str());
    }
    FuncCallStatementNode* node = new FuncCallStatementNode(fcall);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #11
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
TypeNode* handleMutableType(TypeNode* type_expr)
{
    MutableTypeNode* tn = new MutableTypeNode(type_expr);
    tn->setLocation(FileLocation(yylineno));
    return tn;
#if 0
    EquelleType et = type_expr->type();
    et.setMutable(true);
    TypeNode* tn = new TypeNode(et);
    tn->setLocation(type_expr->location());
    delete type_expr;
    return tn;
#endif
}
コード例 #12
0
ファイル: localstorage.cpp プロジェクト: AmesianX/tdesktop
	FileLocation readFileLocation(const MediaKey &location, bool check) {
		FileLocations::iterator i = _fileLocations.find(location);
		for (FileLocations::iterator i = _fileLocations.find(location); (i != _fileLocations.end()) && (i.key() == location);) {
			if (check) {
				QFileInfo info(i.value().name);
				if (!info.exists() || info.lastModified() != i.value().modified || info.size() != i.value().size) {
					_fileLocationPairs.remove(i.value().name);
					i = _fileLocations.erase(i);
					_writeLocations();
					continue;
				}
			}
			return i.value();
		}
		return FileLocation();
	}
コード例 #13
0
ファイル: fileuploader.cpp プロジェクト: JordanSekky/tdesktop
void FileUploader::uploadMedia(MsgId msgId, const ReadyLocalMedia &media) {
	if (media.type == ToPreparePhoto) {
		App::feedPhoto(media.photo, media.photoThumbs);
	} else if (media.type == ToPrepareDocument) {
		DocumentData *document;
		if (media.photoThumbs.isEmpty()) {
			document = App::feedDocument(media.document);
		} else {
			document = App::feedDocument(media.document, media.photoThumbs.begin().value());
		}
		document->status = FileUploading;
		if (!media.file.isEmpty()) {
			document->location = FileLocation(mtpc_storage_filePartial, media.file);
		}
	}
	queue.insert(msgId, File(media));
	sendNext();
}
コード例 #14
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
TypeNode* handleArrayType(const int array_size, TypeNode* type_expr)
{
    ArrayTypeNode* tn = new ArrayTypeNode(type_expr, array_size);
    tn->setLocation(FileLocation(yylineno));
    return tn;
#if 0
    EquelleType et = type_expr->type();
    if (et.isArray()) {
        yyerror("cannot create an Array of an Array.");
        return type_expr;
    } else {
        et.setArraySize(array_size);
        TypeNode* tn = new TypeNode(et);
        tn->setLocation(type_expr->location());
        delete type_expr;
        return tn;
    }
#endif
}
コード例 #15
0
ファイル: fileuploader.cpp プロジェクト: NXij/tdesktop-dark
void FileUploader::uploadMedia(const FullMsgId &msgId, const ReadyLocalMedia &media) {
    if (media.type == PreparePhoto) {
        App::feedPhoto(media.photo, media.photoThumbs);
    } else if (media.type == PrepareDocument || media.type == PrepareAudio) {
        DocumentData *document;
        if (media.photoThumbs.isEmpty()) {
            document = App::feedDocument(media.document);
        } else {
            document = App::feedDocument(media.document, media.photoThumbs.begin().value());
        }
        document->status = FileUploading;
        if (!media.data.isEmpty()) {
            document->setData(media.data);
        }
        if (!media.file.isEmpty()) {
            document->setLocation(FileLocation(StorageFilePartial, media.file));
        }
    }
    queue.insert(msgId, File(media));
    sendNext();
}
コード例 #16
0
ファイル: fileuploader.cpp プロジェクト: NXij/tdesktop-dark
void FileUploader::upload(const FullMsgId &msgId, const FileLoadResultPtr &file) {
    if (file->type == PreparePhoto) {
        PhotoData *photo = App::feedPhoto(file->photo, file->photoThumbs);
        photo->uploadingData = new PhotoData::UploadingData(file->partssize);
    } else if (file->type == PrepareDocument || file->type == PrepareAudio) {
        DocumentData *document;
        if (file->thumb.isNull()) {
            document = App::feedDocument(file->document);
        } else {
            document = App::feedDocument(file->document, file->thumb);
        }
        document->status = FileUploading;
        if (!file->content.isEmpty()) {
            document->setData(file->content);
        }
        if (!file->filepath.isEmpty()) {
            document->setLocation(FileLocation(StorageFilePartial, file->filepath));
        }
    }
    queue.insert(msgId, File(file));
    sendNext();
}
コード例 #17
0
ChildFFMpegLoader::ChildFFMpegLoader(uint64 videoPlayId, std_::unique_ptr<VideoSoundData> &&data) : AudioPlayerLoader(FileLocation(), QByteArray())
, _videoPlayId(videoPlayId)
, _parentData(std_::move(data)) {
	_frame = av_frame_alloc();
}
コード例 #18
0
ファイル: file_download.cpp プロジェクト: 2asoft/tdesktop
void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRequestId req) {
	Requests::iterator i = _requests.find(req);
	if (i == _requests.cend()) {
		if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): request req=%2 for offset=%3 not found in _requests=%4").arg(_id).arg(req).arg(offset).arg(serializereqs(_requests)));
		return loadNext();
	}
	if (result.type() != mtpc_upload_file) {
		if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): bad cons received! %2").arg(_id).arg(result.type()));
		return cancel(true);
	}

	int32 limit = (_locationType == UnknownFileLocation) ? DownloadPartSize : DocumentDownloadPartSize;
	int32 dcIndex = i.value();
	DataRequestedMap[_dc].v[dcIndex] -= limit;

	--_queue->queries;
	_requests.erase(i);

	auto &d = result.c_upload_file();
	auto &bytes = d.vbytes.c_string().v;

	if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): got part with offset=%2, bytes=%3, _queue->queries=%4, _nextRequestOffset=%5, _requests=%6").arg(_id).arg(offset).arg(bytes.size()).arg(_queue->queries).arg(_nextRequestOffset).arg(serializereqs(_requests)));

	if (bytes.size()) {
		if (_fileIsOpen) {
			int64 fsize = _file.size();
			if (offset < fsize) {
				_skippedBytes -= bytes.size();
			} else if (offset > fsize) {
				_skippedBytes += offset - fsize;
			}
			_file.seek(offset);
			if (_file.write(bytes.data(), bytes.size()) != qint64(bytes.size())) {
				return cancel(true);
			}
		} else {
			_data.reserve(offset + bytes.size());
			if (offset > _data.size()) {
				_skippedBytes += offset - _data.size();
				_data.resize(offset);
			}
			if (offset == _data.size()) {
				_data.append(bytes.data(), bytes.size());
			} else {
				_skippedBytes -= bytes.size();
				if (int64(offset + bytes.size()) > _data.size()) {
					_data.resize(offset + bytes.size());
				}
				memcpy(_data.data() + offset, bytes.data(), bytes.size());
			}
		}
	}
	if (!bytes.size() || (bytes.size() % 1024)) { // bad next offset
		_lastComplete = true;
	}
	if (_requests.isEmpty() && (_lastComplete || (_size && _nextRequestOffset >= _size))) {
		if (!_fname.isEmpty() && (_toCache == LoadToCacheAsWell)) {
			if (!_fileIsOpen) _fileIsOpen = _file.open(QIODevice::WriteOnly);
			if (!_fileIsOpen) {
				return cancel(true);
			}
			if (_file.write(_data) != qint64(_data.size())) {
				return cancel(true);
			}
		}
		_type = d.vtype.type();
		_complete = true;
		if (_fileIsOpen) {
			_file.close();
			_fileIsOpen = false;
			psPostprocessFile(QFileInfo(_file).absoluteFilePath());
		}
		removeFromQueue();

		if (!_queue->queries) {
			App::app()->killDownloadSessionsStart(_dc);
		}

		if (_localStatus == LocalNotFound || _localStatus == LocalFailed) {
			if (_locationType != UnknownFileLocation) { // audio, video, document
				MediaKey mkey = mediaKey(_locationType, _dc, _id, _version);
				if (!_fname.isEmpty()) {
					Local::writeFileLocation(mkey, FileLocation(mtpToStorageType(_type), _fname));
				}
				if (_toCache == LoadToCacheAsWell) {
					if (_locationType == DocumentFileLocation) {
						Local::writeStickerImage(mkey, _data);
					} else if (_locationType == AudioFileLocation) {
						Local::writeAudio(mkey, _data);
					}
				}
			} else {
				Local::writeImage(storageKey(*_location), StorageImageSaved(mtpToStorageType(_type), _data));
			}
		}
	} else {
		if (DebugLogging::FileLoader() && _id) DEBUG_LOG(("FileLoader(%1): not done yet, _lastComplete=%2, _size=%3, _nextRequestOffset=%4, _requests=%5").arg(_id).arg(Logs::b(_lastComplete)).arg(_size).arg(_nextRequestOffset).arg(serializereqs(_requests)));
	}
	emit progress(this);
	if (_complete) {
		FileDownload::ImageLoaded().notify();
	}
	loadNext();
}
コード例 #19
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
NormNode* handleNorm(ExpressionNode* expr_to_norm)
{
    NormNode* node = new NormNode(expr_to_norm);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #20
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
UnaryNegationNode* handleUnaryNegation(ExpressionNode* expr_to_negate)
{
    UnaryNegationNode* node = new UnaryNegationNode(expr_to_negate);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #21
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
TrinaryIfNode* handleTrinaryIf(ExpressionNode* predicate, ExpressionNode* iftrue, ExpressionNode* iffalse)
{
    TrinaryIfNode* node = new TrinaryIfNode(predicate, iftrue, iffalse);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #22
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
OnNode* handleExtend(ExpressionNode* left, ExpressionNode* right)
{
    OnNode* node = new OnNode(left, right, true);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #23
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
StringNode* handleString(const std::string& content)
{
    StringNode* node = new StringNode(content);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #24
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
UnitNode* handleUnitOp(BinaryOp op, UnitNode* left, UnitNode* right)
{
    UnitNode* node = new BinaryOpUnitNode(op, left, right);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #25
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
QuantityNode* handleQuantity(NumberNode* number, UnitNode* unit)
{
    QuantityNode* node = new QuantityNode(number, unit);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #26
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
UnitNode* handleUnit(const std::string& name)
{
    UnitNode* node = new BasicUnitNode(name);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #27
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
RandomAccessNode* handleRandomAccess(ExpressionNode* expr, const int index)
{
    RandomAccessNode* node = new RandomAccessNode(expr, index);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #28
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
LoopNode* handleLoopStart(const std::string& loop_variable, const std::string& loop_set)
{
    LoopNode* node = new LoopNode(loop_variable, loop_set);
    node->setLocation(FileLocation(yylineno));
    return node;
}
コード例 #29
0
ファイル: mtpFileLoader.cpp プロジェクト: neuroidss/tdesktop
void mtpFileLoader::partLoaded(int32 offset, const MTPupload_File &result, mtpRequestId req) {
//	uint64 ms = getms();
	Requests::iterator i = requests.find(req);
	if (i == requests.cend()) return loadNext();

	int32 limit = (_locationType == UnknownFileLocation) ? DownloadPartSize : DocumentDownloadPartSize;
	int32 dcIndex = i.value();
	_dataRequested[dc].v[dcIndex] -= limit;

	--queue->queries;
	requests.erase(i);

	const MTPDupload_file &d(result.c_upload_file());
	const string &bytes(d.vbytes.c_string().v);
	if (bytes.size()) {
		if (fileIsOpen) {
			int64 fsize = file.size();
			if (offset < fsize) {
				skippedBytes -= bytes.size();
			} else if (offset > fsize) {
				skippedBytes += offset - fsize;
			}
			file.seek(offset);
			if (file.write(bytes.data(), bytes.size()) != qint64(bytes.size())) {
				return finishFail();
			}
		} else {
			data.reserve(offset + bytes.size());
			if (offset > data.size()) {
				skippedBytes += offset - data.size();
				data.resize(offset);
			}
			if (offset == data.size()) {
				data.append(bytes.data(), bytes.size());
			} else {
				skippedBytes -= bytes.size();
				if (int64(offset + bytes.size()) > data.size()) {
					data.resize(offset + bytes.size());
				}
				memcpy(data.data() + offset, bytes.data(), bytes.size());
			}
		}
	}
	if (!bytes.size() || (bytes.size() % 1024)) { // bad next offset
		lastComplete = true;
	}
	if (requests.isEmpty() && (lastComplete || (size && nextRequestOffset >= size))) {
		if (!fname.isEmpty() && duplicateInData) {
			if (!fileIsOpen) fileIsOpen = file.open(QIODevice::WriteOnly);
			if (!fileIsOpen) {
				return finishFail();
			}
			if (file.write(data) != qint64(data.size())) {
				return finishFail();
			}
		}
		type = d.vtype.type();
		complete = true;
		if (fileIsOpen) {
			file.close();
			fileIsOpen = false;
			psPostprocessFile(QFileInfo(file).absoluteFilePath());
		}
		removeFromQueue();

		emit App::wnd()->imageLoaded();

		if (!queue->queries) {
			App::app()->killDownloadSessionsStart(dc);
		}

		if (_localStatus == LocalNotFound || _localStatus == LocalFailed) {
			if (_locationType != UnknownFileLocation) { // audio, video, document
				MediaKey mkey = mediaKey(_locationType, dc, id);
				if (!fname.isEmpty()) {
					Local::writeFileLocation(mkey, FileLocation(mtpToStorageType(type), fname));
				}
				if (duplicateInData) {
					if (_locationType == DocumentFileLocation) {
						Local::writeStickerImage(mkey, data);
					} else if (_locationType == AudioFileLocation) {
						Local::writeAudio(mkey, data);
					}
				}
			} else {
				Local::writeImage(storageKey(dc, volume, local), StorageImageSaved(mtpToStorageType(type), data));
			}
		}
	}
	emit progress(this);
	loadNext();
}
コード例 #30
0
ファイル: ParseActions.cpp プロジェクト: atgeirr/equelle
ArrayNode* handleArray(FuncArgsNode* expr_list)
{
    ArrayNode* node = new ArrayNode(expr_list);
    node->setLocation(FileLocation(yylineno));
    return node;
}