diff options
Diffstat (limited to 'debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten')
12 files changed, 1309 insertions, 0 deletions
diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMakeLists.txt b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMakeLists.txt new file mode 100644 index 00000000..72b6efa3 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMakeLists.txt @@ -0,0 +1,253 @@ +cmake_minimum_required(VERSION 3.0.0) + +# ------------------------------------------------------------------------------ + + +if(DEFINED ENV{EMSCRIPTEN}) + SET(emscripten_root_path "$ENV{EMSCRIPTEN}") +else() + find_file(EMCC_EXECUTABLE emcc HINTS "/usr/lib/emscripten") + if(EXISTS ${EMCC_EXECUTABLE}) + get_filename_component(emscripten_root_path ${EMCC_EXECUTABLE} DIRECTORY) + endif() +endif() + +# Abort if not found. +if ("${emscripten_root_path}" STREQUAL "") + MESSAGE(FATAL_ERROR "Could not locate the Emscripten directory via the \ + EMSCRIPTEN environment variable! Set it up or pass \ + -Demscripten_root_path=xxx to CMake to specify the \ + directory.") +endif() + +SET(CMAKE_TOOLCHAIN_FILE "${emscripten_root_path}/cmake/Modules/Platform/Emscripten.cmake") + +SET(project_name "libUncrustify") +PROJECT(${project_name}) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +#get parent folder, add src +GET_FILENAME_COMPONENT(unc_projdir ${CMAKE_CURRENT_LIST_DIR} DIRECTORY) + +# ------------------------------------------------------------------------------ + +include(CheckCXXCompilerFlag) +include(CheckIncludeFileCXX) +include(CheckSymbolExists) +include(CheckCXXSymbolExists) +include(CheckTypeSize) + +find_package(PythonInterp REQUIRED) + +# +# Determine config +# +if(WIN32) + # Windows builds use src/windows_compat.h instead of config.h +else() + # Generate config.h + set(avail_headers "") + + set(headers + inttypes.h + memory.h + stdint.h + stdlib.h + strings.h + string.h + sys/stat.h + sys/types.h + unistd.h + utime.h + ) + foreach(header ${headers}) + string(TOUPPER "${header}" header_uc) + string(REGEX REPLACE "[^A-Z0-9_]" "_" include_var "HAVE_${header_uc}") + check_include_file_cxx("${header}" ${include_var}) + if(${include_var}) + list(APPEND avail_headers ${header}) + endif() + unset(include_var) + unset(header_uc) + endforeach() + unset(headers) + + check_include_file("stdbool.h" HAVE_STDBOOL_H) + + set(symbols + memset + strcasecmp + strchr + strdup + strerror + strtol + strtoul + ) + foreach(symbol ${symbols}) + string(TOUPPER "${symbol}" symbol_uc) + string(REGEX REPLACE "[^A-Z0-9_]" "_" symbol_var "HAVE_${symbol_uc}") + check_cxx_symbol_exists("${symbol}" "${avail_headers}" ${symbol_var}) + unset(symbol_var) + unset(symbol_uc) + endforeach() + unset(symbols) + + unset(avail_headers) + + check_type_size(_Bool _BOOL LANGUAGE C) + + configure_file("${unc_projdir}/src/config.h.in" config.h @ONLY) +endif() + +# +# Generate uncrustify_version.h +# + +set(CURRENT_VERSION "Uncrustify-0.69.0_f") + +option(NoGitVersionString "Do not use make_version.py and git to build a version string" OFF) +if(NoGitVersionString) + configure_file("${unc_projdir}/src/uncrustify_version.h.in" "${PROJECT_BINARY_DIR}/uncrustify_version.h" @ONLY) +else() + # Add target to generate version header; + # do this every build to ensure git SHA is up to date + add_custom_target(generate_version_header + ${CMAKE_COMMAND} + -D PYTHON_EXECUTABLE:STRING=${PYTHON_EXECUTABLE} + -D SOURCE_DIR:PATH="${unc_projdir}" + -D INPUT:PATH="${unc_projdir}/src/uncrustify_version.h.in" + -D OUTPUT:PATH="${PROJECT_BINARY_DIR}/uncrustify_version.h" + -D CURRENT_VERSION:STRING="CURRENT_VERSION" + -P ${unc_projdir}/cmake/GenerateVersionHeader.cmake + COMMENT "Generating version header" + ) + set_source_files_properties( + "${PROJECT_BINARY_DIR}/uncrustify_version.h" + PROPERTIES GENERATED TRUE + ) +endif() + +# +# Generate token_names.h +# +add_custom_command( + OUTPUT "${PROJECT_BINARY_DIR}/token_names.h" + COMMAND ${CMAKE_COMMAND} + "-Dsrc_file=${unc_projdir}/src/token_enum.h" + "-Ddst_file=${PROJECT_BINARY_DIR}/token_names.h" + -P "${unc_projdir}/cmake/GenerateTokenNames.cmake" + MAIN_DEPENDENCY "${unc_projdir}/src/token_enum.h" + COMMENT "Generating token_names.h" +) + +# Set up commands for generated source files +function(py_gen OUTPUT SCRIPT INPUT) + set(out "${PROJECT_BINARY_DIR}/src/${OUTPUT}") + set(deps "${unc_projdir}/src/${INPUT}") + get_filename_component(outdir "${out}" DIRECTORY) + foreach(arg IN LISTS ARGN) + list(APPEND deps "${unc_projdir}/src/${arg}") + endforeach() + + add_custom_command( + OUTPUT "${out}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${outdir}" + COMMAND ${PYTHON_EXECUTABLE} + "${unc_projdir}/scripts/${SCRIPT}" + "${out}" + ${deps} + DEPENDS ${deps} "${unc_projdir}/scripts/${SCRIPT}" + MAIN_DEPENDENCY ${unc_projdir}/src/${INPUT} + COMMENT "Generating ${OUTPUT}" + ) +endfunction() + +py_gen(punctuator_table.h + make_punctuator_table.py + symbols_table.h +) + +py_gen(options.cpp + make_options.py + options.h + options.cpp.in +) + +py_gen(option_enum.h + make_option_enum.py + option.h + option_enum.h.in +) + +py_gen(option_enum.cpp + make_option_enum.py + option.h + option_enum.cpp.in +) + +# ------------------------------------------------------------------------------ + +FILE(GLOB unc_infiles "${unc_projdir}/src/*.cpp") + +ADD_EXECUTABLE(${project_name} + ${unc_infiles} + ${unc_projdir}/src/token_enum.h + ${unc_projdir}/src/symbols_table.h + ${unc_projdir}/src/options.h + ${unc_projdir}/src/option.h + ${PROJECT_BINARY_DIR}/src/options.cpp + ${PROJECT_BINARY_DIR}/src/option_enum.cpp + ${PROJECT_BINARY_DIR}/src/option_enum.h + ${PROJECT_BINARY_DIR}/uncrustify_version.h + ${unc_projdir}/src/option_enum.cpp.in + ${unc_projdir}/src/option_enum.h.in + ${unc_projdir}/src/options.cpp.in +) +add_dependencies(${project_name} generate_version_header) + +include_directories( + ${PROJECT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/src + ${unc_projdir}/src +) + +SET(unc_compile_flags "--bind -O3") +SET_TARGET_PROPERTIES(${project_name} + PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED YES + CXX_EXTENSIONS NO + COMPILE_FLAGS "${unc_compile_flags}" + LINK_FLAGS "${unc_compile_flags} \ + -s TOTAL_MEMORY=67108864 \ + -s ALLOW_MEMORY_GROWTH=1 \ + -s VERBOSE=1 \ + -s MODULARIZE=1 \ + -s EXPORT_NAME=\"'${project_name}'\" \ + -s ERROR_ON_UNDEFINED_SYMBOLS=1 \ + -s 'EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF8ToString\",\"stringToUTF8\",\"lengthBytesUTF8\", \"writeAsciiToMemory\"]' \ + -s WASM=0\ + --memory-init-file 0\ + --pre-js ${CMAKE_CURRENT_LIST_DIR}/prefix_module.js \ + --post-js ${CMAKE_CURRENT_LIST_DIR}/postfix_module.js \ + ") + +EM_LINK_PRE_JS(${project_name} ${CMAKE_CURRENT_LIST_DIR}/prefix_module.js) +EM_LINK_POST_JS(${project_name} ${CMAKE_CURRENT_LIST_DIR}/postfix_module.js) + +# ------------------------------------------------------------------------------ + +# add file post/pre-fix +add_custom_command(TARGET ${project_name} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -Dunc_targetfile:FILEPATH=$<TARGET_FILE:${project_name}> + -P "${CMAKE_CURRENT_LIST_DIR}/CMake_catFiles.cmake" +) + +add_custom_target(emscripten_test + COMMAND ${CMAKE_COMMAND} -Dunc_targetfile:FILEPATH=$<TARGET_FILE:${project_name}> + -Dunc_projdir:FILEPATH=${unc_projdir} + -P "${CMAKE_CURRENT_LIST_DIR}/CMake_emscripten_test.cmake" + COMMENT "Starting libUncrustify.js tests:" +) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMake_catFiles.cmake b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMake_catFiles.cmake new file mode 100644 index 00000000..c637ea24 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMake_catFiles.cmake @@ -0,0 +1,19 @@ +if(NOT unc_targetfile) + MESSAGE(FATAL_ERROR "unc_targetfile param not defined") +endif() + +function(cat IN_FILE OUT_FILE) + file(READ ${IN_FILE} CONTENTS) + file(APPEND ${OUT_FILE} "${CONTENTS}") +endfunction() + + +SET(unc_tmpfile "${unc_targetfile}_.tmp") + +file(WRITE "${unc_tmpfile}" "") + +cat("${CMAKE_CURRENT_LIST_DIR}/prefix_file" "${unc_tmpfile}") +cat("${unc_targetfile}" "${unc_tmpfile}") +cat("${CMAKE_CURRENT_LIST_DIR}/postfix_file" "${unc_tmpfile}") + +file(RENAME "${unc_tmpfile}" "${unc_targetfile}") diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMake_emscripten_test.cmake b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMake_emscripten_test.cmake new file mode 100644 index 00000000..a37ee945 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/CMake_emscripten_test.cmake @@ -0,0 +1,24 @@ +if(NOT unc_targetfile) + MESSAGE(FATAL_ERROR "unc_targetfile param not defined") +endif() +if(NOT unc_projdir ) + MESSAGE(FATAL_ERROR "unc_projdir param not defined") +endif() + +message(STATUS "unc_targetfile: ${unc_targetfile}") +message(STATUS "test_dir: ${unc_projdir}/emscripten/test/") +message(STATUS "-----------------------------------------------------------------------------") + + +find_package(PythonInterp REQUIRED) +execute_process( + COMMAND ${PYTHON_EXECUTABLE} "${unc_projdir}/emscripten/test/run_tests.py" "${unc_targetfile}" "${unc_projdir}/emscripten/test/" + WORKING_DIRECTORY ${unc_projdir} + RESULT_VARIABLE make_version_error + OUTPUT_VARIABLE make_version_output +) +MESSAGE(STATUS ${make_version_output}) + +if(NOT ${make_version_error} EQUAL 0) + message(FATAL_ERROR "errno: ${make_version_error}") +endif() diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/README.md b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/README.md new file mode 100644 index 00000000..22012383 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/README.md @@ -0,0 +1,42 @@ +building +-------------------------------------------------------------------------------- + **dependencies**: cmake, python, clang, emscripten, node + + 1. create a `build` directory somewhere + 2. inside this directory call `cmake <CMakeLists.txt directory>` and `make`<br> + (the CMakeLists.txt file is located in <uncrustify_root_dir>/emscripten) + +Optionally the generated libUncrustify.js can be tested via `make emscripten_test` + +_libUncrustify.js_ example usage +-------------------------------------------------------------------------------- +1. load module instance: + ```js + var uncrustify = libUncrustify(); + ``` + +2. set option settings either one at a time with: + ```js + uncrustify.set_option( "optionNameString", "newOptionValueString" ); + ``` + + or a whole bunch via: + + ```js + uncrustify.loadConfig( "configFileFormatString" ) + ``` + +3. set the language of the to be formated file string + ```js + uncrustify.set_language( languageInt ); + ``` + +4. format a file string: + ```js + var uncrustyFileString = uncrustify.uncrustify( "crustyFileString" ); + ``` + +5. delete initialized module instance: + ```js + uncrustify.destruct(); + ``` diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/build.sh b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/build.sh new file mode 100755 index 00000000..df4b6fe3 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/build.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# script to build without cmake, +# manually generate header files usually created by CMake, +# past those inside Uncrustifys 'src' dir +# run this script in the 'emscripten' dir + +sh_dir="$(dirname "$(readlink -f "$0")")" +outTmp="temp.bak" +out="libUncrustify.js" + +#https://github.com/kripken/emscripten/blob/master/src/settings.js + +em++ -O3 \ + ${COMMENT# initialy increase memory for big input files } \ + -s TOTAL_MEMORY=67108864 \ + ${COMMENT# let the memory grow dynamically if even more is needed } \ + -s ALLOW_MEMORY_GROWTH=1 \ + -s VERBOSE=1 \ + -s MODULARIZE=1 \ + -s EXPORT_NAME="'libUncrustify'" \ + -s ERROR_ON_UNDEFINED_SYMBOLS=1 \ + -s ALLOW_MEMORY_GROWTH=1 \ + -s "EXTRA_EXPORTED_RUNTIME_METHODS=['UTF8ToString', 'stringToUTF8', 'lengthBytesUTF8', 'writeAsciiToMemory']" \ + --bind \ + --pre-js prefix_module.js \ + --post-js postfix_module.js \ + ${COMMENT# TODO: handle async ajax load to enable this } \ + --memory-init-file 0 \ + -o $out \ + ../src/*.cpp \ +&& cat "./prefix_file" "$out" "./postfix_file" > "$outTmp" \ +&& mv "$outTmp" "$out" \ +&& ./test/run_tests.py "$sh_dir/libUncrustify.js" "$sh_dir/test" diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/libUncrustify.d.ts b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/libUncrustify.d.ts new file mode 100644 index 00000000..1e7b7fb6 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/libUncrustify.d.ts @@ -0,0 +1,674 @@ +/** +* Emscriptens interface for bound std::vectors +*/ +interface EmscriptenVector< T > +{ + get( i : number ) : T + push_back( elem : T ); + resize( size : number, elem : T ); + size() : number; + get() : T; + set( elem : T ); +//TODO: +// isAliasOf(); +// clone(); +// delete(); +// isDeleted() : boolean; +// deleteLater(); +} + +/** +* Emscriptens interface for bound enum types +*/ +interface EmscriptenEnumType +{ + //! returns list with value objects of an enum + values() : EmscriptenVector<EmscriptenEnumTypeObject>; +} + +/** +* Emscriptens interface for bound enum type value objects +*/ +interface EmscriptenEnumTypeObject +{ + //! return value of an enum value object + value : number; +} + +declare namespace LibUncrustify +{ + // <editor-fold desc="enums"> + + // Example how to iterate below options : forin iterate Options, + // skip 'values' key, [ s : Options_STRING ] : EmscriptenEnumTypeObject; + + // region enum bindings + export interface OptionTypeValue extends EmscriptenEnumTypeObject {} + export interface OptionType extends EmscriptenEnumType + { + BOOL : OptionTypeValue; + IARF : OptionTypeValue; + LINEEND : OptionTypeValue; + TOKENPOS : OptionTypeValue; + NUM : OptionTypeValue; + UNUM : OptionTypeValue; + STRING : OptionTypeValue; + } + + export interface IARFValue extends EmscriptenEnumTypeObject {} + export interface IARF extends EmscriptenEnumType + { + IGNORE : IARFValue; + ADD : IARFValue; + REMOVE : IARFValue; + FORCE : IARFValue; + } + + export interface LineEndValue extends EmscriptenEnumTypeObject {} + export interface LineEnd extends EmscriptenEnumType + { + LF : LineEndValue; + CRLF : LineEndValue; + CR : LineEndValue; + AUTO : LineEndValue; + } + + export interface TokenPosValue extends EmscriptenEnumTypeObject {} + export interface TokenPos extends EmscriptenEnumType + { + IGNORE : TokenPosValue; + BREAK : TokenPosValue; + FORCE : TokenPosValue; + LEAD : TokenPosValue; + TRAIL : TokenPosValue; + JOIN : TokenPosValue; + LEAD_BREAK : TokenPosValue; + LEAD_FORCE : TokenPosValue; + TRAIL_BREAK : TokenPosValue; + TRAIL_FORCE : TokenPosValue; + } + + export interface LogTypeValue extends EmscriptenEnumTypeObject {} + export interface LogType extends EmscriptenEnumType + { + SYS : LogTypeValue; + ERR : LogTypeValue; + WARN : LogTypeValue; + NOTE : LogTypeValue; + INFO : LogTypeValue; + DATA : LogTypeValue; + FILELIST : LogTypeValue; + LINEENDS : LogTypeValue; + CASTS : LogTypeValue; + ALBR : LogTypeValue; + ALTD : LogTypeValue; + ALPP : LogTypeValue; + ALPROTO : LogTypeValue; + ALNLC : LogTypeValue; + ALTC : LogTypeValue; + ALADD : LogTypeValue; + ALASS : LogTypeValue; + FVD : LogTypeValue; + FVD2 : LogTypeValue; + INDENT : LogTypeValue; + INDENT2 : LogTypeValue; + INDPSE : LogTypeValue; + INDPC : LogTypeValue; + NEWLINE : LogTypeValue; + PF : LogTypeValue; + STMT : LogTypeValue; + TOK : LogTypeValue; + ALRC : LogTypeValue; + CMTIND : LogTypeValue; + INDLINE : LogTypeValue; + SIB : LogTypeValue; + RETURN : LogTypeValue; + BRDEL : LogTypeValue; + FCN : LogTypeValue; + FCNP : LogTypeValue; + PCU : LogTypeValue; + DYNKW : LogTypeValue; + OUTIND : LogTypeValue; + BCSAFTER : LogTypeValue; + BCSPOP : LogTypeValue; + BCSPUSH : LogTypeValue; + BCSSWAP : LogTypeValue; + FTOR : LogTypeValue; + AS : LogTypeValue; + PPIS : LogTypeValue; + TYPEDEF : LogTypeValue; + VARDEF : LogTypeValue; + DEFVAL : LogTypeValue; + PVSEMI : LogTypeValue; + PFUNC : LogTypeValue; + SPLIT : LogTypeValue; + FTYPE : LogTypeValue; + TEMPL : LogTypeValue; + PARADD : LogTypeValue; + PARADD2 : LogTypeValue; + BLANKD : LogTypeValue; + TEMPFUNC : LogTypeValue; + SCANSEMI : LogTypeValue; + DELSEMI : LogTypeValue; + FPARAM : LogTypeValue; + NL1LINE : LogTypeValue; + PFCHK : LogTypeValue; + AVDB : LogTypeValue; + SORT : LogTypeValue; + SPACE : LogTypeValue; + ALIGN : LogTypeValue; + ALAGAIN : LogTypeValue; + OPERATOR : LogTypeValue; + ASFCP : LogTypeValue; + INDLINED : LogTypeValue; + BCTRL : LogTypeValue; + RMRETURN : LogTypeValue; + PPIF : LogTypeValue; + MCB : LogTypeValue; + BRCH : LogTypeValue; + FCNR : LogTypeValue; + OCCLASS : LogTypeValue; + OCMSG : LogTypeValue; + BLANK : LogTypeValue; + OBJCWORD : LogTypeValue; + CHANGE : LogTypeValue; + CONTTEXT : LogTypeValue; + ANNOT : LogTypeValue; + OCBLK : LogTypeValue; + FLPAREN : LogTypeValue; + OCMSGD : LogTypeValue; + INDENTAG : LogTypeValue; + NFD : LogTypeValue; + JDBI : LogTypeValue; + SETPAR : LogTypeValue; + SETTYP : LogTypeValue; + SETFLG : LogTypeValue; + NLFUNCT : LogTypeValue; + CHUNK : LogTypeValue; + GUY98 : LogTypeValue; + GUY : LogTypeValue; + } + + export interface TokenTypeValue extends EmscriptenEnumTypeObject {} + export interface TokenType extends EmscriptenEnumType + { + NONE : TokenTypeValue; + EOF : TokenTypeValue; + UNKNOWN : TokenTypeValue; + JUNK : TokenTypeValue; + WHITESPACE : TokenTypeValue; + SPACE : TokenTypeValue; + NEWLINE : TokenTypeValue; + NL_CONT : TokenTypeValue; + COMMENT_CPP : TokenTypeValue; + COMMENT : TokenTypeValue; + COMMENT_MULTI : TokenTypeValue; + COMMENT_EMBED : TokenTypeValue; + COMMENT_START : TokenTypeValue; + COMMENT_END : TokenTypeValue; + COMMENT_WHOLE : TokenTypeValue; + COMMENT_ENDIF : TokenTypeValue; + IGNORED : TokenTypeValue; + WORD : TokenTypeValue; + NUMBER : TokenTypeValue; + NUMBER_FP : TokenTypeValue; + STRING : TokenTypeValue; + STRING_MULTI : TokenTypeValue; + IF : TokenTypeValue; + ELSE : TokenTypeValue; + ELSEIF : TokenTypeValue; + FOR : TokenTypeValue; + WHILE : TokenTypeValue; + WHILE_OF_DO : TokenTypeValue; + SWITCH : TokenTypeValue; + CASE : TokenTypeValue; + DO : TokenTypeValue; + SYNCHRONIZED : TokenTypeValue; + VOLATILE : TokenTypeValue; + TYPEDEF : TokenTypeValue; + STRUCT : TokenTypeValue; + ENUM : TokenTypeValue; + ENUM_CLASS : TokenTypeValue; + SIZEOF : TokenTypeValue; + DECLTYPE : TokenTypeValue; + RETURN : TokenTypeValue; + BREAK : TokenTypeValue; + UNION : TokenTypeValue; + GOTO : TokenTypeValue; + CONTINUE : TokenTypeValue; + C_CAST : TokenTypeValue; + CPP_CAST : TokenTypeValue; + D_CAST : TokenTypeValue; + TYPE_CAST : TokenTypeValue; + TYPENAME : TokenTypeValue; + TEMPLATE : TokenTypeValue; + WHERE_SPEC : TokenTypeValue; + ASSIGN : TokenTypeValue; + ASSIGN_NL : TokenTypeValue; + SASSIGN : TokenTypeValue; + ASSIGN_DEFAULT_ARG : TokenTypeValue; + ASSIGN_FUNC_PROTO : TokenTypeValue; + COMPARE : TokenTypeValue; + SCOMPARE : TokenTypeValue; + BOOL : TokenTypeValue; + SBOOL : TokenTypeValue; + ARITH : TokenTypeValue; + SARITH : TokenTypeValue; + CARET : TokenTypeValue; + DEREF : TokenTypeValue; + INCDEC_BEFORE : TokenTypeValue; + INCDEC_AFTER : TokenTypeValue; + MEMBER : TokenTypeValue; + DC_MEMBER : TokenTypeValue; + C99_MEMBER : TokenTypeValue; + INV : TokenTypeValue; + DESTRUCTOR : TokenTypeValue; + NOT : TokenTypeValue; + D_TEMPLATE : TokenTypeValue; + ADDR : TokenTypeValue; + NEG : TokenTypeValue; + POS : TokenTypeValue; + STAR : TokenTypeValue; + PLUS : TokenTypeValue; + MINUS : TokenTypeValue; + AMP : TokenTypeValue; + BYREF : TokenTypeValue; + POUND : TokenTypeValue; + PREPROC : TokenTypeValue; + PREPROC_INDENT : TokenTypeValue; + PREPROC_BODY : TokenTypeValue; + PP : TokenTypeValue; + ELLIPSIS : TokenTypeValue; + RANGE : TokenTypeValue; + NULLCOND : TokenTypeValue; + SEMICOLON : TokenTypeValue; + VSEMICOLON : TokenTypeValue; + COLON : TokenTypeValue; + ASM_COLON : TokenTypeValue; + CASE_COLON : TokenTypeValue; + CLASS_COLON : TokenTypeValue; + CONSTR_COLON : TokenTypeValue; + D_ARRAY_COLON : TokenTypeValue; + COND_COLON : TokenTypeValue; + WHERE_COLON : TokenTypeValue; + QUESTION : TokenTypeValue; + COMMA : TokenTypeValue; + ASM : TokenTypeValue; + ATTRIBUTE : TokenTypeValue; + AUTORELEASEPOOL : TokenTypeValue; + OC_AVAILABLE : TokenTypeValue; + OC_AVAILABLE_VALUE : TokenTypeValue; + CATCH : TokenTypeValue; + WHEN : TokenTypeValue; + WHERE : TokenTypeValue; + CLASS : TokenTypeValue; + DELETE : TokenTypeValue; + EXPORT : TokenTypeValue; + FRIEND : TokenTypeValue; + NAMESPACE : TokenTypeValue; + PACKAGE : TokenTypeValue; + NEW : TokenTypeValue; + OPERATOR : TokenTypeValue; + OPERATOR_VAL : TokenTypeValue; + ASSIGN_OPERATOR : TokenTypeValue; + ACCESS : TokenTypeValue; + ACCESS_COLON : TokenTypeValue; + THROW : TokenTypeValue; + NOEXCEPT : TokenTypeValue; + TRY : TokenTypeValue; + BRACED_INIT_LIST : TokenTypeValue; + USING : TokenTypeValue; + USING_STMT : TokenTypeValue; + USING_ALIAS : TokenTypeValue; + D_WITH : TokenTypeValue; + D_MODULE : TokenTypeValue; + SUPER : TokenTypeValue; + DELEGATE : TokenTypeValue; + BODY : TokenTypeValue; + DEBUG : TokenTypeValue; + DEBUGGER : TokenTypeValue; + INVARIANT : TokenTypeValue; + UNITTEST : TokenTypeValue; + UNSAFE : TokenTypeValue; + FINALLY : TokenTypeValue; + FIXED : TokenTypeValue; + IMPORT : TokenTypeValue; + D_SCOPE : TokenTypeValue; + D_SCOPE_IF : TokenTypeValue; + LAZY : TokenTypeValue; + D_MACRO : TokenTypeValue; + D_VERSION : TokenTypeValue; + D_VERSION_IF : TokenTypeValue; + PAREN_OPEN : TokenTypeValue; + PAREN_CLOSE : TokenTypeValue; + ANGLE_OPEN : TokenTypeValue; + ANGLE_CLOSE : TokenTypeValue; + SPAREN_OPEN : TokenTypeValue; + SPAREN_CLOSE : TokenTypeValue; + FPAREN_OPEN : TokenTypeValue; + FPAREN_CLOSE : TokenTypeValue; + TPAREN_OPEN : TokenTypeValue; + TPAREN_CLOSE : TokenTypeValue; + BRACE_OPEN : TokenTypeValue; + BRACE_CLOSE : TokenTypeValue; + VBRACE_OPEN : TokenTypeValue; + VBRACE_CLOSE : TokenTypeValue; + SQUARE_OPEN : TokenTypeValue; + SQUARE_CLOSE : TokenTypeValue; + TSQUARE : TokenTypeValue; + MACRO_OPEN : TokenTypeValue; + MACRO_CLOSE : TokenTypeValue; + MACRO_ELSE : TokenTypeValue; + LABEL : TokenTypeValue; + LABEL_COLON : TokenTypeValue; + FUNCTION : TokenTypeValue; + FUNC_CALL : TokenTypeValue; + FUNC_CALL_USER : TokenTypeValue; + FUNC_DEF : TokenTypeValue; + FUNC_TYPE : TokenTypeValue; + FUNC_VAR : TokenTypeValue; + FUNC_PROTO : TokenTypeValue; + FUNC_START : TokenTypeValue; + FUNC_CLASS_DEF : TokenTypeValue; + FUNC_CLASS_PROTO : TokenTypeValue; + FUNC_CTOR_VAR : TokenTypeValue; + FUNC_WRAP : TokenTypeValue; + PROTO_WRAP : TokenTypeValue; + MACRO_FUNC : TokenTypeValue; + MACRO : TokenTypeValue; + QUALIFIER : TokenTypeValue; + EXTERN : TokenTypeValue; + DECLSPEC : TokenTypeValue; + ALIGN : TokenTypeValue; + TYPE : TokenTypeValue; + PTR_TYPE : TokenTypeValue; + TYPE_WRAP : TokenTypeValue; + CPP_LAMBDA : TokenTypeValue; + CPP_LAMBDA_RET : TokenTypeValue; + TRAILING_RET : TokenTypeValue; + BIT_COLON : TokenTypeValue; + OC_DYNAMIC : TokenTypeValue; + OC_END : TokenTypeValue; + OC_IMPL : TokenTypeValue; + OC_INTF : TokenTypeValue; + OC_PROTOCOL : TokenTypeValue; + OC_PROTO_LIST : TokenTypeValue; + OC_GENERIC_SPEC : TokenTypeValue; + OC_PROPERTY : TokenTypeValue; + OC_CLASS : TokenTypeValue; + OC_CLASS_EXT : TokenTypeValue; + OC_CATEGORY : TokenTypeValue; + OC_SCOPE : TokenTypeValue; + OC_MSG : TokenTypeValue; + OC_MSG_CLASS : TokenTypeValue; + OC_MSG_FUNC : TokenTypeValue; + OC_MSG_NAME : TokenTypeValue; + OC_MSG_SPEC : TokenTypeValue; + OC_MSG_DECL : TokenTypeValue; + OC_RTYPE : TokenTypeValue; + OC_ATYPE : TokenTypeValue; + OC_COLON : TokenTypeValue; + OC_DICT_COLON : TokenTypeValue; + OC_SEL : TokenTypeValue; + OC_SEL_NAME : TokenTypeValue; + OC_BLOCK : TokenTypeValue; + OC_BLOCK_ARG : TokenTypeValue; + OC_BLOCK_TYPE : TokenTypeValue; + OC_BLOCK_EXPR : TokenTypeValue; + OC_BLOCK_CARET : TokenTypeValue; + OC_AT : TokenTypeValue; + OC_PROPERTY_ATTR : TokenTypeValue; + PP_DEFINE : TokenTypeValue; + PP_DEFINED : TokenTypeValue; + PP_INCLUDE : TokenTypeValue; + PP_IF : TokenTypeValue; + PP_ELSE : TokenTypeValue; + PP_ENDIF : TokenTypeValue; + PP_ASSERT : TokenTypeValue; + PP_EMIT : TokenTypeValue; + PP_ENDINPUT : TokenTypeValue; + PP_ERROR : TokenTypeValue; + PP_FILE : TokenTypeValue; + PP_LINE : TokenTypeValue; + PP_SECTION : TokenTypeValue; + PP_ASM : TokenTypeValue; + PP_UNDEF : TokenTypeValue; + PP_PROPERTY : TokenTypeValue; + PP_BODYCHUNK : TokenTypeValue; + PP_PRAGMA : TokenTypeValue; + PP_REGION : TokenTypeValue; + PP_ENDREGION : TokenTypeValue; + PP_REGION_INDENT : TokenTypeValue; + PP_IF_INDENT : TokenTypeValue; + PP_IGNORE : TokenTypeValue; + PP_OTHER : TokenTypeValue; + CHAR : TokenTypeValue; + DEFINED : TokenTypeValue; + FORWARD : TokenTypeValue; + NATIVE : TokenTypeValue; + STATE : TokenTypeValue; + STOCK : TokenTypeValue; + TAGOF : TokenTypeValue; + DOT : TokenTypeValue; + TAG : TokenTypeValue; + TAG_COLON : TokenTypeValue; + LOCK : TokenTypeValue; + AS : TokenTypeValue; + IN : TokenTypeValue; + BRACED : TokenTypeValue; + THIS : TokenTypeValue; + BASE : TokenTypeValue; + DEFAULT : TokenTypeValue; + GETSET : TokenTypeValue; + GETSET_EMPTY : TokenTypeValue; + CONCAT : TokenTypeValue; + CS_SQ_STMT : TokenTypeValue; + CS_SQ_COLON : TokenTypeValue; + CS_PROPERTY : TokenTypeValue; + SQL_EXEC : TokenTypeValue; + SQL_BEGIN : TokenTypeValue; + SQL_END : TokenTypeValue; + SQL_WORD : TokenTypeValue; + SQL_ASSIGN : TokenTypeValue; + CONSTRUCT : TokenTypeValue; + LAMBDA : TokenTypeValue; + ASSERT : TokenTypeValue; + ANNOTATION : TokenTypeValue; + FOR_COLON : TokenTypeValue; + DOUBLE_BRACE : TokenTypeValue; + CNG_HASINC : TokenTypeValue; + CNG_HASINCN : TokenTypeValue; + Q_EMIT : TokenTypeValue; + Q_FOREACH : TokenTypeValue; + Q_FOREVER : TokenTypeValue; + Q_GADGET : TokenTypeValue; + Q_OBJECT : TokenTypeValue; + MODE : TokenTypeValue; + DI : TokenTypeValue; + HI : TokenTypeValue; + QI : TokenTypeValue; + SI : TokenTypeValue; + NOTHROW : TokenTypeValue; + WORD_ : TokenTypeValue; + } + + export interface LanguageValue extends EmscriptenEnumTypeObject {} + export interface Language extends EmscriptenEnumType + { + C : LanguageValue; + CPP : LanguageValue; + D : LanguageValue; + CS : LanguageValue; + JAVA : LanguageValue; + OC : LanguageValue; + VALA : LanguageValue; + PAWN : LanguageValue; + ECMA : LanguageValue; + } + + // endregion enum bindings + // </editor-fold> + + export interface GenericOptionPtr + { + type(): OptionTypeValue; + description(): string; + name(): string; + possibleValues(): EmscriptenVector<string>; + defaultStr(): string; + minStr(): string; + maxStr(): string; + isDefault: boolean; + reset(): void + set(value: string): boolean; + value(): string; + } + + export interface OptionGroupPtr + { + description: string + options: EmscriptenVector<GenericOptionPtr>; + } + + export interface Uncrustify + { + OptionType: OptionType; + IARF: IARF; + LineEnd: LineEnd; + TokenPos: TokenPos; + LogType: LogType; + TokenType: TokenType; + Language: Language; + + //! get groups vector + get_groups() : EmscriptenVector <OptionGroupPtr> + + //! get options vector + get_options() : EmscriptenVector <GenericOptionPtr> + + //! destroys the current libUncrustify instance + destruct() : void; + + //! returns the UNCRUSTIFY_VERSION string + get_version() : string; + + //! adds a new keyword to Uncrustifys dynamic keyword map (dkwm, keywords.cpp) + add_keyword( tag : string, type : TokenType ) : void + + //! removes a keyword from Uncrustifys dynamic keyword map (dkwm, keywords.cpp) + // remove_keyword( tag : string ) + + // clears Uncrustifys dynamic keyword map (dkwm, keywords.cpp) + clear_keywords() : void; + + //! sets all option values to their default values + reset_options() : void; + + /** + * resets value of an option to its default + * + * @param name: name of the option + * @return options enum value of the found option or -1 if option was not found + */ + option_reset_value( name : string ) : number; + + /** + * sets value of an option + * + * @param name name of the option + * @param value value that is going to be set + * @return options enum value of the found option or -1 if option was not found + */ + option_set_value( name : string, value : string ) : number; + + /** + * returns value of an option + * + * @param name name of the option + * @return currently set value of the option + */ + option_get_value( name : string ) : string; + + /** + * reads option file string, sets the defined options + * + * @return returns EXIT_SUCCESS on success + */ + load_config( cfg : string ) : number; + + /** + * returns the config file string based on the current configuration + * + * @param withDoc false= without documentation true=with documentation text lines + * @param only_not_default false=containing all options true=containing only options with non default values + * @return returns the config file string based on the current configuration + */ + show_config( withDoc : boolean, only_not_default : boolean ) : string; + + /** + * returns the config file string with all options based on the current configuration + * + * @param withDoc false= without documentation true=with documentation text lines + * @return returns the config file string with all options based on the current configuration + */ + show_config( withDoc : boolean ) : string; + + /** + * returns the config file string with all options and without documentation based on the current configuration + * + * @return returns the config file string with all options without documentation based on the current configuration + */ + show_config() : string; + + //! enable or disable logging of a specific LogType + log_type_enable(type : LogType, value : bool) : void + + /** + * Show or hide the severity prefix "<1>" + * + * @param b true=show false=hide + */ + log_type_show_name( b : boolean ) : void; + + //! disables all logging messages + quiet() : void; + + /** + * format text + * + * @param file file string that is going to be formated + * @param lang specifies in which language the input file is written (see LangFlag) + * @param frag [optional] true=fragmented code input + * false=unfragmented code input [default] + * + * @return formatted file string + */ + uncrustify( file : string, lang : LanguageValue, frag : boolean ) : string; + uncrustify( file : string, lang : LanguageValue ) : string; + + /** + * generate debug output + * + * @param file file string that is going to be formated + * @param lang specifies in which language the input file is written (see LangFlag) + * @param frag [optional] true=fragmented code input + * false=unfragmented code input [default] + * + * @return debug output string + */ + debug( file : string, lang : LanguageValue, frag : boolean ) : string; + debug( file : string, lang : LanguageValue ) : string; + } + + var Uncrustify : { + (module?: Object): Uncrustify; + new (module?: Object): Uncrustify; + }; +} + +declare var uncrustify : LibUncrustify.Uncrustify; + +declare module "libUncrustify" +{ + export = uncrustify; +} diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/postfix_file b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/postfix_file new file mode 100644 index 00000000..17315134 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/postfix_file @@ -0,0 +1,2 @@ +if (typeof module !== 'undefined') module.exports = libUncrustify; +if (typeof define === 'function') define(libUncrustify); diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/postfix_module.js b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/postfix_module.js new file mode 100644 index 00000000..cbf8f57b --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/postfix_module.js @@ -0,0 +1,141 @@ + //! auto initializes the module + Module["_initialize"](); //// execute this only one time, + Module["_initialize"] = Function.prototype; // and replace it with a noop + + /** + * Takes in a JS string with other params, converts it to UTF8 and + * passes it to the actual _uncrustify function while also managing the + * memory on the emscripten heap. + */ + Module["uncrustify"] = function(str, langIDX, frag, defer) + { + if( !str || typeof(str) !== "string" || str.length === 0 ) {return "";} + + var nDataBytes = lengthBytesUTF8(str)+1; // +1 for \0 + var stringInputPtr = Module._malloc(nDataBytes); + Module.stringToUTF8(str, stringInputPtr, nDataBytes); + + var retStringPointer = 0; + + switch(arguments.length) + { + // depending in the number of args the internal select_overload + // function resolves the appropriate internal _uncrustify function + case 2: + { + retStringPointer = Module["_uncrustify"](stringInputPtr, langIDX); + break; + } + case 3: + { + retStringPointer = Module["_uncrustify"](stringInputPtr, langIDX, frag); + break; + } +// case 4: +// { +// retStringPointer = Module["_uncrustify"](stringInputPtr, langIDX, frag, defer); +// break; +// } + default: + { + break; + } + } + + Module._free(stringInputPtr); + + + var retString = ""; + + if(retStringPointer !== 0) + { + retString = Module.UTF8ToString(retStringPointer); + Module._free(retStringPointer); + } + + return retString; + } + + /** + * Takes in a JS string with other params, converts it to UTF8 and + * passes it to the actual _debug function while also managing the + * memory on the emscripten heap. + */ + Module["debug"] = function(str, langIDX, frag) + { + if( !str || typeof(str) !== "string" || str.length === 0 ) {return "";} + + var nDataBytes = lengthBytesUTF8(str)+1; // +1 for \0 + var stringInputPtr = Module._malloc(nDataBytes); + Module.stringToUTF8(str, stringInputPtr, nDataBytes); + + var retStringPointer = 0; + + switch(arguments.length) + { + // depending in the number of args the internal select_overload + // function resolves the appropriate internal _uncrustify function + case 2: + { + retStringPointer = Module["_debug"](stringInputPtr, langIDX); + break; + } + case 3: + { + retStringPointer = Module["_debug"](stringInputPtr, langIDX, frag); + break; + } + default: + { + break; + } + } + + Module._free(stringInputPtr); + + + var retString = ""; + + if(retStringPointer !== 0) + { + retString = Module.UTF8ToString(retStringPointer); + Module._free(retStringPointer); + } + + return retString; + } + + /** + * Takes in a JS string, removes non ascii chars (only those are needed + * in a config) and passes it to the actual _loadConfig function while + * also managing the memory on the emscripten heap. + */ + Module.load_config = function(str) + { + // UTF8 functions return on empty string but they have to be accepted too + // to reset the current config + if( !str || typeof(str) !== "string" || str.length === 0) {str = " ";} + + //remove unneeded non asci chars in the config + str.replace(/[^\x00-\x7F]/g, ""); + + var nDataBytes = str.length+1; // +1 for \0 + var stringInputPtr = Module._malloc(nDataBytes); + Module.writeAsciiToMemory(str, stringInputPtr); + + + var retStringPointer = Module["_load_config"](stringInputPtr); + Module._free(stringInputPtr); + + + var retString = ""; + + if(retStringPointer !== 0) + { + retString = Module.Pointer_stringify(retStringPointer); + Module._free(retStringPointer); + } + + return retString; + } + diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/prefix_file b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/prefix_file new file mode 100644 index 00000000..6a6b5e98 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/prefix_file @@ -0,0 +1,8 @@ +/* + * @file libUncrustify.js — JS port of Uncrustify + * + * @author Ben Gardner, + * ported by Daniel Chumak with the help of emscripten + * @license GPLv2 + */ + diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/prefix_module.js b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/prefix_module.js new file mode 100644 index 00000000..05d09cd7 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/prefix_module.js @@ -0,0 +1,28 @@ + if( !Module.hasOwnProperty('noInitialRun') ) { Module.noInitialRun = true; } + if( !Module.hasOwnProperty('noExitRuntime') ) { Module.noExitRuntime = true; } + if( !Module.hasOwnProperty('print') || typeof Module["print"] != 'function') + { + Module.print = (function() + { + return function(text) + { + if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); + console.log(text); + }; + })(); + } + if( !Module.hasOwnProperty('printErr') || typeof Module["printErr"] != 'function') + { + Module.printErr = function(text) + { + if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); + if (0) + { // XXX disabled for safety typeof dump == 'function') { + dump(text + '\n'); // fast, straight to the real console + } + else + { + console.error(text); + } + }; + } diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/test/run_tests.py b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/test/run_tests.py new file mode 100755 index 00000000..c7a4fcae --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/test/run_tests.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python +# +# Rebuilds the version using git describe +# +import sys +from subprocess import Popen +from os import listdir, EX_OK, EX_USAGE, EX_SOFTWARE +from os.path import isfile, isdir, abspath, basename +from tempfile import NamedTemporaryFile +from glob import glob + + +def main(args): + if len(args) < 2 or not isfile(args[0]) or not isdir(args[1]): + print("Usage:") + print(" arg 1: libUncrustify.js file path") + print(" arg 2: test directory path") + return EX_USAGE + + c_red = '\033[31m' + c_green = '\033[32m' + c_end = '\033[0m' + + js_file_path = args[0] + passed = 0 + total = 0 + + test_files_dir = abspath(args[1]) + test_files = glob(test_files_dir+"/test_*.js") + temp_file = NamedTemporaryFile(delete=True) + + for test_file_path in test_files: + total += 1 + pt_strg = "Testing %s: " % basename(test_file_path) + pt_strg_len = len(pt_strg) + + sys.stdout.write(pt_strg) + + with open(temp_file.name, 'r+') as t: + process = Popen(["node", test_file_path, js_file_path], stderr=t, stdout=t) + process.wait() + + if process.returncode == 0: + print(("%spassed.%s" % (c_green, c_end)).rjust(86-pt_strg_len)) + passed += 1 + else: + print(("%sfailed!%s" % (c_red, c_end)).rjust(78-pt_strg_len)) + + t.seek(0) + text = t.read() + print(text) + + if total == 0: + print("%sError%s: no test files found in %s" % (c_red, c_end, test_files_dir)) + return EX_USAGE + + print('-' * 80) + + if passed == total: + print("%sAll %s tests passed%s" % (c_green, total, c_end)) + return EX_OK + else: + print("%sWarning%s: %s/%s tests passed" % (c_red, c_end, passed, total)) + return EX_SOFTWARE + +if __name__ == '__main__': + exit(main(sys.argv[1:])) diff --git a/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/test/test_run.js b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/test/test_run.js new file mode 100644 index 00000000..27627094 --- /dev/null +++ b/debian/uncrustify-trinity/uncrustify-trinity-0.78.1/emscripten/test/test_run.js @@ -0,0 +1,18 @@ +exports.test = function(libUncrustify, assert){ + var uncrustify = libUncrustify(); + + var input = ' string a = "aaaa";'; + var expectedOutput = 'string a = "aaaa";'; + var generatedOutput = uncrustify.uncrustify( input, uncrustify.Language.CPP ); + + assert.deepEqual(expectedOutput, generatedOutput, "comparing expectedOutput and generatedOutput"); + + uncrustify.destruct(); +}; + +if (module == require.main) { + if(process.argv.length < 3) {throw "libUncrustify.js path missing";} + var uncrustify = require(process.argv[2]); + var assert = require("assert"); + exports.test(uncrustify, assert); +} |