From 8885ca1c3ce0e764c0d74fecc9c635eb6ba1e4ed Mon Sep 17 00:00:00 2001 From: Philip McGrath Date: Sat, 25 Feb 2023 16:38:11 -0500 Subject: [PATCH 1/2] Add `CONTRIBUTING.md` The guidelines were written by Aeva in . Co-Authored-By: Aeva Palecek --- CONTRIBUTING.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..8abcc14 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,37 @@ +# Contributing to Tangerine + +Contributions are welcome! +Here are some pointers. + +## C++ Style Guide + +C++ code written for Tangerine (i.e. in `tangerine/`, not in `third_party/`) should generally follow the [Unreal Engine coding standards](https://docs.unrealengine.com/5.1/en-US/epic-cplusplus-coding-standard-for-unreal-engine/), except that Tangerine does not use Hungarian notation. + +The main points are: + + - Indent with tabs, one tab per indentation level. + Tabs are to be 4 characters wide. + + - Braces are always on their own line at the same indentation level as the surrounding scope. + + - `TitleCase` is used for all class names, function names, variable names, constants, and so on. + + - Variable names should be descriptive and useful. + + - Single digit variables may be lower case for loop counters, but should generally be uppercase otherwise. + + - Single digit variable names should be avoided in favor of more descriptive names, but they do show up as loop counters, coordinates, and sometimes math terms. + + - `UPPER_SNAKE_CASE` is used for preprocessor defines. + + - Preprocessor directives should be lowercase and have no space between the `#` and the name, like so: `#define FNORD 1`. + + - Preprocessor directives generally aren't indented, but may be if it improves clarity. + + - `snake_case` is used for labels. + + - Labels should not be indented. + + - `goto` is acceptable when it improves readability. + + - There's no line limit, but the code should probably read ok on a modest 1080p monitor in a full screen window with a reasonable font size. From dfb4061a3756327e647ec20df006d17b766f78ac Mon Sep 17 00:00:00 2001 From: Philip McGrath Date: Sat, 25 Feb 2023 17:18:24 -0500 Subject: [PATCH 2/2] Add Emacs Configuration for C++ The values in `c-file-offsets` were generated by running `c-guess-no-install` on `gl_boilerplate.cpp`, `tangerine.cpp`, and `sdf_rendering.cpp`. --- tangerine/.dir-locals.el | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tangerine/.dir-locals.el diff --git a/tangerine/.dir-locals.el b/tangerine/.dir-locals.el new file mode 100644 index 0000000..fd4b356 --- /dev/null +++ b/tangerine/.dir-locals.el @@ -0,0 +1,33 @@ +;; See ../CONTRIBUTING.md for details. +((auto-mode-alist . (("\\.h\\'" . c++-mode))) + (c++-mode . ((c-file-style . "linux") + (indent-tabs-mode . t) + (tab-width . 4) + (c-basic-offset . 4) + (c-file-offsets + (arglist-cont . 0) + (arglist-intro . +) + (block-close . 0) + (brace-entry-open . 0) + (brace-list-close . 0) + (brace-list-entry . 0) + (brace-list-intro . +) + (class-close . 0) + (class-open . 0) + (case-label . 0) + (defun-block-intro . +) + (defun-close . 0) + (defun-open . 0) + (else-clause . 0) + (inclass . +) + (inline-close . 0) + (inline-open . 0) + (label . 0) + (member-init-cont . -) + (member-init-intro . +) + (statement . 0) + (statement-block-intro . +) + (statement-case-intro . +) + (statement-cont . +) + (substatement-open . 0) + (topmost-intro . 0)))))