diff --git a/.gitignore b/.gitignore index b7c4cca..eb89f3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,79 +1,92 @@ # Compiled Object files *.slo *.lo *.o *.obj # Compiled Dynamic libraries *.so *.so.* *.dylib *.dll # Compiled Static libraries *.lai *.la *.a *.lib # Executables *.exe *.out *.app *.class # Mobile Tools for Java (J2ME) .mtj.tmp/ # Package Files # *.jar *.war *.ear # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* # Qt-es /.qmake.cache /.qmake.stash *.pro.user *.pro.user.* *.moc moc_*.cpp qrc_*.cpp ui_*.h Makefile* *-build-* # QtCreator *.autosave coco/*.old coco/*~ *~ cpp/build-*/* cpp/xreate-debug/* cpp/xreate-release/* cpp/.idea -cpp/CMakeLists.txt.user* -hs/* +CMakeLists.txt.user +cmake_install.cmake project/* nb*.xml .* target/* /tools/phabricator/xreate-frontend/nbproject/private/ documentation/trash4/ trash/ CMakeFiles/ gen-cpp/ generated-cpp/ gen-php/ generated-js/ books/ build/ coco/Parser.* coco/Scanner.* + +cpp/src/compilation/latecontextcompiler.cpp +cpp/src/compilation/latecontextcompiler.h +cpp/src/pass/environmenttestspass.cpp +cpp/src/pass/environmenttestspass.h +cpp/src/query/ptrvalid.cpp +cpp/src/query/ptrvalid.h +cpp/tests/deferred/ +cpp/tests/vendorAPI/ + +installation/ +scripts/metatests/ +tools/phabricator/administration/ diff --git a/config/default.json b/config/default.json index ff649b1..f72b68e 100644 --- a/config/default.json +++ b/config/default.json @@ -1,73 +1,73 @@ { "containers": { "id": { "implementations": "impl_fulfill_cluster", "clusters": "var_cluster", "prototypes": "proto_cluster", "linkedlist": "linkedlist" }, "impl": { "solid": "solid", "onthefly": "on_the_fly" } }, "logging": { "id": "logging" }, "function-entry": "entry", "clasp": { "bindings" : { "variable": "bind", "function": "bind_func", "scope": "bind_scope", "function_demand" : "bind_function_demand", "scope_decision": "bind_scope_decision" }, "context" : { "decisions":{ "dependent": "resolution_dependency" }, }, "nonevalue": "nonevalue", "ret": { "symbol": "retv", "tag": "ret" } }, "tests": { "template": "containers", "templates": { "default": "*-", "basic": "Basic.*", "ast": "AST.*", "cfa": "CFA.*", "dfa": "DFA.*", "compilation": "Compilation.*", - "containers": "Containers*-", + "containers": "Containers.ListAsArray2-", "diagnostic": "Diagnostic.*", "serializer": "ExpressionSerializer.*", "externc": "InterfaceExternC.*", "context": "ExpressionSerializer.*:Context.*", "types": "Types.*-", "log": "Logging*", "clang": "ClangAPI.*", "skip": "SkipDetection*:Adhoc_Loop_SkipDetection.*", "raw-xml": "libxml2*", "xml": "Xml.*", "installation": "Compilation.*:Sprint1.*", "exploitation": "Exploitation.*", "loops": "Loop.*", "dsl": "Interpretation.*", "adhocs": "Adhoc.*", } } } diff --git a/core/containers.lp b/core/containers.lp index 876c7c9..63b7269 100644 --- a/core/containers.lp +++ b/core/containers.lp @@ -1,57 +1,58 @@ %defines impl(solid; on_the_fly; linked_list). op(seqaccess; randaccess). relation(recommends; satisfied; unsupported). relation_score(satisfied, 0). relation_score(recommends, 1). relation_score(unsupported, -1). score(-1..1). %domain facts: relation_op(seqaccess, on_the_fly, recommends). + relation_op(randaccess, solid, recommends). relation_op(randaccess, on_the_fly, unsupported). %dfa analysis: %scheme: dfa_connection(Vto, Vfrom, proto); %-- dfa_connection(VTo, VFrom, alias); %-- dfa_connection(VFormal, VActual, arg); %-- dfa_connection(VActual, VFormal, ret) %compilation: %-- %domain rules: %aliases: var_origin(VAR) :- not dfa_connection(VAR, _, alias), v(VAR). var_alias(VAR0, VAR_TO) :- dfa_connection(VAR_TO, VAR0, alias), var_origin(VAR0). var_alias(VAR0, VAR_TO2) :- dfa_connection(VAR_TO2, VAR_TO1, alias), var_alias(VAR0, VAR_TO1). var_alias(VAR0, VAR0):- var_origin(VAR0). %prototypes: var_proto(V0, Vproto) :- var_origin(V0); var_origin(Vproto); var_alias(Vproto, Vp); dfa_connection(V0, Vp, proto). %implementations: -impl_fulfill(OP, IMPL) :- relation_op(OP, IMPL, unsupported). impl_fulfill(OP, IMPL, SCORE):- SCORE = #sum{SCORE1, (OP, IMPL, RL): relation_op(OP, IMPL, RL),relation_score(RL, SCORE1)} ; op(OP); impl(IMPL); not -impl_fulfill(OP, IMPL). -var_impl_fulfill(Var0, Impl) :- var_alias(Var0, Var_Any); bind(Var_Any, op(Op)); -impl_fulfill(Op, Impl). var_impl_fulfill(VAR0, IMPL, Score) :- Score = #sum{SCORE, (OP, IMPL, VAR_ANY): impl_fulfill(OP, IMPL, SCORE), var_alias(VAR0, VAR_ANY), bind(VAR_ANY, op(OP))} ; bind(VAR0, impl(IMPL)); var_origin(VAR0); not -var_impl_fulfill(VAR0, IMPL). %transfunction implementation: %bind(Vactual, op(Op)) :- var_alias(Vformal, V1); bind(V1, op(Op)); dfa_connection(Vformal, Vactual, arg); op(Op). %bind(Vactual, op(Op)) :- var_alias(VO, Vformal); var_alias(VO, V); bind(V, op(Op)); dfa_connection(Vactual,Vformal, ret); op(Op). % --uncomment to add possible implementations(impl) to an actual var %bind(Vres, op(Op)) :- var_alias(VO, VA); bind(VA, op(Op)); dfa_connection(VArg,VO, result); op(Op). %optimization % #maximize {SCORE, (VAR0, IMPL) : var_impl_fulfill(VAR0, IMPL, SCORE)}. #show var_alias/2. #show var_impl_fulfill/3. #show proto_alias2. diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 4d5f6c6..764079d 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -1,34 +1,34 @@ cmake_minimum_required(VERSION 2.8.11) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall -fprofile-arcs -ftest-coverage -O0") set(CMAKE_BUILD_TYPE Debug) # BUILD OPTIONS #====================== set(XREATE_DEFINITIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DWITH_THREADS=1 ) add_definitions(${XREATE_DEFINITIONS}) -add_compile_options(-Winvalid-pch -fPIC) +add_compile_options(-Winvalid-pch -fPIC -std=c++11) # XREATE #====================== add_subdirectory(src) # XREATE-TESTS #====================== if (BUILD_XREATE_TESTS) message ("Building xreate tests") add_subdirectory(tests) endif () # XREATE-SERVER #====================== if (BUILD_XREATE_SERVER) message ("Building xreate server") add_subdirectory(../tools/execution-server execution-server) endif () diff --git a/cpp/code-coverage.sh b/cpp/code-coverage.sh deleted file mode 100755 index a1ee2de..0000000 --- a/cpp/code-coverage.sh +++ /dev/null @@ -1,2 +0,0 @@ -lcov --capture --directory ./ --output-file coverage.info -genhtml coverage.info --output-directory coverage-report diff --git a/cpp/src/compilation/advanced.cpp b/cpp/src/compilation/advanced.cpp index 600dfdf..d49ede8 100644 --- a/cpp/src/compilation/advanced.cpp +++ b/cpp/src/compilation/advanced.cpp @@ -1,437 +1,432 @@ /* * File: InstructionsAdvanced.cpp * Author: pgess * * Created on June 26, 2016, 6:00 PM */ #include #include "compilation/advanced.h" #include "compilation/containers.h" #include "query/context.h" #include "query/containers.h" -#include "query/ptrvalid.h" - #include "llvmlayer.h" #include "ast.h" using namespace std; using namespace llvm; using namespace xreate; using namespace xreate::containers; using namespace xreate::compilation; #define NAME(x) (hintRetVar.empty()? x : hintRetVar) #define UNUSED(x) (void)(x) #define EXPAND_CONTEXT \ LLVMLayer* llvm = context.pass->man->llvm; \ compilation::CodeScopeUnit* scope = context.scope; \ compilation::FunctionUnit* function = context.function; Advanced::Advanced(compilation::Context ctx) : context(ctx), tyNum(static_cast (ctx.pass->man->llvm->toLLVMType(ExpandedType(TypeAnnotation(TypePrimitive::Num))))) { } llvm::Value* Advanced::compileMapSolidOutput(const Expression &expr, const std::string hintRetVar) { EXPAND_CONTEXT //initialization std::string varIn = expr.getOperands()[0].getValueString(); Symbol symbolIn = scope->scope->findSymbol(varIn); ImplementationRec implIn = containers::Query::queryImplementation(symbolIn).extract(); // impl of input list size_t size = implIn.size; CodeScope* scopeLoop = expr.blocks.front(); std::string varEl = scopeLoop->__bindings[0]; Iterator* it = Iterator::create(context, symbolIn); llvm::Value *rangeFrom = it->begin(); llvm::Value *rangeTo = it->end(); //definitions ArrayType* tyNumArray = (ArrayType*) (llvm->toLLVMType(ExpandedType(TypeAnnotation(tag_array, TypePrimitive::Num, size)))); llvm::IRBuilder<> &builder = llvm->builder; llvm::BasicBlock *blockLoop = llvm::BasicBlock::Create(llvm::getGlobalContext(), "loop", function->raw); llvm::BasicBlock *blockBeforeLoop = builder.GetInsertBlock(); llvm::BasicBlock *blockAfterLoop = llvm::BasicBlock::Create(llvm::getGlobalContext(), "postloop", function->raw); Value* dataOut = llvm->builder.CreateAlloca(tyNumArray, ConstantInt::get(tyNum, size), NAME("map")); // * initial check Value* condBefore = builder.CreateICmpSLE(rangeFrom, rangeTo); builder.CreateCondBr(condBefore, blockLoop, blockAfterLoop); // create PHI: builder.SetInsertPoint(blockLoop); llvm::PHINode *stateLoop = builder.CreatePHI(tyNum, 2, "mapIt"); stateLoop->addIncoming(rangeFrom, blockBeforeLoop); // loop body: Value* elIn = it->get(stateLoop, varEl); compilation::CodeScopeUnit* scopeLoopUnit = function->getScopeUnit(scopeLoop); scopeLoopUnit->bindArg(elIn, move(varEl)); Value* elOut = scopeLoopUnit->compile(); Value *pElOut = builder.CreateGEP(dataOut, ArrayRef(std::vector{ConstantInt::get(tyNum, 0), stateLoop})); builder.CreateStore(elOut, pElOut); //next iteration preparing Value *stateLoopNext = builder.CreateAdd(stateLoop, llvm::ConstantInt::get(tyNum, 1)); stateLoop->addIncoming(stateLoopNext, blockLoop); //next iteration checks: Value* condAfter = builder.CreateICmpSLE(stateLoopNext, rangeTo); builder.CreateCondBr(condAfter, blockLoop, blockAfterLoop); //finalization: builder.SetInsertPoint(blockAfterLoop); return dataOut; } Value* Advanced::compileArrayIndex(llvm::Value* aggregate, std::vector indexes, std::string hintRetVar) { EXPAND_CONTEXT UNUSED(function); indexes.insert(indexes.begin(), llvm::ConstantInt::get(tyNum, 0)); llvm::Value *pEl = llvm->builder.CreateGEP(aggregate, llvm::ArrayRef(indexes)); return llvm->builder.CreateLoad(pEl, NAME("el")); } Value* Advanced::compileStructIndex(llvm::Value* aggregate, const ExpandedType& t, const std::string& idx) { EXPAND_CONTEXT UNUSED(scope); TypeUtils types(llvm); std::vector&& fields = types.getStructFields(t); for (unsigned i = 0, size = fields.size(); i < size; ++i) { if (fields.at(i) == idx) { std::vector refs; llvm::IntegerType* tyInt = llvm::Type::getInt32Ty(llvm::getGlobalContext()); llvm::ConstantInt* zero = llvm::ConstantInt::get(tyInt, 0, false); llvm::BasicBlock *blockSafe = llvm::BasicBlock::Create(llvm::getGlobalContext(), "safe", function->raw); - // TODO review safety check: not null ptr + // TODO review safety check: validPtr for `aggregate` // SECTIONTAG validptr exception - Symbol s; - if (!QueryPtrValid::assertValidPtr(s)) { - PointerType* tyAggr = dyn_cast(aggregate->getType()); - llvm::Value* null = llvm::ConstantPointerNull::get(tyAggr); - Value* condNull = llvm->builder.CreateICmpNE(aggregate, null); - - llvm::BasicBlock *blockException = llvm::BasicBlock::Create(llvm::getGlobalContext(), "exception", function->raw); - llvm->builder.CreateCondBr(condNull, blockSafe, blockException); - llvm->initExceptionBlock(blockException); - } + PointerType* tyAggr = dyn_cast(aggregate->getType()); + llvm::Value* null = llvm::ConstantPointerNull::get(tyAggr); + Value* condNull = llvm->builder.CreateICmpNE(aggregate, null); + + llvm::BasicBlock *blockException = llvm::BasicBlock::Create(llvm::getGlobalContext(), "exception", function->raw); + llvm->builder.CreateCondBr(condNull, blockSafe, blockException); + llvm->initExceptionBlock(blockException); llvm->builder.SetInsertPoint(blockSafe); std::vector indexes; //dereference pointer if (types.isPointer(t)) { indexes.push_back(zero); } indexes.push_back(ConstantInt::get(tyInt, i)); Value* addr = llvm->builder.CreateGEP(aggregate, indexes); return llvm->builder.CreateLoad(addr); } } assert(false && "not found required struct field"); return nullptr; } llvm::Value* Advanced::compileFold(const Expression& fold, const std::string& hintRetVar) { EXPAND_CONTEXT assert(fold.op == Operator::FOLD); //initialization: Symbol varInSymbol = scope->scope->findSymbol(fold.getOperands()[0].getValueString()); Implementation info = Query::queryImplementation(varInSymbol); Iterator* it = Iterator::create(context, varInSymbol); llvm::Value* rangeBegin = it->begin(); llvm::Value* rangeEnd = it->end(); llvm::Value* accumInit = scope->process(fold.getOperands()[1]); std::string varIn = fold.getOperands()[0].getValueString(); std::string varAccum = fold.bindings[1]; std::string varEl = fold.bindings[0]; TransformerSaturation* transformerSaturation = context.pass->transformations->get(); llvm::BasicBlock *blockBeforeLoop = llvm->builder.GetInsertBlock(); llvm::BasicBlock *blockLoop = llvm::BasicBlock::Create(llvm::getGlobalContext(), "fold", function->raw); llvm::BasicBlock *blockBody = llvm::BasicBlock::Create(llvm::getGlobalContext(), "body", function->raw); llvm::BasicBlock *blockAfterLoop = llvm::BasicBlock::Create(llvm::getGlobalContext(), "postfold", function->raw); llvm->builder.CreateBr(blockLoop); // * create phi llvm->builder.SetInsertPoint(blockLoop); llvm::PHINode *accum = llvm->builder.CreatePHI(accumInit->getType(), 2, NAME("accum")); accum->addIncoming(accumInit, blockBeforeLoop); llvm::PHINode *itLoop = llvm->builder.CreatePHI(rangeBegin->getType(), 2, "foldIt"); itLoop->addIncoming(rangeBegin, blockBeforeLoop); // * loop body llvm->builder.SetInsertPoint(blockBody); CodeScope* scopeLoop = fold.blocks.front(); compilation::CodeScopeUnit* loopUnit = function->getScopeUnit(scopeLoop); Value* elIn = it->get(itLoop); loopUnit->bindArg(accum, move(varAccum)); loopUnit->bindArg(elIn, move(varEl)); Value* accumNext = loopUnit->compile(); // * computing next iteration state Value *itLoopNext = it->advance(itLoop); accum->addIncoming(accumNext, llvm->builder.GetInsertBlock()); itLoop->addIncoming(itLoopNext, llvm->builder.GetInsertBlock()); llvm->builder.CreateBr(blockLoop); // * break checks, continue checks //!! only after compiled Loop Body in order to fetch saturation expression llvm->builder.SetInsertPoint(blockLoop); if (transformerSaturation->exists()) { transformerSaturation->inject(blockBeforeLoop, blockAfterLoop, context); } // * next iteration checks Value* condRange = llvm->builder.CreateICmpNE(itLoop, rangeEnd); llvm->builder.CreateCondBr(condRange, blockBody, blockAfterLoop); // finalization: llvm->builder.SetInsertPoint(blockAfterLoop); return accum; } llvm::Value* Advanced::compileFoldInf(const Expression& fold, const std::string& hintRetVar) { EXPAND_CONTEXT assert(fold.op == Operator::FOLD_INF); std::string accumName = fold.bindings[0]; llvm::Value* accumInit = scope->process(fold.getOperands()[0]); llvm::BasicBlock *blockBeforeLoop = llvm->builder.GetInsertBlock(); llvm::BasicBlock *blockLoop = llvm::BasicBlock::Create(llvm::getGlobalContext(), "fold", function->raw); llvm::BasicBlock *blockBody = llvm::BasicBlock::Create(llvm::getGlobalContext(), "body", function->raw); llvm::BasicBlock *blockAfterLoop = llvm::BasicBlock::Create(llvm::getGlobalContext(), "postfold", function->raw); TransformerSaturation* transformerSaturation = context.pass->transformations->get(); llvm->builder.CreateBr(blockLoop); // * create phi llvm->builder.SetInsertPoint(blockLoop); llvm::PHINode *accum = llvm->builder.CreatePHI(accumInit->getType(), 2, NAME("accum")); accum->addIncoming(accumInit, blockBeforeLoop); // * loop body llvm->builder.SetInsertPoint(blockBody); CodeScope* scopeLoop = fold.blocks.front(); compilation::CodeScopeUnit* unitLoop = function->getScopeUnit(scopeLoop); unitLoop->bindArg(accum, move(accumName)); Value* accumNext = unitLoop->compile(); // * computing next iteration state accum->addIncoming(accumNext, llvm->builder.GetInsertBlock()); llvm->builder.CreateBr(blockLoop); // * break checks, continue checks assert(transformerSaturation->exists()); llvm->builder.SetInsertPoint(blockLoop); transformerSaturation->inject(blockBeforeLoop, blockAfterLoop, context); llvm->builder.CreateBr(blockBody); // finalization: llvm->builder.SetInsertPoint(blockAfterLoop); return accum; } llvm::Value* Advanced::compileLoopContext(const Expression& expression, const std::string& hintRetVar) { EXPAND_CONTEXT llvm::IRBuilder<>& builder = llvm->builder; ContextQuery* queryContext = reinterpret_cast (context.pass->man->clasp->getQuery(QueryId::ContextQuery)); ScopePacked scopeOuterId = context.pass->man->clasp->pack(scope->scope); const Domain& contextScopeOuter = queryContext->getContext(scopeOuterId); std::string classSelected = expression.operands[0].getValueString(); std::list elementsSelected; for (const Expression& c : contextScopeOuter) { if (c.op == Operator::CALL && c.getValueString() == classSelected) { assert(c.operands.size()); elementsSelected.push_back(c.operands[0]); } } assert(expression.blocks.size()); CodeScope* scopeInner = expression.blocks.front(); compilation::CodeScopeUnit* scopeInnerUnit = function->getScopeUnit(scopeInner); ScopePacked scopeInnerId = context.pass->man->clasp->pack(scopeInner); llvm::Value* result = nullptr; for (const Expression& element : elementsSelected) { std::string blockName = "context" + element.getValueString(); llvm::BasicBlock *blockInner = llvm::BasicBlock::Create(llvm::getGlobalContext(), blockName, function->raw); builder.CreateBr(blockInner); builder.SetInsertPoint(blockInner); queryContext->forceContext(scopeInnerId,{element}); scopeInnerUnit->reset(); result = scopeInnerUnit->compile(); } return result; } llvm::Value* Advanced::compileIf(const Expression& exprIf, const std::string& hintRetVar) { EXPAND_CONTEXT //initialization: const Expression& condExpr = exprIf.getOperands()[0]; llvm::IRBuilder<>& builder = llvm->builder; llvm::Type* tyResultType = llvm->toLLVMType(llvm->ast->expandType(exprIf.type)); llvm::BasicBlock *blockAfter = llvm::BasicBlock::Create(llvm::getGlobalContext(), "ifAfter", function->raw); llvm::BasicBlock *blockTrue = llvm::BasicBlock::Create(llvm::getGlobalContext(), "ifTrue", function->raw); llvm::BasicBlock *blockFalse = llvm::BasicBlock::Create(llvm::getGlobalContext(), "ifFalse", function->raw); llvm::Value* cond = scope->process(condExpr); llvm->builder.CreateCondBr(cond, blockTrue, blockFalse); builder.SetInsertPoint(blockTrue); CodeScope* scopeTrue = exprIf.blocks.front(); llvm::Value* resultTrue = function->getScopeUnit(scopeTrue)->compile(); builder.CreateBr(blockAfter); builder.SetInsertPoint(blockFalse); CodeScope* scopeFalse = exprIf.blocks.back(); llvm::Value* resultFalse = function->getScopeUnit(scopeFalse)->compile(); builder.CreateBr(blockAfter); builder.SetInsertPoint(blockAfter); llvm::PHINode *ret = builder.CreatePHI(tyResultType, 2, NAME("if")); ret->addIncoming(resultTrue, blockTrue); ret->addIncoming(resultFalse, blockFalse); return ret; } //TODO Switch: default variant no needed when all possible conditions are considered llvm::Value* Advanced::compileSwitch(const Expression& exprSwitch, const std::string& hintRetVar) { EXPAND_CONTEXT UNUSED(function); assert(exprSwitch.operands.size() >= 2); assert(exprSwitch.operands[1].op == Operator::CASE_DEFAULT && "No default case in Switch Statement"); int countCases = exprSwitch.operands.size() - 1; llvm::IRBuilder<>& builder = llvm->builder; llvm::BasicBlock* blockProlog = builder.GetInsertBlock(); llvm::BasicBlock *blockEpilog = llvm::BasicBlock::Create(llvm::getGlobalContext(), "switchAfter", function->raw); builder.SetInsertPoint(blockEpilog); llvm::Type* exprSwitchType = llvm->toLLVMType(ExpandedType(exprSwitch.type)); llvm::PHINode *ret = builder.CreatePHI(exprSwitchType, countCases, NAME("switch")); builder.SetInsertPoint(blockProlog); llvm::Value * conditionSwitch = scope->process(exprSwitch.operands[0]); llvm::BasicBlock *blockDefault = llvm::BasicBlock::Create(llvm::getGlobalContext(), "caseDefault", function->raw); llvm::SwitchInst * instructionSwitch = builder.CreateSwitch(conditionSwitch, blockDefault, countCases); for (int size = exprSwitch.operands.size(), i = 2; i < size; ++i) { llvm::BasicBlock *blockCase = llvm::BasicBlock::Create(llvm::getGlobalContext(), "case" + std::to_string(i), function->raw); llvm::Value* condCase = function->getScopeUnit(exprSwitch.operands[i].blocks.front())->compile(); builder.SetInsertPoint(blockCase); llvm::Value* resultCase = function->getScopeUnit(exprSwitch.operands[i].blocks.back())->compile(); builder.CreateBr(blockEpilog); ret->addIncoming(resultCase, builder.GetInsertBlock()); builder.SetInsertPoint(blockProlog); instructionSwitch->addCase(dyn_cast(condCase), blockCase); } //compile default block: builder.SetInsertPoint(blockDefault); CodeScope* scopeDefault = exprSwitch.operands[1].blocks.front(); llvm::Value* resultDefault = function->getScopeUnit(scopeDefault)->compile(); builder.CreateBr(blockEpilog); ret->addIncoming(resultDefault, builder.GetInsertBlock()); builder.SetInsertPoint(blockEpilog); return ret; } //TODO recognize cases to make const arrays/stored in global mem/stack alloced. llvm::Value* Advanced::compileListAsSolidArray(const Expression &expr, const std::string& hintRetVar) { EXPAND_CONTEXT UNUSED(scope); UNUSED(function); AST* root = context.pass->man->root; const size_t& length = expr.getOperands().size(); const Expression& expression = expr; llvm::Value* zero = ConstantInt::get(tyNum, 0); llvm::Value* one = ConstantInt::get(tyNum, 1); ExpandedType typAggrExpanded = root->expandType(expression.type); assert(typAggrExpanded->__operator == TypeOperator::ARRAY); llvm::Type* typEl = llvm->toLLVMType(ExpandedType(typAggrExpanded->__operands[0])); ArrayType* typAggr = (ArrayType*) llvm::ArrayType::get(typEl, length); llvm::Value* list = llvm->builder.CreateAlloca(typAggr, ConstantInt::get(Type::getInt32Ty(llvm::getGlobalContext()), length, false), hintRetVar); const std::vector& operands = expression.getOperands(); llvm::Value* addrOperand = llvm->builder.CreateGEP(typAggr, list, ArrayRef(std::vector{zero, zero})); llvm->builder.CreateStore(scope->process(operands.front()), addrOperand) ; for (auto i=++operands.begin(); i!=operands.end(); ++i){ addrOperand = llvm->builder.CreateGEP(typEl, addrOperand, ArrayRef(std::vector{one})); llvm->builder.CreateStore(scope->process(*i), addrOperand) ; } return list; // Value* listDest = l.builder.CreateAlloca(typList, ConstantInt::get(typI32, __size), *hintRetVar); // l.buil1der.CreateMemCpy(listDest, listSource, __size, 16); } llvm::Value* Advanced::compileConstantStringAsPChar(const string& data, const std::string& hintRetVar) { EXPAND_CONTEXT UNUSED(function); UNUSED(scope); Type* typPchar = PointerType::getUnqual(Type::getInt8Ty(llvm::getGlobalContext())); //ArrayType* typStr = (ArrayType*) (llvm->toLLVMType(ExpandedType(TypeAnnotation(tag_array, TypePrimitive::I8, size+1)))); /* std::vector chars; chars.reserve(size+1); for (size_t i=0; i< size; ++i){ chars[i] = ConstantInt::get(typI8, (unsigned char) data[i]); } chars[size] = ConstantInt::get(typI8, 0); */ Value* rawData = ConstantDataArray::getString(llvm::getGlobalContext(), data); Value* rawPtrData = llvm->builder.CreateAlloca(rawData->getType(), ConstantInt::get(Type::getInt32Ty(llvm::getGlobalContext()), 1, false)); llvm->builder.CreateStore(rawData, rawPtrData); return llvm->builder.CreateCast(llvm::Instruction::BitCast, rawPtrData, typPchar, hintRetVar); } diff --git a/cpp/src/compilation/containers.h b/cpp/src/compilation/containers.h index 681396c..222be75 100644 --- a/cpp/src/compilation/containers.h +++ b/cpp/src/compilation/containers.h @@ -1,81 +1,80 @@ #ifndef CODEINSTRUCTIONS_H #define CODEINSTRUCTIONS_H #include "ast.h" #include "llvmlayer.h" #include "pass/compilepass.h" #include "compilation/advanced.h" #include "query/context.h" #include "query/containers.h" -#include "query/ptrvalid.h" namespace xreate { namespace containers { using namespace llvm; class Iterator{ public : virtual llvm::Value* begin() =0; virtual llvm::Value* end() = 0; virtual llvm::Value* get(llvm::Value* index,const std::string& hintRetVar="") = 0; virtual llvm::Value* advance(llvm::Value* index, const std::string& hintRetVar="")=0; virtual ~Iterator(){}; static Iterator* create(xreate::compilation::Context context, const xreate::Symbol& var); }; template class IteratorForward; template<> class IteratorForward : public Iterator { private: LLVMLayer* llvm; const xreate::Symbol current; const Symbol source; const ImplementationLinkedList linkedlist; CodeScope* const sourceScope; //TODO initialize and mark as const (three fields) compilation::CodeScopeUnit* sourceUnit; compilation::FunctionUnit* function; //TODO is used somewhere? const Expression& sourceDecl; compilation::Context context; llvm::Type* sourceRawType =nullptr; public: IteratorForward(const compilation::Context& ctx, const xreate::Symbol& s, const ImplementationRec& implementation) : llvm(ctx.pass->man->llvm), current(s), source(implementation.source), linkedlist(source), sourceScope(source.scope), sourceUnit(new compilation::CodeScopeUnit(source.scope, ctx.function, ctx.pass)), sourceDecl(CodeScope::findDeclaration(source)), context(ctx) {} llvm::Value* begin() override; llvm::Value* end() override; llvm::Value* get(llvm::Value* index,const std::string& hintRetVar="") override; llvm::Value* advance(llvm::Value* index, const std::string& hintRetVar="") override; }; template<> class IteratorForward: public Iterator{ size_t __length; llvm::Value* __container; LLVMLayer* llvm; public: IteratorForward(const compilation::Context& ctx, const xreate::Symbol& symbolContainer, const ImplementationRec& implementation); llvm::Value* begin() override; llvm::Value* end() override; llvm::Value* get(llvm::Value* index,const std::string& hintRetVar="") override; llvm::Value* advance(llvm::Value* index, const std::string& hintRetVar="") override; }; }} #endif //CODEINSTRUCTIONS_H diff --git a/cpp/tests/containers.cpp b/cpp/tests/containers.cpp index 55e89eb..9d044d5 100644 --- a/cpp/tests/containers.cpp +++ b/cpp/tests/containers.cpp @@ -1,92 +1,96 @@ /* * containers.cpp * * Created on: Jun 9, 2015 * Author: pgess */ #include "passmanager.h" #include "query/containers.h" #include "Parser.h" #include "gtest/gtest.h" using namespace std; using namespace xreate; using namespace containers; TEST(Containers, ListAsArray){ PassManager* man = PassManager::prepareForCode( R"Code( main = function(x:: int):: int;entry { a = [1, 2, 3]:: [int]. a[x] } )Code" ); void* mainPtr = man->run(); int (*main)(int) = (int (*)(int))mainPtr; ASSERT_EQ(2, main(1)); delete man; } TEST(Containers, ListAsArray2){ PassManager* man = PassManager::prepareForCode( R"Code( main = function:: int;entry { a= [1, 2, 3]:: [int]. b= loop map(a->el:: int):: [int]{ 2 * el }. - b[1] - 4 + sum = loop fold(b->el:: int, 0->acc):: int { + acc + el + }. + + sum } )Code" ); void* mainPtr = man->run(); int (*main)() = (int (*)())mainPtr; ASSERT_EQ(0, main()); delete man; } TEST(Containers, ContanierLinkedList1){ FILE* input = fopen("scripts/testspass/Containers_Implementation_LinkedList1.xreate","r"); assert(input != nullptr); Scanner scanner(input); Parser parser(&scanner); parser.Parse(); AST& ast = parser.root; CodeScope* body = ast.findFunction("test")->getEntryScope(); Symbol symb_chilrenRaw = body->findSymbol("childrenRaw"); containers::ImplementationLinkedList iLL(symb_chilrenRaw); ASSERT_EQ(true, static_cast(iLL)); ASSERT_EQ("next", iLL.fieldPointer); Implementation impl = Implementation::create(symb_chilrenRaw); ASSERT_NO_FATAL_FAILURE(impl.extract()); ImplementationRec recOnthefly = impl.extract(); ASSERT_EQ(symb_chilrenRaw, recOnthefly.source); } TEST(Containers, Implementation_LinkedListFull){ FILE* input = fopen("scripts/testspass/Containers_Implementation_LinkedList1.xreate","r"); assert(input != nullptr); std::unique_ptr program(PassManager::prepareForCode(input)); void* mainPtr = program->run(); int (*main)() = (int (*)())(intptr_t)mainPtr; int answer = main(); ASSERT_EQ(17, answer); fclose(input); } diff --git a/documentation-tools/RemarkupParser/tests/main.cpp b/documentation-tools/RemarkupParser/tests/main.cpp new file mode 100644 index 0000000..5361187 --- /dev/null +++ b/documentation-tools/RemarkupParser/tests/main.cpp @@ -0,0 +1,46 @@ +#include + +#include +#include +#include + +#include "gen-cpp/PhabricatorParserPrivate.h" + +using namespace std; +using namespace apache::thrift; +using namespace apache::thrift::protocol; +using namespace apache::thrift::transport; + +int main() { + boost::shared_ptr socket(new TSocket("/tmp/phabricator-parser")); + boost::shared_ptr transport(new TBufferedTransport(socket)); + boost::shared_ptr protocol(new TBinaryProtocol(transport)); + PhabricatorParserPrivateClient client(protocol); + + string text = +"= Large Header = \n \ + \n\ +== Smaller Header == \n\ + \n\ +## This is a Header As Well\n\ + \n\ +Also a Large Header \n\ +=================== \n\ + \n\ +Also a Smaller Header \n\ +---------------------"; + try { + transport->open(); + + + for (int i=0; i + + + + + diff --git a/documentation-tools/conduit-client/tests/CMakeLists.txt b/documentation-tools/conduit-client/tests/CMakeLists.txt new file mode 100644 index 0000000..b86387e --- /dev/null +++ b/documentation-tools/conduit-client/tests/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 2.8.11) +project(conduit-client-tests) +set(CMAKE_BUILD_TYPE Debug) +set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -Wall -O0 --std=c++11") + +find_package(GTest REQUIRED) +INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS}) + +find_package ( Qt5 COMPONENTS Core Network ) + +set(LIB_INSTALL_DIR + ${CMAKE_CURRENT_BINARY_DIR}/conduit-client/ + + CACHE INTERNAL "install dir" FORCE +) + +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/conduit-client) +INCLUDE_DIRECTORIES(${CONDUIT_CLIENT_INCLUDE_PATH}) + +# TESTS +#========================= +aux_source_directory(. TEST_FILES) +add_executable(${PROJECT_NAME} ${TEST_FILES}) +target_link_libraries(${PROJECT_NAME} conduitclient ${GTEST_LIBRARIES} Qt5::Core Qt5::Network) diff --git a/documentation-tools/conduit-client/tests/main.cpp b/documentation-tools/conduit-client/tests/main.cpp new file mode 100644 index 0000000..6c9fca8 --- /dev/null +++ b/documentation-tools/conduit-client/tests/main.cpp @@ -0,0 +1,26 @@ +#include +#include + +#include "phrictionclient.h" + +using namespace std; + +TEST(Phriction, test1){ + QString uri("http://127.0.01:8081"); + QString user("pgess"); + QString token("api-pygm46avv2si6biyun5cmuhqr3xr"); + QString certificate("bjuun7um2coedcypcp34sx5q2whizfo2e5ek25emh2imt3zki3romj4tm3zmsq6cibyrh7ocndup77v7dsqapjodgb3vkrjtjbhn657raz7jrulhhfov3byrx3ixd35g5tcgtfijouifwgnk3cdh72csdzcjoouidlfiujig7awvsvv7x2f3wakdw2xigenqc7f677aqimbaaa5ayspoeeqt74dhswagljydfmwnadz2sr3bpej6b7avmrl7myb"); + + PhrictionClient phriction(uri, user, token, certificate); + + ASSERT_TRUE(phriction.publishDocument("/", "Manual", "manual", "")); + // ASSERT_TRUE(phriction.publishDocument("/one", "One", "one", "")); +} + +int main(int argc, char **argv) { + testing::GTEST_FLAG(color) = "yes"; + testing::InitGoogleTest(&argc, argv); + + QCoreApplication core(argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/documentation-tools/juffed-lexers/qscilexerremarkup.cpp b/documentation-tools/juffed-lexers/qscilexerremarkup.cpp index 33c3238..cd3c223 100644 --- a/documentation-tools/juffed-lexers/qscilexerremarkup.cpp +++ b/documentation-tools/juffed-lexers/qscilexerremarkup.cpp @@ -1,226 +1,226 @@ #include "qscilexerremarkup.h" #include #include QRegularExpression patternBold("\\*\\*(.+?)\\*\\*"); QRegularExpression patternItalic("(?SendScintilla(QsciScintilla::SCI_GETTEXTRANGE, start, end, chars); QString source = QString::fromUtf8(chars); delete [] chars; runPhutilRemarkupBoldRule(source,start); runPhutilRemarkupItalicRule(source,start); runPhutilRemarkupHighlightedRule(source, start); runPhutilRemarkupUnderlinedRule(source, start); runPhutilRemarkupMonospaceRule(source, start); } void QsciLexerRemarkup::runPhutilRemarkupBoldRule(const QString& source, int index){ int pos =0; while(true) { QRegularExpressionMatch result = patternBold.match(source, pos); if (!result.hasMatch()){break;} //hide: startStyling(index + result.capturedStart(0)); setStyling(result.capturedLength(0), (int) QsciLexerRemarkupStyles::Hidden); QString r = result.captured(1); startStyling(index + result.capturedStart(1)); setStyling(result.capturedLength(1), (int) QsciLexerRemarkupStyles::Bold); pos = result.capturedEnd(1) + 1; } } void QsciLexerRemarkup::runPhutilRemarkupItalicRule(const QString& source, int index){ int pos =0; while(true) { QRegularExpressionMatch result = patternItalic.match(source, pos); if (!result.hasMatch()){break;} //hide: startStyling(index + result.capturedStart(0)); setStyling(result.capturedLength(0), (int) QsciLexerRemarkupStyles::Hidden); startStyling(index + result.capturedStart(1)); setStyling(result.capturedLength(1), (int) QsciLexerRemarkupStyles::Italic); pos = result.capturedEnd(1) + 1; } } void QsciLexerRemarkup::runPhutilRemarkupHighlightedRule(const QString& source, int index){ int pos =0; while(true) { QRegularExpressionMatch result = patternHighlighted.match(source, pos); if (!result.hasMatch()){break;} //hide: startStyling(index + result.capturedStart(0)); setStyling(result.capturedLength(0), (int) QsciLexerRemarkupStyles::Hidden); startStyling(index + result.capturedStart(1)); setStyling(result.capturedLength(1), (int) QsciLexerRemarkupStyles::Highlight); pos = result.capturedEnd(1) + 1; } } void QsciLexerRemarkup::runPhutilRemarkupUnderlinedRule(const QString& source, int index){ int pos =0; while(true) { QRegularExpressionMatch result = patternUnderlined.match(source, pos); if (!result.hasMatch()){break;} //hide: startStyling(index + result.capturedStart(0)); setStyling(result.capturedLength(0), (int) QsciLexerRemarkupStyles::Hidden); startStyling(index + result.capturedStart(1)); setStyling(result.capturedLength(1), (int) QsciLexerRemarkupStyles::Underline); pos = result.capturedEnd(1) + 1; } } void QsciLexerRemarkup::runPhutilRemarkupMonospaceRule(const QString& source, int index){ int pos =0; while(true) { QRegularExpressionMatch result = patternMonospace.match(source, pos); if (!result.hasMatch()){break;} //hide: startStyling(index + result.capturedStart(0)); setStyling(result.capturedLength(0), (int) QsciLexerRemarkupStyles::Hidden); startStyling(index + result.capturedStart(1)); setStyling(result.capturedLength(1), (int) QsciLexerRemarkupStyles::Monospace); pos = result.capturedEnd(1) + 1; } } //"PhutilRemarkupBoldRule.php: **bold** //PhutilRemarkupItalicRule.php: //italic// /* "PhutilRemarkupDelRule.php" "PhutilRemarkupDocumentLinkRule.php" "PhutilRemarkupEscapeRemarkupRule.php" "PhutilRemarkupHighlightRule.php" "PhutilRemarkupHyperlinkRule.php" "PhutilRemarkupLinebreaksRule.php" "PhutilRemarkupMonospaceRule.php" "PhutilRemarkupRule.php" "PhutilRemarkupUnderlineRule.php" */ diff --git a/documentation-tools/juffed-lexers/qscilexerremarkup.h b/documentation-tools/juffed-lexers/qscilexerremarkup.h index 4b62f7a..ab9484c 100644 --- a/documentation-tools/juffed-lexers/qscilexerremarkup.h +++ b/documentation-tools/juffed-lexers/qscilexerremarkup.h @@ -1,50 +1,49 @@ #ifndef QSCILEXERREMARKUP_H #define QSCILEXERREMARKUP_H #include #include class QsciLexerRemarkup : public QsciLexerCustom { Q_OBJECT public: virtual QColor defaultColor(int style) const; virtual QFont defaultFont(int style) const; virtual QColor defaultPaper(int style) const; QsciStyle getStyle(int style); QsciLexerRemarkup(QObject * parent = 0); ~QsciLexerRemarkup(); void styleText(int start, int end); QString description(int style) const; const char* language() const; private: void runPhutilRemarkupBoldRule(const QString& source, int index); void runPhutilRemarkupItalicRule(const QString& source, int index); void runPhutilRemarkupHighlightedRule(const QString& source, int index); void runPhutilRemarkupUnderlinedRule(const QString& source, int index); void runPhutilRemarkupMonospaceRule(const QString& source, int index); }; -enum class QsciLexerRemarkupStyles - { - Default = 0, - Hidden, - Bold, - Italic, - Highlight, - Underline, - Monospace, - - Del, - DocumentLink, - EscapeRemarkup, - HyperLink, - - +class QsciLexerRemarkupStyles { +public:enum { + Default = 0, + Hidden, + Bold, + Italic, + Highlight, + Underline, + Monospace, + + Del, + DocumentLink, + EscapeRemarkup, + HyperLink, + }; }; #endif // QSCILEXERREMARKUP_H diff --git a/documentation-tools/juffed-plugins/fm/CMakeLists.txt b/documentation-tools/juffed-plugins/fm/CMakeLists.txt index 4e206d5..ca84e90 100644 --- a/documentation-tools/juffed-plugins/fm/CMakeLists.txt +++ b/documentation-tools/juffed-plugins/fm/CMakeLists.txt @@ -1,15 +1,15 @@ # fm QT_ADD_RESOURCES(fm_RES fm.qrc) QT_WRAP_UI(fm_UI ManageDlg.ui) set(fm_SRC ManageDlg.cpp FMPlugin.cpp TreeView.cpp - filesystemmodel.cpp + documentationmodel.cpp ) add_library(fm SHARED ${fm_SRC} ${fm_RES} ${fm_UI}) target_link_libraries(fm ${JUFFED_LIBRARY} ${JUFF_QT_IMPORTED_TARGETS}) install(TARGETS fm DESTINATION ${JUFFED_PLUGINS_DIR}) diff --git a/documentation-tools/juffed-plugins/fm/FMPlugin.cpp b/documentation-tools/juffed-plugins/fm/FMPlugin.cpp index e9304ab..6e02e18 100644 --- a/documentation-tools/juffed-plugins/fm/FMPlugin.cpp +++ b/documentation-tools/juffed-plugins/fm/FMPlugin.cpp @@ -1,288 +1,293 @@ //TASK read project path Settings::instance()->setValue(plugin->name(), key, value); //TASK provide decorations(icons, etc) - model role (see QVariant QFileSystemModel::data, Qt::DecorationRole) #include "FMPlugin.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "ManageDlg.h" #include "TreeView.h" -#include "filesystemmodel.h" +#include "documentationmodel.h" FMPlugin::FMPlugin() : QObject(), JuffPlugin() { - sortColumn = PluginSettings::getInt(this, "sortColumn", 0); - w_ = new QWidget(); - w_->setWindowTitle(tr("Project")); +} + +void FMPlugin::init(){ + sortColumn = PluginSettings::getInt(this, "sortColumn", 0); - model_ = new FileSystemModel; + w_ = new QWidget(); + w_->setWindowTitle(tr("Project")); + model_ = new DocumentationModel(reinterpret_cast(api()->currentProject()), w_); model_->setRootPath("/"); model_->setNameFilters(QStringList{"*.remarkup"}); model_->setNameFilterDisables(false); + model_->setReadOnly(false); // filter |= QDir::Hidden; // model_->setFilter(filter); tree_ = new TreeView(this, model_); tree_->setModel(model_); - tree_->setDragDropMode(QAbstractItemView::DragOnly); - tree_->setAllColumnsShowFocus(true); +// tree_->setAllColumnsShowFocus(true); tree_->sortByColumn(sortColumn, Qt::AscendingOrder); tree_->setSortingEnabled(true); tree_->setSelectionMode(QAbstractItemView::SingleSelection); //drag & drop tree_->setDragEnabled(true); tree_->viewport()->setAcceptDrops(true); tree_->setDropIndicatorShown(true); tree_->setDragDropMode(QAbstractItemView::InternalMove); - model_->setReadOnly(false); - tree_->setEditTriggers(QTreeView::NoEditTriggers); - connect(model_, &FileSystemModel::fileMoved, this, &FMPlugin::onFileMoved); + tree_->setDragDropOverwriteMode(false); + + tree_->setEditTriggers(QTreeView::EditKeyPressed); + connect(model_, &DocumentationModel::fileMoved, this, &FMPlugin::onFileMoved); connect(model_, &QFileSystemModel::fileRenamed, this, &FMPlugin::onFileRenamed); tree_->header()->resizeSection(0, 180); tree_->header()->resizeSection(1, 80); tree_->header()->resizeSection(2, 60); tree_->header()->resizeSection(3, 180); tree_->initMenu(); tree_->setRootIsDecorated(true); tree_->setItemsExpandable(true); - + //TOOLBAR: // QToolBar * toolBar = new QToolBar("File Browser Tools", w_); //backBtn_ = toolBar->addAction(QIcon::fromTheme("go-previous", QIcon(":icon_back")), tr("Go Back"), this, SLOT(back())); /* if ( Settings::instance()->valueExists(plugin->name(), key) ) return Settings::instance()->stringValue(plugin->name(), key); */ - pathEd_ = new QLineEdit("/private/prg/code/xreate/documentation/"); + pathEd_ = new QLineEdit(); pathEd_->setCompleter(new QCompleter(model_)); connect(pathEd_, SIGNAL(returnPressed()), SLOT(onNewProjectRoot())); QVBoxLayout* vBox = new QVBoxLayout(); vBox->setMargin(0); vBox->setSpacing(2); // vBox->addWidget(toolBar); vBox->addWidget(pathEd_); vBox->addWidget(tree_); w_->setLayout(vBox); connect(tree_, SIGNAL(doubleClicked(const QModelIndex&)), SLOT(itemDoubleClicked(const QModelIndex&))); connect(&fsWatcher_, SIGNAL(directoryChanged(const QString&)), SLOT(onDirChanged(const QString&))); - cd("/private/prg/code/xreate/documentation/"); - + cd("/private/prg/code/xreate/documentation"); + applySettings(); } FMPlugin::~FMPlugin() { w_->deleteLater(); } QString FMPlugin::name() const { return "Project"; } QString FMPlugin::title() const { return tr("Project"); } QString FMPlugin::targetEngine() const { return "all"; } QString FMPlugin::description() const { return "List of project files"; } QWidgetList FMPlugin::dockList() const { QWidgetList wList; wList << w_; return wList; } bool FMPlugin::dockVisible(QWidget* w) const { if ( w == w_ ) { return true; } else { return JuffPlugin::dockVisible(w); } } void FMPlugin::cd(const QString& path) { if ( QFileInfo(path).isDir() ) { // remove currently watching paths QStringList dirs = fsWatcher_.directories(); if ( !dirs.isEmpty() ) { fsWatcher_.removePaths(dirs); } - - tree_->setRootIndex(model_->index(path)); + + tree_->setRootIndex(model_->index(path)); pathEd_->setText(path); pathEd_->setToolTip(path); - + // add new current path for watching fsWatcher_.addPath(path); } } void FMPlugin::itemDoubleClicked(const QModelIndex& index) { QString path = model_->filePath(index); + if ( QFileInfo(path).isDir() ) { -// cd(path); + cd(path); } else { api()->openDoc(path); } } void FMPlugin::onDirChanged(const QString&) { } /* void FMPlugin::curFileDir() { Juff::Document* doc = api()->currentDocument(); if ( !doc->isNull() && !doc->isNoname() ) { cd(QFileInfo(doc->fileName()).absolutePath()); } } */ /* void FMPlugin::newDir() { QString newDirName = QInputDialog::getText(tree_, tr("New directory"), tr("Directory name")); if (newDirName.isEmpty()) return; QDir curDir(model_->filePath(tree_->rootIndex())); if ( !curDir.mkdir(newDirName) ) { QMessageBox::warning(tree_, tr("Warning"), tr("Couldn't create a dir named '%1'").arg(newDirName)); } } */ void FMPlugin::onNewProjectRoot() { if ( QFileInfo(pathEd_->text()).isDir() ) cd(pathEd_->text()); - else - pathEd_->setText(model_->filePath(tree_->rootIndex())); +// else +// pathEd_->setText(modelFilesystem->filePath(tree_->rootIndex())); } void FMPlugin::onDocSaved(const QString& fileName) { Q_UNUSED(fileName); } void FMPlugin::applySettings() { // QPalette plt = tree_->palette(); // plt.setColor(QPalette::Base, EditorSettings::get(EditorSettings::DefaultBgColor)); // plt.setColor(QPalette::Text, EditorSettings::get(EditorSettings::DefaultFontColor)); //// plt.setColor(QPalette::Highlight, EditorSettings::get(EditorSettings::SelectionBgColor)); //// plt.setColor(QPalette::HighlightedText, TextDocSettings::selectionTextColor()); // tree_->setPalette(plt); // pathEd_->setPalette(plt); // PluginSettings::set(this, "ShowAsTree", showAsTree); // tree_->setRootIsDecorated(showAsTree); // tree_->setItemsExpandable(showAsTree); // QDir::Filters filter = QDir::AllDirs | QDir::AllEntries | QDir::NoDotAndDotDot; // if (showHidden) // filter |= QDir::Hidden; // model_->setFilter(filter); } QWidget * FMPlugin::settingsPage() const { // QWidget * cfg = new QWidget(); // QVBoxLayout * l = new QVBoxLayout(); // cfg->setLayout(l); // QCheckBox * treeCheckBox = new QCheckBox(tr("Show Directory Structure in a Tree"), cfg); // treeCheckBox->setChecked(showAsTree); // connect(treeCheckBox, SIGNAL(toggled(bool)), this, SLOT(treeCheckBox_toggled(bool))); // QCheckBox *showHiddenBox = new QCheckBox(tr("Show Hidden Files and Directories"), cfg); // showHiddenBox->setChecked(showHidden); // connect(showHiddenBox, SIGNAL(toggled(bool)), this, SLOT(showHiddenBox_toggled(bool))); // l->addWidget(treeCheckBox); // l->addWidget(showHiddenBox); // l->addItem(new QSpacerItem(1, 1, QSizePolicy::Minimum, QSizePolicy::MinimumExpanding)); // return cfg; return 0; } void FMPlugin::onFileMoved(const QString &path, const QString &pathOld){ QStringList docs = api()->docList(); const QFileInfo& fileInfo(path); if ( fileInfo.isDir()){ //move section for(QString& file: docs) { if (file.left(pathOld.length()).compare(pathOld) == 0){ //file affected Juff::Document* docUpdated = api()->document(file); const QString& fileNewName = file.replace(0, pathOld.length(), path); docUpdated->setFileName(fileNewName); } } } { //move topic for(const QString& file: docs) { if (file.length() == pathOld.length() && file.compare(pathOld) == 0){ Juff::Document* docUpdated = api()->document(file); docUpdated->setFileName(path); break; } } } } void FMPlugin::onFileRenamed(const QString &path, const QString &oldName, const QString &newName){ const QString& fileOldName = path + QDir::separator() + oldName; const QString& fileNewName = path + QDir::separator() + newName; QStringList docs = api()->docList(); for(const QString& file: docs) { if (file.length() == fileOldName.length() && file.compare(fileOldName) == 0){ Juff::Document* docUpdated = api()->document(file); docUpdated->setFileName(fileNewName); break; } } } #if QT_VERSION < 0x050000 Q_EXPORT_PLUGIN2(fm, FMPlugin) #endif diff --git a/documentation-tools/juffed-plugins/fm/FMPlugin.h b/documentation-tools/juffed-plugins/fm/FMPlugin.h index 373fec1..5438be9 100644 --- a/documentation-tools/juffed-plugins/fm/FMPlugin.h +++ b/documentation-tools/juffed-plugins/fm/FMPlugin.h @@ -1,83 +1,84 @@ #ifndef _FM_PLUGIN_H_ #define _FM_PLUGIN_H_ class QLineEdit; class QAction; class TreeView; #include #include #include #include #include -class FileSystemModel; +class DocumentationModel; class FMPlugin : public QObject, public JuffPlugin { Q_OBJECT #if QT_VERSION >= 0x050000 Q_PLUGIN_METADATA(IID JuffPlugin_iid) #endif Q_INTERFACES(JuffPlugin) public: FMPlugin(); virtual ~FMPlugin(); + void init(); // info virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString targetEngine() const; // controls virtual QWidgetList dockList() const; virtual bool dockVisible(QWidget*) const; virtual void applySettings(); QWidget * settingsPage() const; protected: virtual void onDocSaved(const QString&); protected slots: void itemDoubleClicked(const QModelIndex&); void home(); void up(); void back(); void curFileDir(); void favorites(); void newDir(); void addToFavorites(); void goToFavorite(); void manageFavorites(); void onNewProjectRoot(); void treeCheckBox_toggled(bool value); void showHiddenBox_toggled(bool value); void onDirChanged(const QString&); void onFileMoved(const QString &path, const QString &pathOld); void onFileRenamed(const QString &path, const QString &oldName, const QString &newName); private: void cd(const QString&); void initFavoritesMenu(); bool showAsTree; bool showHidden; int sortColumn; QWidget* w_; TreeView* tree_; - FileSystemModel* model_; + DocumentationModel* model_; QLineEdit* pathEd_; QAction* backBtn_; QStack history_; QStringList favorites_; QMenu* favoritesMenu_; QAction* addToFavoritesAct_; QAction* manageFavoritesAct_; QFileSystemWatcher fsWatcher_; }; #endif diff --git a/documentation-tools/juffed-plugins/fm/TreeView.cpp b/documentation-tools/juffed-plugins/fm/TreeView.cpp index b6f9830..a891093 100644 --- a/documentation-tools/juffed-plugins/fm/TreeView.cpp +++ b/documentation-tools/juffed-plugins/fm/TreeView.cpp @@ -1,104 +1,113 @@ #include #include "TreeView.h" #include #include #include #include #include #include #include #include +#include "documentationmodel.h" -TreeView::TreeView(JuffPlugin* plugin, QFileSystemModel* model, QWidget* parent) +TreeView::TreeView(JuffPlugin* plugin, DocumentationModel* model, QWidget* parent) : QTreeView(parent) , plugin_(plugin) , __model(model) { header()->installEventFilter(this); } void TreeView::initMenu() { __menuSection = new QMenu(this); __menuTopic = new QMenu(this); __actionRename = __menuSection->addAction("Rename", this, SLOT(rename())); __menuSection->addAction("Add section", this, SLOT(addChildSection())); __menuSection->addAction("Add topic", this, SLOT(addChildTopic())); __menuTopic->addAction("Rename", this, SLOT(rename())); } void TreeView::mousePressEvent(QMouseEvent * e){ __actionRename->setDisabled(false); if (e->button() == Qt::RightButton){ QModelIndex currentIndex = this->indexAt(e->pos()); if (currentIndex.isValid()){ setCurrentIndex(currentIndex); QString path = __model->filePath(currentIndex); if ( QFileInfo(path).isDir() ) { __menuSection->exec(QCursor::pos()); } else { __menuTopic->exec(QCursor::pos()); } return; } setCurrentIndex(rootIndex()); __actionRename->setDisabled(true); __menuSection->exec(QCursor::pos()); } QTreeView::mousePressEvent(e); } void TreeView::rename() { this->edit(currentIndex()); // QFileSystemModel* dirModel = qobject_cast(model()); // if ( 0 != dirModel ) { // QFileInfo fi = dirModel->fileInfo(currentIndex()); // QString newFileName = QInputDialog::getText(this, tr("Rename"), tr("File name"), // QLineEdit::Normal, fi.baseName()); // if (newFileName.isEmpty()) // return; // QString oldFileName = fi.absoluteFilePath(); // QFile file(oldFileName); // QDir::setCurrent(fi.absolutePath()); // if ( !file.rename(newFileName + ".remarkup") ) { // QMessageBox::warning(this, tr("Warning"), // tr("Rename failed: file '%1' already exists").arg(newFileName)); // } else { // emit fileMoved(fi.absoluteDir().absolutePath() + QDir::separator() + newFileName + ".remarkup", oldFileName); // } // } } void TreeView::addChildTopic(){ QString newTopicName = QInputDialog::getText(this, tr("New topic"), tr("Topic name")); if (newTopicName.isEmpty()) return; QFile file(__model->filePath(currentIndex()) + '/' + newTopicName + ".remarkup"); file.open(QIODevice::WriteOnly); file.close(); } void TreeView::addChildSection(){ QString newDirName = QInputDialog::getText(this, tr("New section"), tr("Section name")); if (newDirName.isEmpty()) return; QDir curDir(__model->filePath(currentIndex())); if ( !curDir.mkdir(newDirName) ) { QMessageBox::warning(this, tr("Warning"), tr("Couldn't create a section named '%1'").arg(newDirName)); } } + +void TreeView::dragMoveEvent(QDragMoveEvent* event) +{ + + qDebug() << dropIndicatorPosition(); + + return QTreeView::dragMoveEvent(event); +} \ No newline at end of file diff --git a/documentation-tools/juffed-plugins/fm/TreeView.h b/documentation-tools/juffed-plugins/fm/TreeView.h index cc7f6f0..b1f9bd0 100644 --- a/documentation-tools/juffed-plugins/fm/TreeView.h +++ b/documentation-tools/juffed-plugins/fm/TreeView.h @@ -1,42 +1,45 @@ #ifndef _FM_TREE_VIEW_H_ #define _FM_TREE_VIEW_H_ class JuffPlugin; class QMenu; +class DocumentationModel; #include + QT_BEGIN_NAMESPACE class QFileSystemModel; QT_END_NAMESPACE class TreeView : public QTreeView { Q_OBJECT public: - TreeView(JuffPlugin*, QFileSystemModel* model, QWidget* parent = 0); + TreeView(JuffPlugin*, DocumentationModel* model, QWidget* parent = 0); void initMenu(); + void dragMoveEvent(QDragMoveEvent* event); public slots: void rename(); void addChildSection(); void addChildTopic(); signals: void fileMoved(const QString& newFileName, const QString& oldFileName); protected: virtual void mousePressEvent(QMouseEvent * event) override; private: JuffPlugin* plugin_; QMenu* __menuSection; QMenu* __menuTopic; QAction* __actionRename; - QFileSystemModel* __model; + DocumentationModel* __model; }; #endif diff --git a/documentation-tools/juffed-plugins/fm/documentationmodel.cpp b/documentation-tools/juffed-plugins/fm/documentationmodel.cpp new file mode 100644 index 0000000..6b10302 --- /dev/null +++ b/documentation-tools/juffed-plugins/fm/documentationmodel.cpp @@ -0,0 +1,148 @@ +#include "documentationmodel.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include "AppInfo.h" +#include "DocumentationProject.h" + +DocumentationModel::DocumentationModel(DocumentationProject* project, QObject *parent) + : docs(project), QFileSystemModel(parent) + {} + +DocumentationModel::~DocumentationModel() {} + +bool DocumentationModel::dropMimeData(const QMimeData *data + , Qt::DropAction action + ,int row + , int column + , const QModelIndex &parent) { + + bool success = QFileSystemModel::dropMimeData(data, action, row, column, parent); + + if (success){ + QString pathTo = filePath(parent) + QDir::separator(); + QString pathOld = data->urls().begin()->toLocalFile(); + QString pathNew = pathTo + QFileInfo(pathOld).fileName(); + + emit fileMoved(pathNew, pathOld); + } + + return true; +} + +int +DocumentationModel::columnCount(const QModelIndex &parent) const +{ + return (parent.column() > 0) ? 0 : 5; +} + +QVariant +DocumentationModel::headerData(int section, Qt::Orientation orientation, int role) const{ + if (section == 4){ + return "Title"; + } + + return QFileSystemModel::headerData(section, orientation, role); +} + +Qt::ItemFlags +DocumentationModel::flags(const QModelIndex &index) const { + auto flags = QFileSystemModel::flags(index); + + if (index.column() == 4) { + return flags | Qt::ItemIsEditable; + } + + return flags; +} + +QVariant +DocumentationModel::data(const QModelIndex &index, int role) const +{ + if (role == Qt::DisplayRole || role == Qt::EditRole) + if (index.column() == 4) { + QString filepath = filePath(index); + QString title = docs->getTitle(filepath); + if (!title.isEmpty()) qDebug() << "File " << filepath <<" title is " << title; + return docs->getTitle(filepath); + } + + return QFileSystemModel::data(index, role); +} + +bool +DocumentationModel::setData(const QModelIndex &idx, const QVariant &value, int role){ + if (idx.column() == 4) { + QString newTitle = value.toString(); + QString filepath = filePath(idx); + + docs->project.insert(filepath, QJsonObject({{"title", QJsonValue(newTitle)}})); + +// auto i = project.object().find(filepath); +// if (i == project.object().end()){ +// +// +// +// +// } else { +//// QJsonObject record = i.value().toObject(); +//// record.insert("title", QJsonValue(newTitle)); +// +// +// +// i.value() = QJsonObject({{"title", QJsonValue(newTitle)}}); +// } + + +// QJsonObject projectObj = project.object(); +// auto j = projectObj.find(filepath); +// +// if (j != projectObj.end()){ +// qDebug() << QJsonDocument(j.value().toObject()).toJson(QJsonDocument::Indented); +// } + + qDebug() << "set title: `" << newTitle <<"` for file: `" << filepath << "'"; + return true; + } + + return QFileSystemModel::setData(idx, value, role); +} + +//QString +//DocumentationModel::filePath(QModelIndex i) const{ +// return reinterpret_cast(sourceModel())->filePath(this->mapToSource(i)); +//} + +//bool +//DocumentationModel::lessThan(const QModelIndex &left, const QModelIndex &right) const { +// return filePath(left) < filePath(right); +// auto i = project.find(filepath); +// +// if (i == project.end()){ +// return ""; +// } +// +// return (i.value().toObject()["title"].toString()); +//} + +//void QSortFilterProxyModelPrivate::sort() +//{ +// Q_Q(QSortFilterProxyModel); +// emit q->layoutAboutToBeChanged(QList(), QAbstractItemModel::VerticalSortHint); +// QModelIndexPairList source_indexes = store_persistent_indexes(); +// IndexMap::const_iterator it = source_index_mapping.constBegin(); +// for (; it != source_index_mapping.constEnd(); ++it) { +// QModelIndex source_parent = it.key(); +// Mapping *m = it.value(); +// sort_source_rows(m->source_rows, source_parent); +// build_source_to_proxy_mapping(m->source_rows, m->proxy_rows); +// } +// update_persistent_indexes(source_indexes); +// emit q->layoutChanged(QList(), QAbstractItemModel::VerticalSortHint); +//} \ No newline at end of file diff --git a/documentation-tools/juffed-plugins/fm/documentationmodel.h b/documentation-tools/juffed-plugins/fm/documentationmodel.h new file mode 100644 index 0000000..04458be --- /dev/null +++ b/documentation-tools/juffed-plugins/fm/documentationmodel.h @@ -0,0 +1,27 @@ +#ifndef FILESYSTEMMODEL_H +#define FILESYSTEMMODEL_H +#include +#include +#include "DocumentationProject.h" + +class DocumentationModel: public QFileSystemModel { + Q_OBJECT + + public: + DocumentationModel(DocumentationProject* docs, QObject *parent); + ~DocumentationModel(); + bool lessThan(const QModelIndex &left, const QModelIndex &right) const; + bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE; + + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + Qt::ItemFlags flags(const QModelIndex &index) const; + bool setData(const QModelIndex &idx, const QVariant &value, int role); + + DocumentationProject* docs; +signals: + void fileMoved(const QString& path, const QString& pathOld); + +}; +#endif // FILESYSTEMMODEL_H diff --git a/documentation-tools/juffed-plugins/fm/filesystemmodel.cpp b/documentation-tools/juffed-plugins/fm/filesystemmodel.cpp deleted file mode 100644 index 35b9663..0000000 --- a/documentation-tools/juffed-plugins/fm/filesystemmodel.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include "filesystemmodel.h" - -#include -#include - -FileSystemModel::FileSystemModel(): QFileSystemModel() {} - -bool FileSystemModel::dropMimeData(const QMimeData *data - , Qt::DropAction action - ,int row - , int column - , const QModelIndex &parent) { - - bool success = QFileSystemModel::dropMimeData(data, action, row, column, parent); - - if (success){ - QString pathTo = filePath(parent) + QDir::separator(); - QString pathOld = data->urls().begin()->toLocalFile(); - QString pathNew = pathTo + QFileInfo(pathOld).fileName(); - - emit fileMoved(pathNew, pathOld); - } - - return success; -} diff --git a/documentation-tools/juffed-plugins/fm/filesystemmodel.h b/documentation-tools/juffed-plugins/fm/filesystemmodel.h deleted file mode 100644 index 9168067..0000000 --- a/documentation-tools/juffed-plugins/fm/filesystemmodel.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef FILESYSTEMMODEL_H -#define FILESYSTEMMODEL_H -#include - -class FileSystemModel: public QFileSystemModel { - Q_OBJECT - - public: - FileSystemModel(); - bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE; - -signals: - void fileMoved(const QString& path, const QString& pathOld); - -}; -#endif // FILESYSTEMMODEL_H diff --git a/documentation-tools/juffed-plugins/phapublisher/phapublisher.cpp b/documentation-tools/juffed-plugins/phapublisher/phapublisher.cpp index b3700b7..2f025db 100644 --- a/documentation-tools/juffed-plugins/phapublisher/phapublisher.cpp +++ b/documentation-tools/juffed-plugins/phapublisher/phapublisher.cpp @@ -1,114 +1,136 @@ //TEST check publishing with intermdeiate non existent categories #include "phapublisher.h" #include "phrictionclient.h" #include "ui_publishersettings.h" #include "PluginSettings.h" +#include "DocumentationProject.h" #include #include #include +#include "DocumentationProject.h" + class UiSettings : public QWidget, public Ui::Form{}; void PhaPublisher::publishCurrentPage(){ Juff::Document* doc = api()->currentDocument(); QString filename = doc->fileName(); if (!filename.startsWith(cfgRoot)){ QMessageBox::critical(doc, "Phabricator Publisher", "Current document located not in scope of a project", QMessageBox::Ok); } QFileInfo finfo(filename); QString slug; + QString title; + if (finfo.baseName()=="index"){ slug = filename.mid(cfgRoot.length(), filename.length()-cfgRoot.length()-finfo.fileName().length()-1); + if (slug.isEmpty()) slug = "/"; + title = slug.right(slug.length() - slug.lastIndexOf("/") - 1); + } else { - slug = filename.mid(cfgRoot.length(), filename.length()-cfgRoot.length()-finfo.completeSuffix().length()-1); + slug = filename.mid(cfgRoot.length(), filename.length()-cfgRoot.length()-finfo.completeSuffix().length() - 1); + title = finfo.baseName(); } - QString title = finfo.baseName(); + title[0] = title[0].toUpper(); + title.replace('_', ' '); + + QString titleAlternate = docs->getTitle(filename); + if (!titleAlternate.isEmpty()){ + title = titleAlternate; + } + + QString content; doc->getText(content); if (transport->publishDocument(slug, title, content, "")){ QMessageBox::information(nullptr, "Phabricator publisher", "Page published successfully"); } } PhaPublisher::PhaPublisher() : QObject(), JuffPlugin() ,uiSettings(new UiSettings()), transport(0) { cfgUrl = PluginSettings::getString(this, "url", "http://localhost/"); cfgUser = PluginSettings::getString(this, "user", "pgess"); cfgCertificate = PluginSettings::getString(this, "certificate", ""); cfgToken = PluginSettings::getString(this, "token", ""); cfgRoot = PluginSettings::getString(this, "root", "~"); + if (cfgRoot.right(1) == "/"){ + cfgRoot = cfgRoot.left(cfgRoot.length()-1); + } uiSettings->setupUi(uiSettings); uiSettings->uiUrl->setText(cfgUrl); uiSettings->uiUser->setText(cfgUser); uiSettings->uiSertificate->setPlainText(cfgCertificate); uiSettings->uiToken->setText(cfgToken); uiSettings->uiRoot->setText(cfgRoot); } QWidget* PhaPublisher::settingsPage() const{ return uiSettings; } void PhaPublisher::applySettings(){ if (!uiSettings) return; cfgUrl = uiSettings->uiUrl->text(); cfgUser = uiSettings->uiUser->text(); cfgCertificate = uiSettings->uiSertificate->toPlainText(); cfgToken = uiSettings->uiToken->text(); cfgRoot = uiSettings->uiRoot->text(); PluginSettings::set(this, "url", cfgUrl); PluginSettings::set(this, "user", cfgUser); PluginSettings::set(this, "certificate", cfgCertificate); PluginSettings::set(this, "token", cfgToken); PluginSettings::set(this, "root", cfgRoot); delete transport; transport = new PhrictionClient(cfgUrl, cfgUser, cfgToken, cfgCertificate); } void PhaPublisher::init(){ //transport = new PhrictionClient(); + + docs = reinterpret_cast(api()->currentProject()); } QAction* createAction(const QString& title, const QKeySequence& key, const QObject* this_, const char* slot) { QAction* act = new QAction(title, 0); this_->connect(act, SIGNAL(triggered()), this_, slot); act->setShortcut(key); return act; } // info QString PhaPublisher::name()const {return "phublisher";} QString PhaPublisher::title() const {return "Phabricator publisher";} QString PhaPublisher::description() const {return "Phabricator publisher";} QString PhaPublisher::targetEngine() const{ return "all";} Juff::ActionList PhaPublisher::mainMenuActions(Juff::MenuID id) const { Juff::ActionList list; if ( id == Juff::MenuEdit ) { list << createAction(tr("publish"), QKeySequence("Ctrl+Shift+B"), this, SLOT(publishCurrentPage())); } return list; } PhaPublisher::~PhaPublisher(){ delete transport; //delete uiSettings; uiSettings->deleteLater(); } diff --git a/documentation-tools/juffed-plugins/phapublisher/phapublisher.h b/documentation-tools/juffed-plugins/phapublisher/phapublisher.h index efad109..c4aa84e 100644 --- a/documentation-tools/juffed-plugins/phapublisher/phapublisher.h +++ b/documentation-tools/juffed-plugins/phapublisher/phapublisher.h @@ -1,45 +1,47 @@ #ifndef PHAPUBLISHER_H #define PHAPUBLISHER_H #include #include "JuffPlugin.h" class PhrictionClient; class UiSettings; +class DocumentationProject; class PhaPublisher : public QObject, public JuffPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID JuffPlugin_iid) Q_INTERFACES(JuffPlugin) public: explicit PhaPublisher(); ~PhaPublisher(); void init(); // info virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString targetEngine() const; Juff::ActionList mainMenuActions(Juff::MenuID id) const; virtual QWidget* settingsPage() const override; virtual void applySettings(); signals: public slots: void publishCurrentPage(); private: + DocumentationProject* docs; PhrictionClient* transport; UiSettings* uiSettings; QString cfgUrl; QString cfgUser; QString cfgCertificate; QString cfgToken; QString cfgRoot; }; #endif // PHAPUBLISHER_H diff --git a/documentation-tools/juffed/build.sh b/documentation-tools/juffed/build.sh new file mode 100644 index 0000000..e3da1df --- /dev/null +++ b/documentation-tools/juffed/build.sh @@ -0,0 +1,43 @@ +DIR_DT = $PWD/.. +DIR_J = DIR_DT/juffed + +#install packages + sudo zypper in libQt5PrintSupport-devel libqt5-qttools-devel enca libqscintilla-devel libqscintilla-qt5-devel thift libthift-devel + +#pulling juffed + cd /opt + git clone https://github.com/Mezomish/juffed.git + cd /juffed + git apply $DIR_J/patches + +#prepare RemarkupParser + #THRIFT_CMPILER=thrift + #cd $DIR_DT/RemarkupParser/ + #$THRIFT_COMPILER -out ./gen-cpp -gen cpp:moveable_types ./remarkup.thrift + +#add plugins + rm -r /opt/juffed/plugins/fm/ + ln -s $DIR_DT/juffed-plugins/fm /opt/juffed/plugins/fm + ln -s $DIR_DT/juffed-plugins/phapublisher /opt/juffed/plugins/phapublisher + ln -s $DIR_DT/juffed-plugins/remarkupplugin /opt/juffed/plugins/remarkupplugin + +#add subprojects + ln -s $DIR_DT/conduit-client /opt/juffed/src/3rd_party/conduit-client + ln -s $DIR_DT/RemarkupParser /opt/juffed/src/3rd_party/RemarkupParser + +#add lexers + mkdir /opt/juffed/src/app/qsci/lexers/custom + ln -s $DIR_DT/juffed-lexers/qscilexerremarkup.* /opt/juffed/src/app/qsci/lexers/custom/ + sudo ln -s $DIR_DT/juffed-lexers/remarkup.xml /usr/local/share/juffed/hlschemes/ + +#actual build/install + cd /opt/juffed + mkdir build + cd ./build + cmake ../. -DUSE_QT5=ON -DUSE_ENCA=ON -DUSE_SYSTEM_QTSINGLEAPPLICATION=0 -DCMAKE_BUILD_TYPE=debug + make -j4 + sudo make install + +#link to development version +sudo rm /usr/local/bin/juffed +sudo ln -s /opt/juffed/build/juffed /usr/local/bin/juffed diff --git a/documentation-tools/juffed/patches b/documentation-tools/juffed/patches new file mode 100644 index 0000000..561f009 --- /dev/null +++ b/documentation-tools/juffed/patches @@ -0,0 +1,519 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 1303b01..720418a 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -19,6 +19,8 @@ + project (juffed) + cmake_minimum_required (VERSION 2.8.11) + ++set (CMAKE_CXX_FLAGS "--std=c++11 ${CMAKE_CXX_FLAGS}") ++ + # build options + option(USE_QT5 "Use Qt5. Defaults to Qt4" $ENV{USE_QT5}) + option(USE_SYSTEM_QTSINGLEAPPLICATION "Try to find system-wide QtSingleApplication library" $ENV{USE_SYSTEM_SINGLETON}) +@@ -301,9 +303,13 @@ target_link_libraries ( ${JUFFED} + ) + + if ( UNIX ) +- set(CMAKE_CXX_FLAGS "-Wall -Wextra") ++ set(CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}") + endif ( UNIX ) + ++#add custom sub projects ++#add_subdirectory(src/3rd_party/RemarkupParser) ++add_subdirectory(src/3rd_party/conduit-client) ++ + # + # plugins + message(STATUS "Plugins: all externally linked cmake-ready plugs will be built") +diff --git a/cmake/FileSets.cmake b/cmake/FileSets.cmake +index 256b0fd..6f1a62e 100644 +--- a/cmake/FileSets.cmake ++++ b/cmake/FileSets.cmake +@@ -90,6 +90,9 @@ SET ( juffed_qsci_SRCS + src/app/qsci/lexers/qscilexerlisp.cpp + src/app/qsci/lexers/qscilexernsis.cpp + src/app/qsci/lexers/my/QsciLexerMatlab.cpp ++ ++ #custom lexers ++ src/app/qsci/lexers/custom/qscilexerremarkup.cpp + ) + + SET ( juffed_qsci_UIS +diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt +index d161ec9..7d7cb4f 100644 +--- a/plugins/CMakeLists.txt ++++ b/plugins/CMakeLists.txt +@@ -120,3 +120,7 @@ endif (BUILD_AUTOSAVE) + if (BUILD_COLORPICKER) + add_subdirectory(colorpicker) + endif (BUILD_COLORPICKER) ++ ++#add custom plugins ++add_subdirectory(phapublisher) ++#add_subdirectory(remarkupplugin +diff --git a/src/app/qsci/LexerStorage.cpp b/src/app/qsci/LexerStorage.cpp +index b836047..53ad1cd 100644 +--- a/src/app/qsci/LexerStorage.cpp ++++ b/src/app/qsci/LexerStorage.cpp +@@ -3,7 +3,7 @@ JuffEd - An advanced text editor + Copyright 2007-2010 Mikhail Murzin + + This program is free software; you can redistribute it and/or +-modify it under the terms of the GNU General Public License ++modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, +@@ -78,6 +78,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + #include "QSciSettings.h" + + #include "Log.h" ++#include "lexers/custom/qscilexerremarkup.h" + #include + + namespace Juff { +@@ -92,6 +93,10 @@ namespace Juff { + + bool bold; + bool italic; ++ bool capitalization; ++ bool monospace; ++ bool underline; ++ bool strikeout; + QColor color; + QColor bgColor; + }; +@@ -101,7 +106,7 @@ namespace Juff { + style = st; + hlElements = elements; + } +- ++ + QList hlElements; + Style style; + }; +@@ -120,11 +125,11 @@ public: + } + ~LSInterior() { + } +- ++ + QsciLexer* lexer(const QString& name/*, const QFont&*/); + void readCustomStyle(const QString& name); + void applyCustomStyle(const QString& name, const QFont& font); +- ++ + QMap lexers_; + SchemeMap schemes_; + QMap curLineColors_; +@@ -147,8 +152,8 @@ void parseScheme(const QDomElement& schEl, StyleMap& styles) { + QString defBgColorStr = schEl.attribute("defaultBgColor", ""); + QString defBoldStr = schEl.attribute("defaultBold", "false"); + QString defItalicStr = schEl.attribute("defaultItalic", "false"); +- +- Style defaultStyle(stringToColor(defColorStr), stringToColor(defBgColorStr), ++ ++ Style defaultStyle(stringToColor(defColorStr), stringToColor(defBgColorStr), + stringToBool(defBoldStr), stringToBool(defItalicStr)); + styles["default"] = defaultStyle; + +@@ -162,6 +167,10 @@ void parseScheme(const QDomElement& schEl, StyleMap& styles) { + style.bgColor = stringToColor(styleEl.attribute("bgColor", defBgColorStr)); + style.bold = stringToBool(styleEl.attribute("bold", defBoldStr)); + style.italic = stringToBool(styleEl.attribute("italic", defItalicStr)); ++ style.monospace = stringToBool(styleEl.attribute("monospace", "")); ++ style.underline = stringToBool(styleEl.attribute("underline", "")); ++ style.capitalization = stringToBool(styleEl.attribute("capitalization", "")); ++ style.strikeout = stringToBool(styleEl.attribute("strikeout", "")); + styles[name] = style; + } + } +@@ -172,7 +181,7 @@ void parseScheme(const QDomElement& schEl, StyleMap& styles) { + + void LSInterior::readCustomStyle(const QString& name) { + // LOGGER; +- ++ + QDomDocument doc("JuffScheme"); + QString nm = name; + nm = nm.replace(QString("+"), "plus").replace(QString("#"), "sharp").toLower(); +@@ -187,7 +196,7 @@ void LSInterior::readCustomStyle(const QString& name) { + return; + } + else { +-// Log::debug(QString("File '%1' opened successfully").arg(fileName), true); ++ Log::debug(QString("File '%1' opened successfully").arg(fileName), true); + } + + QString err; +@@ -201,7 +210,7 @@ void LSInterior::readCustomStyle(const QString& name) { + else { + // Log::debug(QString("File '%1' was parsed successfully").arg(fileName), true); + } +- ++ + file.close(); + + QDomElement docElem = doc.documentElement(); +@@ -232,7 +241,7 @@ void LSInterior::readCustomStyle(const QString& name) { + // Log::debug(QString("Preparing to create a lexer '%1'").arg(name)); + + Scheme* scheme = NULL; +- ++ + if ( name.compare("C++") == 0 ) { + scheme = new Scheme(); + scheme->defaultStyle = styles["default"]; +@@ -352,7 +361,7 @@ void LSInterior::readCustomStyle(const QString& name) { + else if ( name.compare("HTML") == 0 ) { + scheme = new Scheme(); + scheme->defaultStyle = styles["default"]; +- scheme->rules ++ scheme->rules + << Rule(styles["tag"], QList() << QsciLexerHTML::Tag) + << Rule(styles["attribute"], QList() << QsciLexerHTML::Attribute) + << Rule(styles["comment"], QList() << QsciLexerHTML::HTMLComment) +@@ -371,7 +380,7 @@ void LSInterior::readCustomStyle(const QString& name) { + else if ( name.compare("PHP") == 0 ) { + scheme = new Scheme(); + scheme->defaultStyle = styles["default"]; +- scheme->rules ++ scheme->rules + << Rule(styles["phpKeyword"], QList() << QsciLexerHTML::PHPKeyword) + << Rule(styles["phpOperator"], QList() << QsciLexerHTML::PHPOperator) + << Rule(styles["phpVariable"], QList() << QsciLexerHTML::PHPVariable) +@@ -410,9 +419,9 @@ void LSInterior::readCustomStyle(const QString& name) { + else if ( name.compare("CSS") == 0 ) { + scheme = new Scheme(); + scheme->defaultStyle = styles["default"]; +- scheme->rules ++ scheme->rules + << Rule(styles["tag"], QList() << QsciLexerCSS::Tag) +-#ifdef CSS3_FOUND ++#ifdef CSS3_FOUND + << Rule(styles["property"], QList() << QsciLexerCSS::CSS1Property << QsciLexerCSS::CSS2Property << QsciLexerCSS::CSS3Property) + #else + << Rule(styles["property"], QList() << QsciLexerCSS::CSS1Property << QsciLexerCSS::CSS2Property) +@@ -500,7 +509,7 @@ void LSInterior::readCustomStyle(const QString& name) { + else if ( name.compare("TCL") == 0 ) { + scheme = new Scheme(); + scheme->defaultStyle = styles["default"]; +- scheme->rules ++ scheme->rules + << Rule(styles["number"], QList() << QsciLexerTCL::Number) + << Rule(styles["keyword"], QList() << QsciLexerTCL::QuotedKeyword << QsciLexerTCL::ExpandKeyword << QsciLexerTCL::KeywordSet6 << QsciLexerTCL::KeywordSet7 << QsciLexerTCL::KeywordSet8 << QsciLexerTCL::KeywordSet9) + << Rule(styles["string"], QList() << QsciLexerTCL::QuotedString) +@@ -522,7 +531,7 @@ void LSInterior::readCustomStyle(const QString& name) { + else if ( name.compare("Pascal") == 0 ) { + scheme = new Scheme(); + scheme->defaultStyle = styles["default"]; +- scheme->rules ++ scheme->rules + << Rule(styles["comment"], QList() << QsciLexerPascal::Comment << QsciLexerPascal::CommentLine << QsciLexerPascal::CommentParenthesis) + << Rule(styles["number"], QList() << QsciLexerPascal::Number) + << Rule(styles["keyword"], QList() << QsciLexerPascal::Keyword) +@@ -539,7 +548,7 @@ void LSInterior::readCustomStyle(const QString& name) { + else if ( name.compare("Fortran") == 0 ) { + scheme = new Scheme(); + scheme->defaultStyle = styles["default"]; +- scheme->rules ++ scheme->rules + << Rule(styles["comment"], QList() << QsciLexerFortran77::Comment) + << Rule(styles["number"], QList() << QsciLexerFortran77::Number) + << Rule(styles["keyword"], QList() << QsciLexerFortran77::Keyword) +@@ -570,17 +579,29 @@ void LSInterior::readCustomStyle(const QString& name) { + } + #endif // JUFF_PROPERTIES_LEXER + ++ else if ( name.compare("Remarkup") == 0 ) { ++ scheme = new Scheme(); ++ scheme->defaultStyle = styles["default"]; ++ scheme->rules ++ << Rule(styles["Bold"], QList() << (int) QsciLexerRemarkupStyles::Bold) ++ << Rule(styles["Italic"], QList() <<(int) QsciLexerRemarkupStyles::Italic) ++ << Rule(styles["Hidden"], QList() <<(int) QsciLexerRemarkupStyles::Hidden) ++ << Rule(styles["Highlight"], QList() <<(int) QsciLexerRemarkupStyles::Highlight) ++ << Rule(styles["Underline"], QList() <<(int) QsciLexerRemarkupStyles::Underline) ++ << Rule(styles["Monospace"], QList() <<(int) QsciLexerRemarkupStyles::Monospace); + ++ schemes_[name] = scheme; ++ } + // Log::debug("Exiting readCustomStyle()"); + } + + void LSInterior::applyCustomStyle(const QString& name, const QFont& font) { + // LOGGER; +- ++ + QsciLexer* lex = lexers_.value(name, 0); + if ( lex != 0 ) { + // Log::debug("Have a lexer"); +- ++ + lex->setFont(font, -1); + + if ( name.compare("none") == 0 ) { +@@ -591,11 +612,11 @@ void LSInterior::applyCustomStyle(const QString& name, const QFont& font) { + } + else { + // Log::debug(QString("Lexer is not 'none'")); +- ++ + if ( schemes_.contains(name) ) { + // Log::debug(QString("Found scheme %1").arg(name)); + Scheme* scheme = schemes_[name]; +- ++ + QFont f(font); + f.setStyle(scheme->defaultStyle.italic ? QFont::StyleItalic : QFont::StyleNormal); + f.setWeight(scheme->defaultStyle.bold ? QFont::Bold : QFont::Normal); +@@ -622,6 +643,15 @@ void LSInterior::applyCustomStyle(const QString& name, const QFont& font) { + QFont f(font); + f.setStyle(rule.style.italic ? QFont::StyleItalic : QFont::StyleNormal); + f.setWeight(rule.style.bold ? QFont::Bold : QFont::Normal); ++ if (rule.style.capitalization) { ++ f.setCapitalization(QFont::AllUppercase); ++ } ++ f.setUnderline(rule.style.underline); ++ f.setStrikeOut(rule.style.strikeout); ++ if (rule.style.monospace) { ++ f.setStyleHint(QFont::Monospace); ++ } ++ + if ( rule.style.color.isValid() ) + lex->setColor(rule.style.color, element); + if ( rule.style.bgColor.isValid() ) +@@ -643,7 +673,7 @@ void LSInterior::applyCustomStyle(const QString& name, const QFont& font) { + + QsciLexer* LSInterior::lexer(const QString& name) { + if ( lexers_.contains(name) ) { +- // return lexer with this name ++ // return lexer with this name + // if it already exists + return lexers_[name]; + } +@@ -774,7 +804,11 @@ QsciLexer* LSInterior::lexer(const QString& name) { + // TODO/FIXME: special lexer. Qorus has to inherit Qore + newLexer = new QsciLexerPerl(); + } +- ++ ++ else if ( name.compare("Remarkup") == 0 ) { ++ newLexer = new QsciLexerRemarkup(); ++ } ++ + if ( newLexer != 0 ) { + lexers_[name] = newLexer; + if ( !name.isEmpty() && name.compare("none") != 0 ) { +@@ -811,7 +845,7 @@ QString LexerStorage::lexerName(const QString& fName) { + // try to guess lexer using file name + QStringList types = lexersList(); + types.removeAll("none"); +- ++ + foreach(QString type, types ) { + QStringList patterns = FileTypeSettings::getFileNamePatterns(type); + foreach (QString pattern, patterns) { +@@ -824,7 +858,7 @@ QString LexerStorage::lexerName(const QString& fName) { + } + } + +- // file name didn't match to any pattern - try to ++ // file name didn't match to any pattern - try to + // analize file's 1st line + + QFile file(fName); +@@ -866,14 +900,14 @@ QsciLexer* LexerStorage::lexerByFileName(const QString& fileName) { + + QStringList LexerStorage::lexersList() const { + QStringList list; +- list << "none" << "Ada" << "Asm" << "Bash" << "Batch" << "C++" << "C#" +- << "CMake" << "CSS" << "D" << "Diff" +- ++ list << "none" << "Ada" << "Asm" << "Bash" << "Batch" << "C++" << "C#" ++ << "CMake" << "CSS" << "D" << "Diff" ++ + #ifdef JUFF_FORTRAN_LEXER + << "Fortran" + #endif // JUFF_FORTRAN_LEXER + +- << "Haskell" << "HTML" << "IDL" << "Java" << "JavaScript" << "Lisp" ++ << "Haskell" << "HTML" << "IDL" << "Java" << "JavaScript" << "Lisp" + << "Lua" << "Makefile" << "Matlab" << "NBC" << "NSIS" << "NXC" + + #ifdef JUFF_PASCAL_LEXER +@@ -886,7 +920,7 @@ QStringList LexerStorage::lexersList() const { + << "Properties" + #endif // JUFF_PROPERTIES_LEXER + +- << "Python" << "PHP" << "Ruby" << "SQL" ++ << "Python" << "PHP" << "Ruby" << "Remarkup" <<"SQL" + + #ifdef JUFF_TCL_LEXER + << "TCL" +@@ -901,7 +935,7 @@ QStringList LexerStorage::lexersList() const { + void LexerStorage::updateLexers(const QFont& font) { + // if ( font == lsInt_->curFont_ ) + // return; +- ++ + QMap::iterator it = lsInt_->lexers_.begin(); + while (it != lsInt_->lexers_.end()) { + lsInt_->applyCustomStyle(it.key(), font); +diff --git a/src/app/qsci/SciDoc.cpp b/src/app/qsci/SciDoc.cpp +index 284ac5d..93596e6 100644 +--- a/src/app/qsci/SciDoc.cpp ++++ b/src/app/qsci/SciDoc.cpp +@@ -88,39 +88,39 @@ SciDoc::Eol guessEol(const QString& fileName) { + std::pair guessIndentation(const QString& fileName) { + bool use_tabs = EditorSettings::get(EditorSettings::UseTabs); // Stores final result whether document uses tabs for indentation (start with default) + int indentation_width = EditorSettings::get(EditorSettings::TabWidth); // Stores final result what indentation width the document uses (start with default) +- ++ + if ( !Juff::Document::isNoname(fileName) && EditorSettings::get(EditorSettings::AutoDetectIndentation) ) { + QFile file(fileName); + if ( file.open(QIODevice::ReadOnly) ) { + int tab_block_count = 0; // Counter of how many text blocks start with tabs + int space_block_count = 0; // Counter of how many text blocks start with spaces +- ++ + QString prev_indent(""); // Stores prior line's indentation string + int prev_spaces; // Stores the prior line's leading spaces +- ++ + std::map space_counts; // Stores the number of indentation increases of various sizes in spaces +- space_counts[1] = space_counts[2] = space_counts[3] = space_counts[4] = space_counts[5] = space_counts[6] = space_counts[7] = space_counts[8] = 0; +- ++ space_counts[1] = space_counts[2] = space_counts[3] = space_counts[4] = space_counts[5] = space_counts[6] = space_counts[7] = space_counts[8] = 0; ++ + QRegExp blank_re("[\t ]*\r?\n?"); // Checks if line is blank + QRegExp indent_re("^[\t ]*"); // Finds all leading whitespace + QRegExp tabs_re("^\t*"); // Finds leading tabs + QRegExp spaces_re("^ *"); // Finds leading spaces +- ++ + // Collect indentation statistics + for ( int i = 0; !file.atEnd() && i < 1000; ++i ) { // Stop at end of document or 1000 lines, whichever comes first + QString line = QString::fromLocal8Bit(file.readLine().constData()); +- ++ + // Skip blank lines, as they are likely to have malformed indentation + if (blank_re.exactMatch(line)) + continue; +- ++ + // Skip subsequent lines with identical indentation. + // In other words, we're counting blocks of indented text, not lines + indent_re.exactMatch(line); + if (prev_indent == indent_re.cap(0)) + continue; + prev_indent = indent_re.cap(0); +- ++ + // Check for a leading tab + tabs_re.exactMatch(line); + if (tabs_re.matchedLength() > 0) { +@@ -128,7 +128,7 @@ std::pair guessIndentation(const QString& fileName) { + prev_spaces = 0; + continue; + } +- ++ + // Check for a leading space + spaces_re.exactMatch(line); + if ( spaces_re.matchedLength() > 0 ) { +@@ -139,7 +139,7 @@ std::pair guessIndentation(const QString& fileName) { + prev_spaces = spaces_re.matchedLength(); + } + } +- ++ + // Guess indentation style based on the collected statistics + if (tab_block_count > 0 || space_block_count > 0) { // If we don't have any statistics to work with, stick with defaults + if ( (tab_block_count * 2) > space_block_count ) { // Heuristic: even smaller numbers of leading tabs typically still indicate that tabs are the indentation character +@@ -148,14 +148,14 @@ std::pair guessIndentation(const QString& fileName) { + else { + // If document uses spaces... + use_tabs = false; +- ++ + // Guess indentation width in spaces + int width = 1; + for ( int i = 2; i <= 8; ++i ) { + if ( space_counts[width] <= space_counts[i] ) // Barely favor larger widths (<= instead of <) + width = i; + } +- ++ + // Heuristic: if there's only one example of an indent, skip and stick with the default + if ( space_counts[width] > 1) + indentation_width = width; +@@ -164,7 +164,7 @@ std::pair guessIndentation(const QString& fileName) { + } + file.close(); + } +- ++ + return std::make_pair(use_tabs, indentation_width); + } + +@@ -236,7 +236,7 @@ public: + edit1_->setDocument(edit2_->document()); + w->setFocusProxy(spl_); + spl_->setSizes(QList() << 0 << spl_->height()); +- ++ + hlTimer_ = new QTimer( w ); + hlTimer_->setSingleShot( true ); + connect(hlTimer_, SIGNAL(timeout()), w, SLOT(highlightWord())); +@@ -323,10 +323,10 @@ SciDoc::SciDoc(const QString& fileName) : Juff::Document(fileName) { + setIndentationsUseTabs(indentation.first); + setTabWidth(indentation.second); + } +- +- +- +- ++ ++ ++ ++ + setLexer(lexName); + + applySettings(); +@@ -1379,8 +1379,8 @@ void SciDoc::applySettings() { + QsciScintilla* edit = edits[i]; + + // indents +- //edit->setTabWidth(EditorSettings::get(EditorSettings::TabWidth)); +- //edit->setIndentationsUseTabs(EditorSettings::get(EditorSettings::UseTabs)); ++ edit->setTabWidth(EditorSettings::get(EditorSettings::TabWidth)); ++ edit->setIndentationsUseTabs(EditorSettings::get(EditorSettings::UseTabs)); + edit->setBackspaceUnindents(EditorSettings::get(EditorSettings::BackspaceUnindents)); + + // colors +@@ -1562,4 +1562,9 @@ Juff::SessionParams SciDoc::sessionParams() const { + return params; + } + ++JuffScintilla* ++SciDoc::getCurrentEditor() const{ ++ return int_->curEdit_; ++} ++ + } +diff --git a/src/app/qsci/SciDoc.h b/src/app/qsci/SciDoc.h +index 58edad1..69a7547 100644 +--- a/src/app/qsci/SciDoc.h ++++ b/src/app/qsci/SciDoc.h +@@ -155,6 +155,9 @@ private: + + class Interior; + Interior* int_; ++ ++public: ++ JuffScintilla* getCurrentEditor() const; + }; + + } diff --git a/documentation-tools/juffed/postcommit b/documentation-tools/juffed/postcommit new file mode 100755 index 0000000..7669285 --- /dev/null +++ b/documentation-tools/juffed/postcommit @@ -0,0 +1 @@ +git diff 5ba17f9 HEAD ./src/app/ ./src/lib/ ./cmake/ plugins/CMakeLists.txt ./CMakeLists.txt > /private/prg/code/xreate/documentation-tools/juffed/patches diff --git a/documentation/Articles/declarative_patterns.remarkup b/documentation/Articles/declarative_patterns.remarkup index 1037818..762972b 100644 --- a/documentation/Articles/declarative_patterns.remarkup +++ b/documentation/Articles/declarative_patterns.remarkup @@ -1,41 +1,38 @@ In addition to a classic object-oriented common patterns and practices there are several areas and problems not very easy and conveniently expressed by object oriented approach. Few of so called declarative patterns are presented below : * **Dependency resolution** Starting at some level of complexity every software project usually faces need of managing dependencies of some kind like package dependencies, components and versions dependency. Dependencies are easily represented by declarative means and moreover usually do not change drastically at runtime. Thus dependency management is good candidate for static or comile-time resolution. See [[articles/declarative_patterns#dependency-resolution|details]]. * **Demand and supply** A big amount of a problems could be expressed in terms of supply and demand of interacting components. See [[articles/declarative_patterns#demand-and-supply|details]]. * **Share or joint use**: Examples: first/last use determination, share use planning and allocation(memory, etc).See for example [[concepts/usage| resources usage]]. ===Dependency resolution=== * **Verification and Adaptation** TODO expand on verification and adaptation. Upstream/downstream * **Preferences** Abitility to express preferences(like/dislike) allows recognize situation ... * **Distibuted information** Information gathered from different sources. ===Demand and supply=== -dssdsds - ===Share or joint use=== -bdfvfsl; \ No newline at end of file diff --git a/documentation/Aspects/Security and safety/access_control.remarkup b/documentation/Aspects/Security_and_safety/access_control.remarkup similarity index 100% rename from documentation/Aspects/Security and safety/access_control.remarkup rename to documentation/Aspects/Security_and_safety/access_control.remarkup diff --git a/documentation/Aspects/Security and safety/bugs_and_review_management.remarkup b/documentation/Aspects/Security_and_safety/bugs_and_review_management.remarkup similarity index 100% rename from documentation/Aspects/Security and safety/bugs_and_review_management.remarkup rename to documentation/Aspects/Security_and_safety/bugs_and_review_management.remarkup diff --git a/documentation/Aspects/Security and safety/component_guaranties.remarkup b/documentation/Aspects/Security_and_safety/component_guaranties.remarkup similarity index 100% rename from documentation/Aspects/Security and safety/component_guaranties.remarkup rename to documentation/Aspects/Security_and_safety/component_guaranties.remarkup diff --git a/documentation/Aspects/Security and safety/index.remarkup b/documentation/Aspects/Security_and_safety/index.remarkup similarity index 100% rename from documentation/Aspects/Security and safety/index.remarkup rename to documentation/Aspects/Security_and_safety/index.remarkup diff --git a/documentation/Aspects/Security and safety/krivyakin.remarkup b/documentation/Aspects/Security_and_safety/krivyakin.remarkup similarity index 100% rename from documentation/Aspects/Security and safety/krivyakin.remarkup rename to documentation/Aspects/Security_and_safety/krivyakin.remarkup diff --git a/documentation/Aspects/Security and safety/metrics.remarkup b/documentation/Aspects/Security_and_safety/metrics.remarkup similarity index 100% rename from documentation/Aspects/Security and safety/metrics.remarkup rename to documentation/Aspects/Security_and_safety/metrics.remarkup diff --git a/documentation/Aspects/Security and safety/pointers_safety.remarkup b/documentation/Aspects/Security_and_safety/pointers_safety.remarkup similarity index 100% rename from documentation/Aspects/Security and safety/pointers_safety.remarkup rename to documentation/Aspects/Security_and_safety/pointers_safety.remarkup diff --git a/documentation/Aspects/Security and safety/unit-tests.remarkup b/documentation/Aspects/Security_and_safety/unit-tests.remarkup similarity index 100% rename from documentation/Aspects/Security and safety/unit-tests.remarkup rename to documentation/Aspects/Security_and_safety/unit-tests.remarkup diff --git a/documentation/index.remarkup b/documentation/index.remarkup index cb900ee..596c373 100644 --- a/documentation/index.remarkup +++ b/documentation/index.remarkup @@ -1,19 +1,18 @@ Main idea behind Xreate is to employ logic inference to address practical day-to-day programming problems. Goals: * Optimization * Security and safety * Virtualization * High-level To begin with, in Xreate we treat defininiton of "high-level" as practical term, meaning ability to adapt, alter, adjust component or whole program to comply with new changed requirements or environment in general. The more "high-level" techniques language provides, the less efforts need to be done for such transformation, given all else things being equal. TODO To reduce high-level or abstraction penalty .... * * Code readability -* Literary programming - +* Literary programming \ No newline at end of file diff --git a/installation/docker/Dockerfile b/installation/docker/Dockerfile index 115ffe5..731d7c4 100644 --- a/installation/docker/Dockerfile +++ b/installation/docker/Dockerfile @@ -1,39 +1,45 @@ FROM opensuse-tumbleweed MAINTAINER Melnychenko Volodymyr -ARG CLANG_VERSION=3_8 +ARG LLVM_VERSION=3_8 ARG BOOST_VERSION=_1_61 ARG CLASP_VERSION=a363d9 RUN zypper in -y \ - boost$BOOST_VERSION-devel clang$CLANG_VERSION-devel llvm$CLANG_VERSION-gold gcc6-c++ \ - tbb-devel cmake git bison re2c scons unzip libgtest0 googletest-devel libxml2-devel wget + boost$BOOST_VERSION-devel clang$LLVM_VERSION-devel llvm$LLVM_VERSION-gold gcc6-c++ \ + tbb-devel cmake git libgtest0 googletest-devel libxml2-devel &&\ + wget bison re2c scons unzip ## COCO WORKDIR /opt/coco-cpp RUN wget http://www.ssw.uni-linz.ac.at/Coco/CPP/CocoSourcesCPP.zip &&\ unzip ./CocoSourcesCPP.zip &&\ g++-6 *.cpp -o Coco -g -Wall # POTASSCO WORKDIR /opt/potassco/clingo/ RUN git clone https://github.com/potassco/clingo.git ./ &&\ git reset --hard $CLASP_VERSION ADD patches/potassco-patch-$CLASP_VERSION . RUN git apply potassco-patch-$CLASP_VERSION &&\ scons configure --build-dir=debug &&\ sed -i "s/CXXFLAGS = \[\(.*\)\]/CXXFLAGS = \['-fPIC', \1\]/" build/debug.py &&\ sed -i "s/CXX = 'c++'/CXX = 'g++-6'/" build/debug.py &&\ sed -i "s/WITH_LUA = 'auto'/WITH_LUA = None/" build/debug.py &&\ sed -i "s/WITH_PYTHON = 'auto'/WITH_PYTHON = None/" build/debug.py &&\ cat build/debug.py &&\ - scons --build-dir=debug -# sed -i "s/'-std=c++11'/'-std=c++14'/" build/debug.py + scons --build-dir=debug &&\ + sed -i "s/'-std=c++11'/'-std=c++14'/" build/debug.py # XREATE -WORKDIR /opt/xreate-build -RUN git clone https://pgess@bitbucket.org/pgess/xreate.git ../xreate &&\ - cmake -DBUILD_XREATE_TESTS=1 ../xreate/cpp &&\ +WORKDIR /opt/xreate +RUN git clone --recursive https://pgess@bitbucket.org/pgess/xreate.git ./ + +RUN cd vendors/jeayeson/ &&\ + ./configure &&\ + mkdir ../../build &&\ + cd ../../build &&\ + cmake -DBUILD_XREATE_TESTS=1 ../cpp &&\ make -j4 VERBOSE=1 diff --git a/scripts/testspass/Containers_Implementation_LinkedList1-data.xml b/scripts/testspass/Containers_Implementation_LinkedList1-data.xml new file mode 100644 index 0000000..316dac4 --- /dev/null +++ b/scripts/testspass/Containers_Implementation_LinkedList1-data.xml @@ -0,0 +1,1269 @@ + + + + 2015-03-17T14:07:08.6318527522016-09-03T17:05:20.767232585PT3H45M59S70LibreOffice/5.2.0.4$Linux_X86_64 LibreOffice_project/20m0$Build-4 + + + 0 + 0 + 31302 + 14580 + true + false + + + view2 + 21310 + 12926 + 0 + 0 + 31300 + 14579 + 0 + 1 + false + 100 + false + + + + + false + true + true + true + 0 + true + true + + false + false + false + false + false + false + false + false + false + false + false + false + true + true + false + false + true + true + false + false + + false + false + true + false + false + + false + false + false + false + true + 2231132 + false + false + true + false + true + true + false + true + 0 + false + true + high-resolution + false + false + + + en + US + + + + + + false + true + true + true + + true + false + false + false + true + false + false + false + + false + false + 1581257 + false + 1 + true + false + false + 0 + false + false + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Preface + Test1 + Test2 + + + + brvnfklvnrlvrkm + + + + + + Goals: + + + DFWN/AFKLJEF;EKF;E’ + + + FDNKADFfdnklfmkfk,d + + + + + + + + A + + + B + + + C + + + + + 122343543 + 14627895742384981230T5834926573989RE3208572193[845486597023P4UP3E; + + + + \ No newline at end of file diff --git a/tools/phabricator/administration/docker-compose.yml b/tools/phabricator/administration/docker-compose.yml index 0a5ce3d..7de0f56 100644 --- a/tools/phabricator/administration/docker-compose.yml +++ b/tools/phabricator/administration/docker-compose.yml @@ -1,24 +1,26 @@ version: '2' services: phabricator_db: image: yesnault/docker-phabricator-mysql + ports: + - '8082:3306' phabricator: image: yesnault/docker-phabricator links: - "phabricator_db:database" depends_on: - phabricator_db ports: - '8081:80' volumes: - phabricator_volume:/opt/ volumes: phabricator_volume: driver: local diff --git a/tools/phabricator/patches/all/libphutil/1-blockrule-syntax.patch b/tools/phabricator/patches/all/1-blockrule-syntax.patch similarity index 100% rename from tools/phabricator/patches/all/libphutil/1-blockrule-syntax.patch rename to tools/phabricator/patches/all/1-blockrule-syntax.patch diff --git a/tools/phabricator/patches/all/phabricator/1-remarkup-linebreaks-disabled.patch b/tools/phabricator/patches/all/phabricator/1-remarkup-linebreaks-disabled.patch deleted file mode 100644 index 59e15b2..0000000 --- a/tools/phabricator/patches/all/phabricator/1-remarkup-linebreaks-disabled.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/src/infrastructure/markup/PhabricatorMarkupEngine.php -+++ b/src/infrastructure/markup/PhabricatorMarkupEngine.php -@@ -454,7 +454,7 @@ final class PhabricatorMarkupEngine extends Phobject { - 'uri.full' => false, - 'syntax-highlighter.engine' => PhabricatorEnv::getEnvConfig( - 'syntax-highlighter.engine'), -- 'preserve-linebreaks' => true, -+ 'preserve-linebreaks' => false, - ); - } diff --git a/tools/phabricator/patches/local/libphutil/1-blockrules.patch b/tools/phabricator/patches/local/1-blockrules.patch similarity index 100% rename from tools/phabricator/patches/local/libphutil/1-blockrules.patch rename to tools/phabricator/patches/local/1-blockrules.patch diff --git a/vendors/jeayeson b/vendors/jeayeson index 20389e5..bf3e2ee 160000 --- a/vendors/jeayeson +++ b/vendors/jeayeson @@ -1 +1 @@ -Subproject commit 20389e5ac679f08f0a268ef0886920b1ae3d2d9f +Subproject commit bf3e2ee13800d0690d5ed0138ac0af6d2f353bbc