diff options
| author | Paul Eggert | 2015-11-19 15:01:26 -0800 |
|---|---|---|
| committer | Paul Eggert | 2015-11-19 15:01:49 -0800 |
| commit | 92949781eb0963fd1b25f1eec4e2d72d2c8ae32e (patch) | |
| tree | 17f16cb6afb54afcbf6abc0ae2c54fe844454cb8 /src/emacs-module.h | |
| parent | d9b300af5c7b07bd870046e73df53e19e860fdb9 (diff) | |
| download | emacs-92949781eb0963fd1b25f1eec4e2d72d2c8ae32e.tar.gz emacs-92949781eb0963fd1b25f1eec4e2d72d2c8ae32e.zip | |
Prefer signed integer types in module code
Generally speaking, at the C level the Emacs source code prefers
signed types like ‘ptrdiff_t’ to unsigned types like ‘size_t’,
partly to avoid the usual signedness confusion when comparing values.
Change the module API to follow this convention.
Use ‘int’ for small values that can’t exceed INT_MAX.
* modules/mod-test/mod-test.c (Fmod_test_globref_make)
(Fmod_test_string_a_to_b, Fmod_test_vector_fill)
(Fmod_test_vector_eq):
* src/emacs-module.c (struct emacs_value_frame)
(module_make_global_ref, module_free_global_ref)
(module_copy_string_contents, module_make_string)
(module_vec_set, module_vec_get, module_vec_size):
* src/emacs-module.h (struct emacs_runtime, struct emacs_env_25):
* src/lread.c (suffix_p):
Prefer signed to unsigned integer types.
Diffstat (limited to 'src/emacs-module.h')
| -rw-r--r-- | src/emacs-module.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/emacs-module.h b/src/emacs-module.h index 2759b1cb0f0..a2edf8c0eb3 100644 --- a/src/emacs-module.h +++ b/src/emacs-module.h | |||
| @@ -46,7 +46,7 @@ enum emacs_arity { emacs_variadic_function = -2 }; | |||
| 46 | struct emacs_runtime | 46 | struct emacs_runtime |
| 47 | { | 47 | { |
| 48 | /* Structure size (for version checking). */ | 48 | /* Structure size (for version checking). */ |
| 49 | size_t size; | 49 | ptrdiff_t size; |
| 50 | 50 | ||
| 51 | /* Private data; users should not touch this. */ | 51 | /* Private data; users should not touch this. */ |
| 52 | struct emacs_runtime_private *private_members; | 52 | struct emacs_runtime_private *private_members; |
| @@ -82,7 +82,7 @@ enum emacs_funcall_exit | |||
| 82 | struct emacs_env_25 | 82 | struct emacs_env_25 |
| 83 | { | 83 | { |
| 84 | /* Structure size (for version checking). */ | 84 | /* Structure size (for version checking). */ |
| 85 | size_t size; | 85 | ptrdiff_t size; |
| 86 | 86 | ||
| 87 | /* Private data; users should not touch this. */ | 87 | /* Private data; users should not touch this. */ |
| 88 | struct emacs_env_private *private_members; | 88 | struct emacs_env_private *private_members; |
| @@ -165,11 +165,11 @@ struct emacs_env_25 | |||
| 165 | bool (*copy_string_contents) (emacs_env *env, | 165 | bool (*copy_string_contents) (emacs_env *env, |
| 166 | emacs_value value, | 166 | emacs_value value, |
| 167 | char *buffer, | 167 | char *buffer, |
| 168 | size_t *size_inout); | 168 | ptrdiff_t *size_inout); |
| 169 | 169 | ||
| 170 | /* Create a Lisp string from a utf8 encoded string. */ | 170 | /* Create a Lisp string from a utf8 encoded string. */ |
| 171 | emacs_value (*make_string) (emacs_env *env, | 171 | emacs_value (*make_string) (emacs_env *env, |
| 172 | const char *contents, size_t length); | 172 | const char *contents, ptrdiff_t length); |
| 173 | 173 | ||
| 174 | /* Embedded pointer type. */ | 174 | /* Embedded pointer type. */ |
| 175 | emacs_value (*make_user_ptr) (emacs_env *env, | 175 | emacs_value (*make_user_ptr) (emacs_env *env, |
| @@ -186,12 +186,12 @@ struct emacs_env_25 | |||
| 186 | void (*fin) (void *) EMACS_NOEXCEPT); | 186 | void (*fin) (void *) EMACS_NOEXCEPT); |
| 187 | 187 | ||
| 188 | /* Vector functions. */ | 188 | /* Vector functions. */ |
| 189 | emacs_value (*vec_get) (emacs_env *env, emacs_value vec, size_t i); | 189 | emacs_value (*vec_get) (emacs_env *env, emacs_value vec, ptrdiff_t i); |
| 190 | 190 | ||
| 191 | void (*vec_set) (emacs_env *env, emacs_value vec, size_t i, | 191 | void (*vec_set) (emacs_env *env, emacs_value vec, ptrdiff_t i, |
| 192 | emacs_value val); | 192 | emacs_value val); |
| 193 | 193 | ||
| 194 | size_t (*vec_size) (emacs_env *env, emacs_value vec); | 194 | ptrdiff_t (*vec_size) (emacs_env *env, emacs_value vec); |
| 195 | }; | 195 | }; |
| 196 | 196 | ||
| 197 | #ifdef __cplusplus | 197 | #ifdef __cplusplus |