1
0
mirror of https://github.com/TREX-CoE/qmckl.git synced 2024-07-03 01:46:12 +02:00

Fixed const in munit and tests

This commit is contained in:
Anthony Scemama 2021-03-29 01:39:12 +02:00
parent 293f0a008e
commit 09c8f9700f
2 changed files with 11 additions and 9 deletions

View File

@ -586,11 +586,7 @@ qmckl_exit_code qmckl_context_remove_memory(qmckl_context context,
qmckl_unlock(context); qmckl_unlock(context);
if (alloc != NULL) {
return QMCKL_SUCCESS; return QMCKL_SUCCESS;
} else {
return QMCKL_DEALLOCATION_FAILED;
}
} }
#+end_src #+end_src

View File

@ -145,7 +145,8 @@ return '\n'.join(result)
: 128 : 128
#+begin_src c :comments org :tangle (eval h) :exports none :noweb yes #+begin_src c :comments org :tangle (eval h) :exports none :noweb yes
void qmckl_string_of_error(qmckl_exit_code error, char string[<<MAX_STRING_LENGTH()>>]); const char* qmckl_string_of_error(const qmckl_exit_code error);
void qmckl_string_of_error_f(const qmckl_exit_code error, char result[<<MAX_STRING_LENGTH()>>]);
#+end_src #+end_src
The text strings are extracted from the previous table. The text strings are extracted from the previous table.
@ -161,7 +162,7 @@ for (text, code, message) in table:
text = text.replace("~","") text = text.replace("~","")
message = message.replace("'",'"') message = message.replace("'",'"')
result += [ f"""case {text}: result += [ f"""case {text}:
strncpy(string,{message},<<MAX_STRING_LENGTH()>>); return {message};
break;""" ] break;""" ]
return '\n'.join(result) return '\n'.join(result)
@ -169,17 +170,22 @@ return '\n'.join(result)
# Source # Source
#+begin_src c :comments org :tangle (eval c) :noweb yes #+begin_src c :comments org :tangle (eval c) :noweb yes
void qmckl_string_of_error(qmckl_exit_code error, char string[<<MAX_STRING_LENGTH()>>]) { const char* qmckl_string_of_error(const qmckl_exit_code error) {
switch (error) { switch (error) {
<<cases()>> <<cases()>>
} }
return "Unknown error";
}
void qmckl_string_of_error_f(const qmckl_exit_code error, char result[<<MAX_STRING_LENGTH()>>]) {
strncpy(result, qmckl_string_of_error(error), <<MAX_STRING_LENGTH()>>);
} }
#+end_src #+end_src
# Fortran interface # Fortran interface
#+begin_src f90 :tangle (eval fh) :noexport :noweb yes #+begin_src f90 :tangle (eval fh) :noexport :noweb yes
interface interface
subroutine qmckl_string_of_error (error, string) bind(C) subroutine qmckl_string_of_error (error, string) bind(C, name='qmckl_string_of_error_f')
use, intrinsic :: iso_c_binding use, intrinsic :: iso_c_binding
integer (c_int32_t), intent(in), value :: error integer (c_int32_t), intent(in), value :: error
character, intent(out) :: string(<<MAX_STRING_LENGTH()>>) character, intent(out) :: string(<<MAX_STRING_LENGTH()>>)