summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
l---------.style.yapf1
-rw-r--r--conf/.dir-locals.el16
-rw-r--r--conf/.prettierrc6
-rw-r--r--conf/.style.yapf5
-rw-r--r--conf/.vscode/settings.json40
-rw-r--r--conf/.vscode/tasks.json44
-rw-r--r--conf/.yarnrc2
-rwxr-xr-xconf/uncrustify-mode.el161
-rw-r--r--conf/uncrustify.cfg78
-rw-r--r--conf/uncrustify.el13
-rwxr-xr-xconf/uncrustify.sh14
-rw-r--r--coverage.sh10
13 files changed, 391 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..aee2e4c
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+config.mk
diff --git a/.style.yapf b/.style.yapf
new file mode 120000
index 0000000..b7630a2
--- /dev/null
+++ b/.style.yapf
@@ -0,0 +1 @@
+conf/.style.yapf \ No newline at end of file
diff --git a/conf/.dir-locals.el b/conf/.dir-locals.el
new file mode 100644
index 0000000..6878638
--- /dev/null
+++ b/conf/.dir-locals.el
@@ -0,0 +1,16 @@
+;; Per-directory local variables for GNU Emacs 23 and later.
+
+((nil
+ . ((fill-column . 78)
+ (tab-width . 4)
+ (indent-tabs-mode . nil)
+ (show-trailing-whitespace . t)
+ (c-basic-offset . 2)
+ (ispell-check-comments . exclusive)
+ (ispell-local-dictionary . "american")
+ (safe-local-variable-values
+ '((c-default-style . "gnu")
+ (sentence-end-double-space . f)
+ (eval add-hook 'prog-mode-hook #'flyspell-prog-mode)
+ (flyspell-issue-message-flag . f) ; avoid messages for every word
+ )))))
diff --git a/conf/.prettierrc b/conf/.prettierrc
new file mode 100644
index 0000000..50063da
--- /dev/null
+++ b/conf/.prettierrc
@@ -0,0 +1,6 @@
+{
+ "trailingComma": "all",
+ "tabWidth": 2,
+ "semi": true,
+ "singleQuote": false
+} \ No newline at end of file
diff --git a/conf/.style.yapf b/conf/.style.yapf
new file mode 100644
index 0000000..3b39780
--- /dev/null
+++ b/conf/.style.yapf
@@ -0,0 +1,5 @@
+[style]
+based_on_style = pep8
+coalesce_brackets=True
+column_limit=80
+dedent_closing_brackets=True
diff --git a/conf/.vscode/settings.json b/conf/.vscode/settings.json
new file mode 100644
index 0000000..6482c5d
--- /dev/null
+++ b/conf/.vscode/settings.json
@@ -0,0 +1,40 @@
+// Place your settings in this file to overwrite default and user settings.
+{
+ // Use latest language servicesu
+ "typescript.tsdk": "./node_modules/typescript/lib",
+ // Defines space handling after a comma delimiter
+ "typescript.format.insertSpaceAfterCommaDelimiter": true,
+ // Defines space handling after a semicolon in a for statement
+ "typescript.format.insertSpaceAfterSemicolonInForStatements": true,
+ // Defines space handling after a binary operator
+ "typescript.format.insertSpaceBeforeAndAfterBinaryOperators": true,
+ // Defines space handling after keywords in control flow statement
+ "typescript.format.insertSpaceAfterKeywordsInControlFlowStatements": true,
+ // Defines space handling after function keyword for anonymous functions
+ "typescript.format.insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
+ // Defines space handling after opening and before closing non empty parenthesis
+ "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ // Defines space handling after opening and before closing non empty brackets
+ "typescript.format.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ // Defines whether an open brace is put onto a new line for functions or not
+ "typescript.format.placeOpenBraceOnNewLineForFunctions": false,
+ // Defines whether an open brace is put onto a new line for control blocks or not
+ "typescript.format.placeOpenBraceOnNewLineForControlBlocks": false,
+ // Files hidden in the explorer
+ "files.exclude": {
+ // include the defaults from VS Code
+ "**/.git": true,
+ "**/.DS_Store": true,
+ // exclude .js and .js.map files, when in a TypeScript project
+ "**/*.js": {
+ "when": "$(basename).ts"
+ },
+ "**/*?.js": {
+ "when": "$(basename).tsx"
+ },
+ "**/*.js.map": true
+ },
+ "tslint.enable": true,
+ "editor.wrappingIndent": "same",
+ "editor.tabSize": 2
+} \ No newline at end of file
diff --git a/conf/.vscode/tasks.json b/conf/.vscode/tasks.json
new file mode 100644
index 0000000..a141599
--- /dev/null
+++ b/conf/.vscode/tasks.json
@@ -0,0 +1,44 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "type": "typescript",
+ "tsconfig": "tsconfig.json",
+ "option": "watch",
+ "problemMatcher": [
+ "$tsc-watch"
+ ],
+ "group": "build",
+ "isBackground": true,
+ "promptOnClose": false
+ },
+ {
+ "type": "typescript",
+ "tsconfig": "tsconfig.json",
+ "problemMatcher": [
+ "$tsc"
+ ],
+ "group": "build"
+ },
+ {
+ "label": "tslint",
+ "type": "shell",
+ "command": "make lint",
+ "problemMatcher": {
+ "owner": "tslint",
+ "applyTo": "allDocuments",
+ "fileLocation": "absolute",
+ "severity": "warning",
+ "pattern": "$tslint5"
+ },
+ "group": "build"
+ },
+ {
+ "label": "My Task",
+ "type": "shell",
+ "command": "echo Hello"
+ }
+ ]
+} \ No newline at end of file
diff --git a/conf/.yarnrc b/conf/.yarnrc
new file mode 100644
index 0000000..fe3df9c
--- /dev/null
+++ b/conf/.yarnrc
@@ -0,0 +1,2 @@
+yarn-offline-mirror "./npm-packages-offline-cache"
+yarn-offline-mirror-pruning true
diff --git a/conf/uncrustify-mode.el b/conf/uncrustify-mode.el
new file mode 100755
index 0000000..97118c0
--- /dev/null
+++ b/conf/uncrustify-mode.el
@@ -0,0 +1,161 @@
+;;; uncrustify-mode.el --- Minor mode to automatically uncrustify.
+
+;; Copyright (C) 2012 tabi
+;; Author: Tabito Ohtani <koko1000ban@gmail.com>
+;; Version: 0.01
+;; Keywords: uncrustify
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Installation:
+
+;; drop requirements and this file into a directory in your `load-path',
+;; and put these lines into your .emacs file.
+
+;; (require 'uncrusfify-mode)
+;; (add-hook 'c-mode-common-hook
+;; '(lambda ()
+;; (uncrustify-mode 1)))
+
+;;; ChangeLog:
+;; * 0.0.1:
+;; Initial version.
+
+
+;; case
+(eval-when-compile
+ (require 'cl))
+
+;;; Variables:
+
+(defcustom uncrustify-config-path
+ "~/.uncrustify.cfg"
+ "uncrustify config file path"
+ :group 'uncrustify
+ :type 'file)
+(make-variable-buffer-local 'uncrustify-config-path)
+
+(defcustom uncrustify-bin
+ "uncrustify -q"
+ "The command to run uncrustify."
+ :group 'uncrustify)
+
+;;; Functions:
+
+(defun uncrustify-get-lang-from-mode (&optional mode)
+ "uncrustify lang option"
+ (let ((m (or mode major-mode)))
+ (case m
+ ('c-mode "C")
+ ('c++-mode "CPP")
+ ('d-mode "D")
+ ('java-mode "JAVA")
+ ('objc-mode "OC")
+ (t
+ nil))))
+
+(defun uncrustify-point->line (point)
+ "Get the line number that POINT is on."
+ ;; I'm not bothering to use save-excursion because I think I'm
+ ;; calling this function from inside other things that are likely to
+ ;; use that and all I really need to do is restore my current
+ ;; point. So that's what I'm doing manually.
+ (let ((line 1)
+ (original-point (point)))
+ (goto-char (point-min))
+ (while (< (point) point)
+ (incf line)
+ (forward-line))
+ (goto-char original-point)
+ line))
+
+(defun uncrustify-invoke-command (lang start-in end-in)
+ "Run uncrustify on the current region or buffer."
+ (if lang
+ (let ((start (or start-in (point-min)))
+ (end (or end-in (point-max)))
+ (original-line (uncrustify-point->line (point)))
+ (cmd (concat uncrustify-bin " -c " uncrustify-config-path " -l " lang))
+ (out-buf (get-buffer-create "*uncrustify-out*"))
+ (error-buf (get-buffer-create "*uncrustify-errors*")))
+
+ (with-current-buffer error-buf (erase-buffer))
+ (with-current-buffer out-buf (erase-buffer))
+
+ ;; Inexplicably, save-excursion doesn't work to restore the
+ ;; point. I'm using it to restore the mark and point and manually
+ ;; navigating to the proper new-line.
+ (let ((result
+ (save-excursion
+ (let ((ret (shell-command-on-region start end cmd t t error-buf nil)))
+ (if (and
+ (numberp ret)
+ (zerop ret))
+ ;; Success! Clean up.
+ (progn
+ (message "Success! uncrustify modify buffer.")
+ (kill-buffer error-buf)
+ t)
+ ;; Oops! Show our error and give back the text that
+ ;; shell-command-on-region stole.
+ (progn (undo)
+ (with-current-buffer error-buf
+ (message "uncrustify error: <%s> <%s>" ret (buffer-string)))
+ nil))))))
+
+ ;; This goto-line is outside the save-excursion becuase it'd get
+ ;; removed otherwise. I hate this bug. It makes things so ugly.
+ (goto-line original-line)
+ (not result)))
+ (message "uncrustify not support this mode : %s" major-mode)))
+
+(defun uncrustify ()
+ (interactive)
+ (save-restriction
+ (widen)
+ (uncrustify-invoke-command (uncrustify-get-lang-from-mode) (region-beginning) (region-end))))
+
+(defun uncrustify-buffer ()
+ (interactive)
+ (save-restriction
+ (widen)
+ (uncrustify-invoke-command (uncrustify-get-lang-from-mode) (point-min) (point-max))))
+
+;;; mode
+
+(defun uncrustify-write-hook ()
+ "Uncrustifys a buffer during `write-file-hooks' for `uncrustify-mode'.
+ if uncrustify returns not nil then the buffer isn't saved."
+ (if uncrustify-mode
+ (save-restriction
+ (widen)
+ (uncrustify-invoke-command (uncrustify-get-lang-from-mode) (point-min) (point-max)))))
+
+;;;###autoload
+(define-minor-mode uncrustify-mode
+ "Automatically `uncrustify' when saving."
+ :lighter " Uncrustify"
+ (if (not (uncrustify-get-lang-from-mode))
+ (message "uncrustify not support this mode : %s" major-mode)
+ (if (version<= "24" emacs-version)
+ (if uncrustify-mode
+ (add-hook 'write-file-hooks 'uncrustify-write-hook nil t)
+ (remove-hook 'uncrustify-write-hook t))
+ (make-local-hook 'write-file-hooks)
+ (funcall (if uncrustify-mode #'add-hook #'remove-hook)
+ 'write-file-hooks 'uncrustify-write-hook))))
+
+(provide 'uncrustify-mode)
+
+;;; uncrustify-mode.el ends here
diff --git a/conf/uncrustify.cfg b/conf/uncrustify.cfg
new file mode 100644
index 0000000..6ced05d
--- /dev/null
+++ b/conf/uncrustify.cfg
@@ -0,0 +1,78 @@
+input_tab_size = 2
+output_tab_size = 2
+
+indent_columns = 2
+indent_with_tabs = 0
+indent_case_brace = 2
+indent_label=0
+
+code_width=80
+#cmd_width=80
+
+# Leave most comments alone for now
+cmt_indent_multi=false
+sp_cmt_cpp_start=add
+
+sp_not=add
+
+sp_func_call_user_paren_paren=remove
+sp_inside_fparen=remove
+sp_after_cast=add
+
+ls_for_split_full=true
+ls_func_split_full=true
+ls_code_width=true
+
+# Arithmetic operations in wrapped expressions should be at the start
+# of the line.
+pos_arith=lead
+
+# Fully parenthesize boolean exprs
+mod_full_paren_if_bool=true
+
+# Braces should be on their own line
+nl_fdef_brace=add
+nl_enum_brace=add
+nl_struct_brace=add
+nl_union_brace=add
+nl_if_brace=add
+nl_brace_else=add
+nl_elseif_brace=add
+nl_while_brace=add
+nl_switch_brace=add
+
+# no newline between "else" and "if"
+nl_else_if=remove
+
+nl_func_paren=remove
+nl_assign_brace=remove
+
+# No extra newlines that cause noisy diffs
+nl_start_of_file=remove
+# If there's no new line, it's not a text file!
+nl_end_of_file=add
+
+sp_inside_paren = remove
+
+sp_arith = add
+sp_arith_additive = add
+
+# We want spaces before and after "="
+sp_before_assign = add
+sp_after_assign = add
+
+# we want "char *foo;"
+sp_after_ptr_star = remove
+sp_between_ptr_star = remove
+
+# we want "if (foo) { ... }"
+sp_before_sparen = add
+
+sp_inside_fparen = remove
+
+# add space before function call and decl: "foo (x)"
+sp_func_call_paren = add
+sp_func_proto_paren = add
+sp_func_proto_paren_empty = add
+sp_func_def_paren = add
+sp_func_def_paren_empty = add
diff --git a/conf/uncrustify.el b/conf/uncrustify.el
new file mode 100644
index 0000000..2ab6961
--- /dev/null
+++ b/conf/uncrustify.el
@@ -0,0 +1,13 @@
+;; suggested integration of uncrustify for Emacs
+;; This assumes that the 'uncrustify-mode.el' is
+;; installed to '~/.emacs.d/load-path/'. Feel free
+;; to put it elsewhere and adjust the load path below!
+
+;; adding the following to ~/.emacs will then run
+;; uncrustify whenever saving a C buffer.
+
+(add-to-list 'load-path "~/.emacs.d/load-path/")
+(require 'uncrustify-mode)
+(add-hook 'c-mode-common-hook
+ '(lambda ()
+ (uncrustify-mode 1)))
diff --git a/conf/uncrustify.sh b/conf/uncrustify.sh
new file mode 100755
index 0000000..e8e05d3
--- /dev/null
+++ b/conf/uncrustify.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+set -eu
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+if ! uncrustify --version >/dev/null; then
+ echo "you need to install uncrustify for indentation"
+ exit 1
+fi
+
+find "$DIR/../src" \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) \
+ -exec uncrustify -c "$DIR/uncrustify.cfg" --replace --no-backup {} + \
+ || true
diff --git a/coverage.sh b/coverage.sh
new file mode 100644
index 0000000..cce6222
--- /dev/null
+++ b/coverage.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+# Run from 'taler-exchange/' top-level directory to generate
+# code coverage data.
+TOP=`pwd`
+mkdir -p doc/coverage/
+lcov -d $TOP -z
+make check
+lcov -d $TOP -c --no-external -o doc/coverage/coverage.info
+lcov -r doc/coverage/coverage.info **/test_* **/perf_* -o doc/coverage/rcoverage.info
+genhtml -o doc/coverage doc/coverage/rcoverage.info