diff --git a/jerry-core/ecma/base/ecma-helpers-string.cpp b/jerry-core/ecma/base/ecma-helpers-string.cpp index 9385f53f0..f6e9e5b04 100644 --- a/jerry-core/ecma/base/ecma-helpers-string.cpp +++ b/jerry-core/ecma/base/ecma-helpers-string.cpp @@ -935,7 +935,7 @@ ecma_string_get_array_index (const ecma_string_t *str_p, /**< ecma-string */ is_array_index = is_array_index && (*out_index_p != ECMA_MAX_VALUE_OF_VALID_ARRAY_INDEX); return is_array_index; -} /* ecma_string_is_array_index */ +} /* ecma_string_get_array_index */ /** * Convert ecma-string's contents to a cesu-8 string and put it to the buffer. @@ -1283,8 +1283,7 @@ ecma_compare_ecma_strings_relational (const ecma_string_t *string1_p, /**< ecma- } return is_first_less_than_second; -} -/* ecma_compare_ecma_strings_relational */ +} /* ecma_compare_ecma_strings_relational */ /** * Get length of ecma-string @@ -1629,7 +1628,7 @@ ecma_string_hash (const ecma_string_t *string_p) /**< ecma-string to calculate h { return (string_p->hash); -} /* ecma_string_try_hash */ +} /* ecma_string_hash */ /** * Create a substring from an ecma string diff --git a/jerry-core/ecma/base/ecma-helpers.cpp b/jerry-core/ecma/base/ecma-helpers.cpp index a85dca8d3..b96c19eea 100644 --- a/jerry-core/ecma/base/ecma-helpers.cpp +++ b/jerry-core/ecma/base/ecma-helpers.cpp @@ -1019,7 +1019,7 @@ ecma_get_named_accessor_property_getter (const ecma_property_t *prop_p) /**< nam prop_p->u.named_accessor_property.getter_setter_pair_cp); return ECMA_GET_POINTER (ecma_object_t, getter_setter_pointers_p->getter_p); -} /* ecma_named_accessor_property_get_getter */ +} /* ecma_get_named_accessor_property_getter */ /** * Get setter of named accessor property @@ -1036,7 +1036,7 @@ ecma_get_named_accessor_property_setter (const ecma_property_t *prop_p) /**< nam prop_p->u.named_accessor_property.getter_setter_pair_cp); return ECMA_GET_POINTER (ecma_object_t, getter_setter_pointers_p->setter_p); -} /* ecma_named_accessor_property_get_setter */ +} /* ecma_get_named_accessor_property_setter */ /** * Set getter of named accessor property @@ -1054,7 +1054,7 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope prop_p->u.named_accessor_property.getter_setter_pair_cp); ECMA_SET_POINTER (getter_setter_pointers_p->getter_p, getter_p); -} /* ecma_named_accessor_property_set_getter */ +} /* ecma_set_named_accessor_property_getter */ /** * Set setter of named accessor property @@ -1072,7 +1072,7 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope prop_p->u.named_accessor_property.getter_setter_pair_cp); ECMA_SET_POINTER (getter_setter_pointers_p->setter_p, setter_p); -} /* ecma_named_accessor_property_set_setter */ +} /* ecma_set_named_accessor_property_setter */ /** * Get property's 'Writable' attribute value diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.cpp b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.cpp index 9fc3aed10..cb21e119c 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers-json.cpp @@ -143,7 +143,7 @@ ecma_builtin_helper_json_create_separated_properties (ecma_collection_header_t * } return properties_str_p; -} /* ecma_builtin_json_helper_create_separated_properties */ +} /* ecma_builtin_helper_json_create_separated_properties */ /** * Common function to create a formatted JSON string. @@ -213,7 +213,7 @@ ecma_builtin_helper_json_create_formatted_json (ecma_string_t *left_bracket_p, / final_str_p = tmp_str_p; return ecma_make_normal_completion_value (ecma_make_string_value (final_str_p)); -} /* ecma_builtin_json_helper_create_formatted_json */ +} /* ecma_builtin_helper_json_create_formatted_json */ /** * Common function to create a non-formatted JSON string. @@ -252,7 +252,7 @@ ecma_builtin_helper_json_create_non_formatted_json (ecma_string_t *left_bracket_ properties_str_p = tmp_str_p; return ecma_make_normal_completion_value (ecma_make_string_value (properties_str_p)); -} /* ecma_builtin_json_helper_create_non_formatted_json */ +} /* ecma_builtin_helper_json_create_non_formatted_json */ /** * Convert decimal value to 4 digit hexadecimal string value. diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.cpp b/jerry-core/ecma/builtin-objects/ecma-builtins.cpp index 3e6c6a65d..f58509e91 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.cpp +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.cpp @@ -452,7 +452,7 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in JERRY_UNREACHABLE (); } -} /* ecma_builtin_list_and_lazy_property_names */ +} /* ecma_builtin_list_lazy_property_names */ /** * Construct a Function object for specified built-in routine diff --git a/jerry-core/ecma/operations/ecma-regexp-object.cpp b/jerry-core/ecma/operations/ecma-regexp-object.cpp index 06f803579..929dc422b 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.cpp +++ b/jerry-core/ecma/operations/ecma-regexp-object.cpp @@ -1167,7 +1167,7 @@ re_match_regexp (re_matcher_ctx_t *re_ctx_p, /**< RegExp matcher context */ JERRY_UNREACHABLE (); return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE); /* fail */ -} /* regexp_match */ +} /* re_match_regexp */ /** * Define the necessary properties for the result array (index, input, length). diff --git a/jerry-core/jerry.cpp b/jerry-core/jerry.cpp index 4b1831bd2..6f521e53b 100644 --- a/jerry-core/jerry.cpp +++ b/jerry-core/jerry.cpp @@ -807,7 +807,7 @@ jerry_api_create_error (jerry_api_error_t error_type, /**< type of error */ return jerry_api_create_error_sz (error_type, (lit_utf8_byte_t *) message_p, lit_zt_utf8_string_size (message_p)); -} +} /* jerry_api_create_error */ /** * Create an error object @@ -885,7 +885,7 @@ jerry_api_create_error_sz (jerry_api_error_t error_type, /**< type of error */ return error_object_p; } -} /* jerry_api_create_error */ +} /* jerry_api_create_error_sz */ /** * Create an external function object @@ -1136,7 +1136,7 @@ bool jerry_api_get_object_field_value (jerry_api_object_t *object_p, /**< object field_name_p, lit_zt_utf8_string_size (field_name_p), field_value_p); -} +} /* jerry_api_get_object_field_value */ /** * Applies the given function to the every fields in the objects @@ -1241,7 +1241,7 @@ jerry_api_get_object_field_value_sz (jerry_api_object_t *object_p, /**< object * ecma_deref_ecma_string (field_name_str_p); return is_successful; -} /* jerry_api_get_object_field_value */ +} /* jerry_api_get_object_field_value_sz */ /** * Set value of field in the specified object @@ -1259,7 +1259,7 @@ jerry_api_set_object_field_value (jerry_api_object_t *object_p, /**< object */ field_name_p, lit_zt_utf8_string_size (field_name_p), field_value_p); -} +} /* jerry_api_set_object_field_value */ /** * Set value of field in the specified object @@ -1302,7 +1302,7 @@ jerry_api_set_object_field_value_sz (jerry_api_object_t *object_p, /**< object * ecma_deref_ecma_string (field_name_str_p); return is_successful; -} /* jerry_api_set_object_field_value */ +} /* jerry_api_set_object_field_value_sz */ /** * Get native handle, associated with specified object diff --git a/jerry-core/lit/lit-snapshot.cpp b/jerry-core/lit/lit-snapshot.cpp index 80059f4e0..bb44a2c29 100644 --- a/jerry-core/lit/lit-snapshot.cpp +++ b/jerry-core/lit/lit-snapshot.cpp @@ -125,7 +125,7 @@ lit_snapshot_dump (lit_literal_t lit, /**< literal to dump */ JERRY_UNREACHABLE (); return 0; -} /* rcs_snapshot_dump */ +} /* lit_snapshot_dump */ /** * Dump literals to specified snapshot buffer. @@ -410,6 +410,6 @@ lit_load_literals_from_snapshot (const uint8_t *lit_table_p, /**< buffer with li mem_heap_free_block (id_map_p); return false; -} /* rcs_load_literals_from_snapshot */ +} /* lit_load_literals_from_snapshot */ #endif /* JERRY_ENABLE_SNAPSHOT_EXEC */ diff --git a/jerry-core/lit/lit-strings.cpp b/jerry-core/lit/lit-strings.cpp index 2bf608b10..6a72a240c 100644 --- a/jerry-core/lit/lit-strings.cpp +++ b/jerry-core/lit/lit-strings.cpp @@ -847,7 +847,7 @@ lit_code_point_to_cesu8 (lit_code_point_t code_point, /**< code point */ offset += lit_code_unit_to_utf8 (convert_code_point_to_low_surrogate (code_point), buf + offset); return offset; } -} /* lit_code_point_to_utf8 */ +} /* lit_code_point_to_cesu8 */ /** * Convert code point to utf-8 representation diff --git a/jerry-core/parser/regexp/re-compiler.cpp b/jerry-core/parser/regexp/re-compiler.cpp index 611bae725..e05e16e6d 100644 --- a/jerry-core/parser/regexp/re-compiler.cpp +++ b/jerry-core/parser/regexp/re-compiler.cpp @@ -201,7 +201,7 @@ re_get_opcode (uint8_t **bc_p) /**< pointer to bytecode start */ uint8_t bytecode = **bc_p; (*bc_p) += sizeof (uint8_t); return (re_opcode_t) bytecode; -} /* get_opcode */ +} /* re_get_opcode */ /** * Get a parameter of a RegExp opcode @@ -212,7 +212,7 @@ re_get_value (uint8_t **bc_p) /**< pointer to bytecode start */ uint32_t value = *((uint32_t*) *bc_p); (*bc_p) += sizeof (uint32_t); return value; -} /* get_value */ +} /* re_get_value */ /** * Callback function of character class generation diff --git a/jerry-core/rcs/rcs-allocator.cpp b/jerry-core/rcs/rcs-allocator.cpp index fd27bf9d6..16664b56e 100644 --- a/jerry-core/rcs/rcs-allocator.cpp +++ b/jerry-core/rcs/rcs-allocator.cpp @@ -299,7 +299,7 @@ rcs_alloc_record (rcs_record_set_t *rec_set_p, /**< recordset */ rcs_assert_state_is_correct (rec_set_p); return rec_p; -} /* alloc_record */ +} /* rcs_alloc_record */ /** * Free the specified record. diff --git a/jerry-core/rcs/rcs-records.cpp b/jerry-core/rcs/rcs-records.cpp index 7cf043d3c..de9cf09bd 100644 --- a/jerry-core/rcs/rcs-records.cpp +++ b/jerry-core/rcs/rcs-records.cpp @@ -142,7 +142,7 @@ rcs_record_set_alignment_bytes_count (rcs_record_t *rec_p, /**< record */ JERRY_ASSERT (RCS_RECORD_IS_CHARSET (rec_p)); rcs_record_set_field (rec_p, RCS_CHARSET_HEADER_ALIGN_POS, RCS_CHARSET_HEADER_ALIGN_WIDTH, count); -} /* rcs_record_set_align */ +} /* rcs_record_set_alignment_bytes_count */ /** * Set the hash value of the record. diff --git a/jerry-libc/jerry-libc-printf.c b/jerry-libc/jerry-libc-printf.c index 6dde07856..fb2e80559 100644 --- a/jerry-libc/jerry-libc-printf.c +++ b/jerry-libc/jerry-libc-printf.c @@ -304,7 +304,7 @@ libc_printf_write_d_i (FILE *stream, /**< stream pointer */ width, flags & LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY, flags & LIBC_PRINTF_ARG_FLAG_ZERO_PADDING); -} /** libc_printf_write_d_i */ +} /* libc_printf_write_d_i */ /** * printf helper function that prints d and i arguments @@ -470,7 +470,7 @@ libc_printf_write_u_o_x_X (FILE *stream, /**< stream pointer */ width, flags & LIBC_PRINTF_ARG_FLAG_LEFT_JUSTIFY, flags & LIBC_PRINTF_ARG_FLAG_ZERO_PADDING); -} /** libc_printf_write_u_o_x_X */ +} /* libc_printf_write_u_o_x_X */ /** * vfprintf diff --git a/jerry-libc/jerry-libc.c b/jerry-libc/jerry-libc.c index d53c563c6..dd53ded79 100644 --- a/jerry-libc/jerry-libc.c +++ b/jerry-libc/jerry-libc.c @@ -173,7 +173,7 @@ strcmp (const char *str1, const char *str2) while (s1 == s2); return (s1 < s2) ? -1 : (s1 > s2 ? 1 : 0); -} +} /* strcmp */ /** Compare two strings. return an integer less than, equal to, or greater than zero if the first n character of s1 is found, respectively, to be less than, to match, @@ -217,7 +217,7 @@ strncmp (const char *s1, const char *s2, size_t n) } return 0; -} +} /* strncmp */ /** Copy a string. At most n bytes of src are copied. Warning: If there is no null byte among the first n bytes of src, the string placed in dest will not be null-terminated. @@ -237,7 +237,7 @@ strncpy (char *dest, const char *src, size_t n) } return dest; -} +} /* strncpy */ /** Calculate the length of a string. */ size_t @@ -250,7 +250,7 @@ strlen (const char *s) } return i; -} +} /* strlen */ /** * Generate pseudo-random integer diff --git a/main-mcu.cpp b/main-mcu.cpp index 56aec57f0..465079d1a 100644 --- a/main-mcu.cpp +++ b/main-mcu.cpp @@ -43,4 +43,4 @@ main (void) { return JERRY_STANDALONE_EXIT_CODE_FAIL; } -} +} /* main */ diff --git a/main-unix.cpp b/main-unix.cpp index 6805b8195..61e6434a1 100644 --- a/main-unix.cpp +++ b/main-unix.cpp @@ -109,7 +109,7 @@ read_sources (const char *script_file_names[], return (const jerry_api_char_t *) buffer; } -} +} /* read_sources */ static bool read_snapshot (const char *snapshot_file_name_p, @@ -481,4 +481,4 @@ main (int argc, return JERRY_STANDALONE_EXIT_CODE_FAIL; } } -} +} /* main */ diff --git a/main.h b/main.h index ca58ca819..5d84af409 100644 --- a/main.h +++ b/main.h @@ -29,7 +29,7 @@ int jerry_port_logmsg (FILE *stream, /**< stream pointer */ count = vfprintf (stream, format, args); va_end (args); return count; -} +} /* jerry_port_logmsg */ /** * Provide error message to console implementation for the engine. @@ -43,7 +43,7 @@ int jerry_port_errormsg (const char *format, /**< format string */ count = vfprintf (stderr, format, args); va_end (args); return count; -} +} /* jerry_port_errormsg */ /** @@ -52,6 +52,6 @@ int jerry_port_errormsg (const char *format, /**< format string */ int jerry_port_putchar (int c) /**< character to put */ { return putchar (c); -} +} /* jerry_port_putchar */ #endif /* !MAIN_H */ diff --git a/tests/unit/test-api.cpp b/tests/unit/test-api.cpp index c0b3b8c6c..c34f4b098 100644 --- a/tests/unit/test-api.cpp +++ b/tests/unit/test-api.cpp @@ -154,7 +154,7 @@ handler_throw_test (const jerry_api_object_t *function_obj_p, jerry_api_release_object (error_p); return false; -} +} /* handler_throw_test */ static void handler_construct_freecb (uintptr_t native_p) @@ -285,7 +285,7 @@ static bool foreach (const jerry_api_string_t *name, JERRY_ASSERT (!strncmp ((const char*)user_data, "user_data", 9)); return true; -} +} /* foreach */ static bool foreach_exception (const jerry_api_string_t *name, const jerry_api_value_t *, void *) { @@ -298,7 +298,7 @@ static bool foreach_exception (const jerry_api_string_t *name, const jerry_api_v JERRY_ASSERT (false); } return true; -} +} /* foreach_exception */ static bool foreach_subset (const jerry_api_string_t *, const jerry_api_value_t *, void *user_data) { @@ -309,7 +309,8 @@ static bool foreach_subset (const jerry_api_string_t *, const jerry_api_value_t } (*count_p)++; return true; -} +} /* foreach_subset */ + int main (void) { @@ -740,4 +741,4 @@ main (void) } return 0; -} +} /* main */ diff --git a/tests/unit/test-common.h b/tests/unit/test-common.h index 4c9f53741..59e72bc91 100644 --- a/tests/unit/test-common.h +++ b/tests/unit/test-common.h @@ -75,7 +75,7 @@ int jerry_port_logmsg (FILE *stream, /**< stream pointer */ count = vfprintf (stream, format, args); va_end (args); return count; -} +} /* jerry_port_logmsg */ /** * Provide error message to console implementation for the engine. @@ -89,7 +89,7 @@ int jerry_port_errormsg (const char *format, /**< format string */ count = vfprintf (stderr, format, args); va_end (args); return count; -} +} /* jerry_port_errormsg */ /** * Provide output character to console implementation for the engine. @@ -97,6 +97,6 @@ int jerry_port_errormsg (const char *format, /**< format string */ int jerry_port_putchar (int c) /**< character to put */ { return putchar (c); -} +} /* jerry_port_putchar */ #endif /* TEST_COMMON_H */ diff --git a/tests/unit/test-literal-storage.cpp b/tests/unit/test-literal-storage.cpp index 839fe9f0a..91869ebe8 100644 --- a/tests/unit/test-literal-storage.cpp +++ b/tests/unit/test-literal-storage.cpp @@ -37,7 +37,7 @@ generate_string (lit_utf8_byte_t *str, lit_utf8_size_t len) { str[i] = bytes[(unsigned long) rand () % length]; } -} +} /* generate_string */ static ecma_number_t generate_number () @@ -53,7 +53,7 @@ generate_number () num *= 10; } return num; -} +} /* generate_number */ int main (int __attr_unused___ argc, @@ -140,4 +140,4 @@ main (int __attr_unused___ argc, lit_finalize (); mem_finalize (true); return 0; -} +} /* main */ diff --git a/tests/unit/test-longjmp.cpp b/tests/unit/test-longjmp.cpp index a9ad08ab3..51e1149d4 100644 --- a/tests/unit/test-longjmp.cpp +++ b/tests/unit/test-longjmp.cpp @@ -65,7 +65,7 @@ test_setjmp_longjmp (volatile int depth) longjmp (buffers[t], t + 1); } -} +} /* test_setjmp_longjmp */ int main (int __attr_unused___ argc, diff --git a/tests/unit/test-strings.cpp b/tests/unit/test-strings.cpp index 37b241c29..a37c20cc4 100644 --- a/tests/unit/test-strings.cpp +++ b/tests/unit/test-strings.cpp @@ -71,7 +71,7 @@ generate_cesu8_char (utf8_char_size char_size, } return lit_code_unit_to_utf8 ((ecma_char_t) code_point, buf); -} +} /* generate_cesu8_char */ static ecma_length_t generate_cesu8_string (lit_utf8_byte_t *buf_p, @@ -98,7 +98,7 @@ generate_cesu8_string (lit_utf8_byte_t *buf_p, JERRY_ASSERT (size == buf_size); return length; -} +} /* generate_cesu8_string */ int main (int __attr_unused___ argc, @@ -232,4 +232,4 @@ main (int __attr_unused___ argc, mem_finalize (true); return 0; -} +} /* main */ diff --git a/tools/vera++/profiles/jerry b/tools/vera++/profiles/jerry index ddb3fe546..df35d059f 100644 --- a/tools/vera++/profiles/jerry +++ b/tools/vera++/profiles/jerry @@ -3,6 +3,7 @@ set rules { jerry_braces_on_separate_line jerry_braces_same_line_or_column jerry_dereference_operator_always_on_right + jerry_comment_function_end jerry_funcname_space_parentheses jerry_identifier_no_space_bracket jerry_indentation diff --git a/tools/vera++/scripts/rules/jerry_comment_function_end.tcl b/tools/vera++/scripts/rules/jerry_comment_function_end.tcl new file mode 100644 index 000000000..c0c8de572 --- /dev/null +++ b/tools/vera++/scripts/rules/jerry_comment_function_end.tcl @@ -0,0 +1,53 @@ +#!/usr/bin/tclsh + +# Copyright 2016 Samsung Electronics Co., Ltd. +# Copyright 2016 University of Szeged +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +foreach fileName [getSourceFileNames] { + set funcStart 0 + set funcName {} + set lineNumber 1 + foreach line [getAllLines $fileName] { + if {[regexp {^((static |const )*\w+ )*\w+ \(.*[,\)]} $line]} { + set type {} + set modifier {} + if {$funcStart == 0} { + regexp {^((static |const )*\w+ )*(\w+) \(} $line matched type modifier funcName + } + } + + if {[regexp {^\{$} $line]} { + set funcStart 1 + } + + if {$funcStart == 1} { + if {[regexp {^\}$} $line]} { + report $fileName $lineNumber "missing comment at the end of function: /* $funcName */" + set funcStart 0 + } elseif {[regexp {^\} /\*\s*\w+\s*\*/$} $line]} { + set comment {} + regexp {^\} /\*\s*(\w+)\s*\*/$} $line -> comment + if {$comment != $funcName} { + report $fileName $lineNumber "comment missmatch. (Current: $comment, Expected: $funcName)" + } + set funcStart 0 + } elseif {[regexp {^\}.*;$} $line]} { + set funcStart 0 + } + } + + incr lineNumber + } +}