Change the coding style to GNU
This commit is contained in:
parent
5d108d7f95
commit
61764bc1f5
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
# Global Options Go Here
|
||||||
|
IndentWidth: 2
|
||||||
|
ColumnLimit: 100
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
BasedOnStyle: GNU
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlignConsecutiveMacros: true
|
||||||
|
ForEachMacros: []
|
||||||
|
IndentWidth: 2
|
||||||
|
AlignConsecutiveAssignments: Consecutive
|
||||||
|
AlignConsecutiveBitFields: Consecutive
|
||||||
|
AlignEscapedNewlines: Left
|
||||||
|
AlwaysBreakTemplateDeclarations: Yes
|
||||||
|
IncludeBlocks: Regroup
|
||||||
|
SortIncludes: true
|
||||||
|
SortUsingDeclarations: true
|
||||||
|
...
|
|
@ -0,0 +1,31 @@
|
||||||
|
# Apply to all files without commiting:
|
||||||
|
# pre-commit run --all-files
|
||||||
|
# Update this file:
|
||||||
|
# pre-commit autoupdate
|
||||||
|
fail_fast: false
|
||||||
|
repos:
|
||||||
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
|
rev: v4.3.0
|
||||||
|
hooks:
|
||||||
|
- id: check-added-large-files
|
||||||
|
- id: check-symlinks
|
||||||
|
- id: check-byte-order-marker
|
||||||
|
- id: check-case-conflict
|
||||||
|
- id: check-docstring-first
|
||||||
|
- id: check-executables-have-shebangs
|
||||||
|
- id: forbid-new-submodules
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: mixed-line-ending
|
||||||
|
|
||||||
|
- repo: https://github.com/pocc/pre-commit-hooks
|
||||||
|
rev: v1.3.5
|
||||||
|
hooks:
|
||||||
|
- id: clang-format
|
||||||
|
- id: cppcheck
|
||||||
|
args: ['--project=compile_commands.json']
|
||||||
|
- repo: https://github.com/detailyang/pre-commit-shell
|
||||||
|
rev: 1.0.5
|
||||||
|
hooks:
|
||||||
|
- id: shell-lint
|
||||||
|
args: ['-x']
|
|
@ -16,6 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#include "export.h"
|
#include "export.h"
|
||||||
|
|
||||||
#include <emacs-module.h>
|
#include <emacs-module.h>
|
||||||
|
|
||||||
/* Declare mandatory GPL symbol. */
|
/* Declare mandatory GPL symbol. */
|
||||||
|
@ -23,45 +24,52 @@ FEYNMAN_EXPORT int plugin_is_GPL_compatible = 0;
|
||||||
|
|
||||||
/* New emacs lisp function. All function exposed to Emacs must have this
|
/* New emacs lisp function. All function exposed to Emacs must have this
|
||||||
* prototype. */
|
* prototype. */
|
||||||
static emacs_value feynman_init(emacs_env *env, ptrdiff_t nargs,
|
static emacs_value
|
||||||
emacs_value args[], void *data) {
|
feynman_init (emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data)
|
||||||
|
{
|
||||||
(void)nargs;
|
(void)nargs;
|
||||||
(void)args;
|
(void)args;
|
||||||
(void)data;
|
(void)data;
|
||||||
return env->make_integer(env, 42);
|
return env->make_integer (env, 42);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bind NAME to FUN. */
|
/* Bind NAME to FUN. */
|
||||||
static void bind_function(emacs_env *env, const char *name, emacs_value Sfun) {
|
static void
|
||||||
|
bind_function (emacs_env *env, const char *name, emacs_value Sfun)
|
||||||
|
{
|
||||||
/* Set the function cell of the symbol named NAME to SFUN using
|
/* Set the function cell of the symbol named NAME to SFUN using
|
||||||
the 'fset' function. */
|
the 'fset' function. */
|
||||||
|
|
||||||
/* Convert the strings to symbols by interning them */
|
/* Convert the strings to symbols by interning them */
|
||||||
emacs_value Qfset = env->intern(env, "fset");
|
emacs_value Qfset = env->intern (env, "fset");
|
||||||
emacs_value Qsym = env->intern(env, name);
|
emacs_value Qsym = env->intern (env, name);
|
||||||
|
|
||||||
/* Prepare the arguments array */
|
/* Prepare the arguments array */
|
||||||
emacs_value args[] = {Qsym, Sfun};
|
emacs_value args[] = { Qsym, Sfun };
|
||||||
|
|
||||||
/* Make the call (2 == nb of arguments) */
|
/* Make the call (2 == nb of arguments) */
|
||||||
env->funcall(env, Qfset, 2, args);
|
env->funcall (env, Qfset, 2, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Provide FEATURE to Emacs. */
|
/* Provide FEATURE to Emacs. */
|
||||||
static void provide(emacs_env *env, const char *feature) {
|
static void
|
||||||
|
provide (emacs_env *env, const char *feature)
|
||||||
|
{
|
||||||
/* call 'provide' with FEATURE converted to a symbol */
|
/* call 'provide' with FEATURE converted to a symbol */
|
||||||
|
|
||||||
emacs_value Qfeat = env->intern(env, feature);
|
emacs_value Qfeat = env->intern (env, feature);
|
||||||
emacs_value Qprovide = env->intern(env, "provide");
|
emacs_value Qprovide = env->intern (env, "provide");
|
||||||
emacs_value args[] = {Qfeat};
|
emacs_value args[] = { Qfeat };
|
||||||
|
|
||||||
env->funcall(env, Qprovide, 1, args);
|
env->funcall (env, Qprovide, 1, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
FEYNMAN_EXPORT int emacs_module_init(struct emacs_runtime *ert) {
|
FEYNMAN_EXPORT int
|
||||||
emacs_env *env = ert->get_environment(ert);
|
emacs_module_init (struct emacs_runtime *ert)
|
||||||
|
{
|
||||||
|
emacs_env *env = ert->get_environment (ert);
|
||||||
/* create a lambda (returns an emacs_value) */
|
/* create a lambda (returns an emacs_value) */
|
||||||
emacs_value fun = env->make_function(
|
emacs_value fun = env->make_function (
|
||||||
env, 0, /* min. number of arguments */
|
env, 0, /* min. number of arguments */
|
||||||
0, /* max. number of arguments */
|
0, /* max. number of arguments */
|
||||||
feynman_init, /* actual function pointer */
|
feynman_init, /* actual function pointer */
|
||||||
|
@ -69,7 +77,7 @@ FEYNMAN_EXPORT int emacs_module_init(struct emacs_runtime *ert) {
|
||||||
NULL /* user pointer of your choice (data param in feynman_init) */
|
NULL /* user pointer of your choice (data param in feynman_init) */
|
||||||
);
|
);
|
||||||
|
|
||||||
bind_function(env, "feynman/init", fun);
|
bind_function (env, "feynman/init", fun);
|
||||||
provide(env, "feynman");
|
provide (env, "feynman");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue