summaryrefslogtreecommitdiff
path: root/src/binding.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/binding.c')
-rw-r--r--src/binding.c97
1 files changed, 60 insertions, 37 deletions
diff --git a/src/binding.c b/src/binding.c
index 43f73ba..f1f9029 100644
--- a/src/binding.c
+++ b/src/binding.c
@@ -8,7 +8,8 @@
int plugin_is_GPL_compatible = 3;
emacs_value
-rep_new_parser(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
+rep_new_parser
+(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
{
char *buffer = NULL;
ptrdiff_t len = 0;
@@ -37,13 +38,15 @@ rep_new_parser(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
uint64_t error_length = from_big_endian(error_vec.len);
if (error_length) {
- error_data[0] = env->make_string(env, error_vec.data, (ptrdiff_t) error_length);
+ error_data[0] =
+ env->make_string(env, error_vec.data, (ptrdiff_t) error_length);
clean_signed(&error_vec, 4);
- env->non_local_exit_signal(env, env->intern(env, "error"),
- env->funcall(env, env->intern(env, "list"),
- 1, error_data));
+ env->non_local_exit_signal
+ (env, env->intern(env, "error"),
+ env->funcall(env, env->intern(env, "list"),
+ 1, error_data));
return env->intern(env, "nil");
}
@@ -52,7 +55,8 @@ rep_new_parser(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
}
emacs_value
-rep_parser_recognize(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
+rep_parser_recognize
+(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
{
struct parser *parser = env->get_user_ptr(env, *args);
@@ -70,9 +74,10 @@ rep_parser_recognize(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *da
error_data[0] = env->make_string
(env, "INPUT should be a vector of integers", 36);
- env->non_local_exit_signal(env, env->intern(env, "wrong-type-argument"),
- env->funcall(env, env->intern(env, "list"),
- 1, error_data));
+ env->non_local_exit_signal
+ (env, env->intern(env, "wrong-type-argument"),
+ env->funcall(env, env->intern(env, "list"),
+ 1, error_data));
return env->intern(env, "nil");
}
@@ -84,9 +89,10 @@ rep_parser_recognize(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *da
if (buffer == NULL) {
error_data[0] = env->make_string(env, "out of memory", 13);
- env->non_local_exit_signal(env, env->intern(env, "error"),
- env->funcall(env, env->intern(env, "list"),
- 1, error_data));
+ env->non_local_exit_signal
+ (env, env->intern(env, "error"),
+ env->funcall(env, env->intern(env, "list"),
+ 1, error_data));
return env->intern(env, "nil");
}
@@ -118,20 +124,24 @@ rep_parser_recognize(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *da
struct UnsignedVec input_vec = (struct UnsignedVec)
{ input_len, NULL, buffer };
- int result = parser_recognize(parser, &input_vec, &error_vec, (unsigned char) 1);
+ int result =
+ parser_recognize
+ (parser, &input_vec, &error_vec, (unsigned char) 1);
free(buffer);
uint64_t error_length = from_big_endian(error_vec.len);
if (error_length) {
- error_data[0] = env->make_string(env, error_vec.data, (ptrdiff_t) error_length);
+ error_data[0] =
+ env->make_string(env, error_vec.data, (ptrdiff_t) error_length);
clean_signed(&error_vec, 4);
- env->non_local_exit_signal(env, env->intern(env, "error"),
- env->funcall(env, env->intern(env, "list"),
- 1, error_data));
+ env->non_local_exit_signal
+ (env, env->intern(env, "error"),
+ env->funcall(env, env->intern(env, "list"),
+ 1, error_data));
return env->intern(env, "nil");
}
@@ -146,7 +156,8 @@ clean_forest(void *ptr)
}
emacs_value
-rep_parser_parse(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
+rep_parser_parse
+(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
{
struct parser *parser = env->get_user_ptr(env, *args);
@@ -164,9 +175,10 @@ rep_parser_parse(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
error_data[0] = env->make_string
(env, "INPUT should be a vector of integers", 36);
- env->non_local_exit_signal(env, env->intern(env, "wrong-type-argument"),
- env->funcall(env, env->intern(env, "list"),
- 1, error_data));
+ env->non_local_exit_signal
+ (env, env->intern(env, "wrong-type-argument"),
+ env->funcall(env, env->intern(env, "list"),
+ 1, error_data));
return env->intern(env, "nil");
}
@@ -178,9 +190,10 @@ rep_parser_parse(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
if (buffer == NULL) {
error_data[0] = env->make_string(env, "out of memory", 13);
- env->non_local_exit_signal(env, env->intern(env, "error"),
- env->funcall(env, env->intern(env, "list"),
- 1, error_data));
+ env->non_local_exit_signal
+ (env, env->intern(env, "error"),
+ env->funcall(env, env->intern(env, "list"),
+ 1, error_data));
return env->intern(env, "nil");
}
@@ -209,23 +222,26 @@ rep_parser_parse(emacs_env *env, ptrdiff_t narg, emacs_value *args, void *data)
to_big_endian((uint64_t) len * 8, input_len);
-struct UnsignedVec input_vec = (struct UnsignedVec)
+ struct UnsignedVec input_vec = (struct UnsignedVec)
{ input_len, NULL, buffer };
- struct UnsignedVec *result = parser_parse(parser, &input_vec, &error_vec, (unsigned char) 1);
-
+ struct UnsignedVec *result =
+ parser_parse(parser, &input_vec, &error_vec, (unsigned char) 1);
+
free(buffer);
uint64_t error_length = from_big_endian(error_vec.len);
if (error_length) {
- error_data[0] = env->make_string(env, error_vec.data, (ptrdiff_t) error_length);
+ error_data[0] =
+ env->make_string(env, error_vec.data, (ptrdiff_t) error_length);
clean_signed(&error_vec, 4);
- env->non_local_exit_signal(env, env->intern(env, "error"),
- env->funcall(env, env->intern(env, "list"),
- 1, error_data));
+ env->non_local_exit_signal
+ (env, env->intern(env, "error"),
+ env->funcall(env, env->intern(env, "list"),
+ 1, error_data));
return env->intern(env, "nil");
}
@@ -258,8 +274,9 @@ emacs_module_init(struct emacs_runtime *ert)
"\n\n\(fn grammar_string)",
NULL);
- env->funcall(env, env->intern(env, "defalias"),
- 2, (emacs_value[]){ env->intern(env, "rep-new-parser"), newfunc });
+ env->funcall
+ (env, env->intern(env, "defalias"), 2,
+ (emacs_value[]){ env->intern(env, "rep-new-parser"), newfunc });
emacs_value recognizefunc = env->make_function
(env, 2, 2, rep_parser_recognize,
@@ -267,8 +284,11 @@ emacs_module_init(struct emacs_runtime *ert)
"\n\n\(fn parser INPUT)",
NULL);
- env->funcall(env, env->intern(env, "defalias"),
- 2, (emacs_value[]){ env->intern(env, "rep-recognize"), recognizefunc });
+ env->funcall(env, env->intern(env, "defalias"), 2,
+ (emacs_value[])
+ {
+ env->intern(env, "rep-recognize"), recognizefunc
+ });
emacs_value parsefunc = env->make_function
(env, 2, 2, rep_parser_parse,
@@ -276,8 +296,11 @@ emacs_module_init(struct emacs_runtime *ert)
"\n\n\(fn parser input)",
NULL);
- env->funcall(env, env->intern(env, "defalias"),
- 2, (emacs_value[]){ env->intern(env, "rep-parse"), parsefunc });
+ env->funcall(env, env->intern(env, "defalias"), 2,
+ (emacs_value[])
+ {
+ env->intern(env, "rep-parse"), parsefunc
+ });
env->funcall(env, env->intern(env, "provide"),
1, (emacs_value[]){ env->intern(env, "rep") });