Add indentation checks for code inside classes and fix appeared issues.
Fix asserts in test_recordset.cpp. JerryScript-DCO-1.0-Signed-off-by: Andrey Shitov a.shitov@samsung.com
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
*/
|
||||
class rcs_chunked_list_t
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* List node
|
||||
*/
|
||||
@@ -65,7 +65,7 @@ class rcs_chunked_list_t
|
||||
|
||||
static size_t get_data_space_size (void);
|
||||
|
||||
private:
|
||||
private:
|
||||
void set_prev (node_t *node_p, node_t *prev_node_p);
|
||||
void set_next (node_t *node_p, node_t *next_node_p);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
*/
|
||||
class rcs_recordset_t
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/* Constructor */
|
||||
void init (void)
|
||||
{
|
||||
@@ -138,7 +138,8 @@ class rcs_recordset_t
|
||||
*/
|
||||
static const uint32_t _fields_offset_begin = _type_field_pos + _type_field_width;
|
||||
};
|
||||
private:
|
||||
|
||||
private:
|
||||
friend class rcs_record_iterator_t;
|
||||
|
||||
/**
|
||||
@@ -157,7 +158,7 @@ class rcs_recordset_t
|
||||
|
||||
void init_free_record (record_t *free_rec_p, size_t size, record_t *prev_rec_p);
|
||||
bool is_record_free (record_t *record_p);
|
||||
protected:
|
||||
protected:
|
||||
/**
|
||||
* First type identifier that can be used for storage-specific record types
|
||||
*/
|
||||
@@ -219,15 +220,15 @@ typedef rcs_record_t::cpointer_t rcs_cpointer_t;
|
||||
*/
|
||||
class rcs_record_iterator_t
|
||||
{
|
||||
public:
|
||||
public:
|
||||
rcs_record_iterator_t (rcs_record_t* rec_p);
|
||||
rcs_record_iterator_t (rcs_cpointer_t rec_ext_cp);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
template<typename T> T read (void);
|
||||
template<typename T> void write (T value);
|
||||
|
||||
private:
|
||||
private:
|
||||
rcs_record_t* _record_start_p; /**< start of current record */
|
||||
uint8_t* _current_pos_p; /**< pointer to current offset in current record */
|
||||
|
||||
@@ -239,13 +240,13 @@ class rcs_record_iterator_t
|
||||
*/
|
||||
class rcs_free_record_t : public rcs_record_t
|
||||
{
|
||||
public:
|
||||
public:
|
||||
size_t get_size (void) const;
|
||||
void set_size (size_t size);
|
||||
|
||||
rcs_record_t* get_prev (void) const;
|
||||
void set_prev (rcs_record_t* prev_rec_p);
|
||||
private:
|
||||
private:
|
||||
/**
|
||||
* Offset of 'length' field, in bits
|
||||
*/
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "jrt.h"
|
||||
#include "mem-allocator.h"
|
||||
#include "rcs-recordset.h"
|
||||
@@ -45,7 +43,7 @@ extern "C"
|
||||
|
||||
class test_rcs_record_type_one_t : public rcs_record_t
|
||||
{
|
||||
public:
|
||||
public:
|
||||
static size_t size (uint32_t elements_count)
|
||||
{
|
||||
return JERRY_ALIGNUP (header_size + element_size * elements_count,
|
||||
@@ -74,7 +72,7 @@ class test_rcs_record_type_one_t : public rcs_record_t
|
||||
set_pointer (prev_field_pos, prev_field_width, prev_rec_p);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
static const uint32_t length_field_pos = _fields_offset_begin;
|
||||
static const uint32_t length_field_width = 12u;
|
||||
|
||||
@@ -87,7 +85,7 @@ class test_rcs_record_type_one_t : public rcs_record_t
|
||||
|
||||
class test_rcs_record_type_two_t : public rcs_record_t
|
||||
{
|
||||
public:
|
||||
public:
|
||||
static size_t size (void)
|
||||
{
|
||||
return JERRY_ALIGNUP (header_size, RCS_DYN_STORAGE_LENGTH_UNIT);
|
||||
@@ -113,7 +111,7 @@ class test_rcs_record_type_two_t : public rcs_record_t
|
||||
set_pointer (prev_field_pos, prev_field_width, prev_rec_p);
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
static const uint32_t prev_field_pos = _fields_offset_begin;
|
||||
static const uint32_t prev_field_width = rcs_cpointer_t::bit_field_width;
|
||||
|
||||
@@ -122,7 +120,7 @@ class test_rcs_record_type_two_t : public rcs_record_t
|
||||
|
||||
class test_rcs_recordset_t : public rcs_recordset_t
|
||||
{
|
||||
public:
|
||||
public:
|
||||
test_rcs_record_type_one_t*
|
||||
create_record_type_one (uint32_t elements_count)
|
||||
{
|
||||
@@ -147,7 +145,7 @@ class test_rcs_recordset_t : public rcs_recordset_t
|
||||
{
|
||||
free_record (rec_p);
|
||||
}
|
||||
private:
|
||||
private:
|
||||
static const int _record_type_one_id = _first_type_id + 0;
|
||||
static const int _record_type_two_id = _first_type_id + 1;
|
||||
|
||||
@@ -243,23 +241,23 @@ main (int __attr_unused___ argc,
|
||||
{
|
||||
if (rand () % 2)
|
||||
{
|
||||
assert (type_one_records_number < test_sub_iters);
|
||||
JERRY_ASSERT (type_one_records_number < test_sub_iters);
|
||||
|
||||
uint32_t elements_count = ((uint32_t) rand ()) % test_max_type_one_record_elements;
|
||||
type_one_record_element_counts[type_one_records_number] = elements_count;
|
||||
type_one_records[type_one_records_number] = storage.create_record_type_one (elements_count);
|
||||
|
||||
assert (type_one_records[type_one_records_number] != NULL);
|
||||
JERRY_ASSERT (type_one_records[type_one_records_number] != NULL);
|
||||
|
||||
type_one_records_number++;
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (type_two_records_number < test_sub_iters);
|
||||
JERRY_ASSERT (type_two_records_number < test_sub_iters);
|
||||
|
||||
type_two_records[type_two_records_number] = storage.create_record_type_two ();
|
||||
|
||||
assert (type_two_records[type_two_records_number] != NULL);
|
||||
JERRY_ASSERT (type_two_records[type_two_records_number] != NULL);
|
||||
|
||||
type_two_records_number++;
|
||||
}
|
||||
@@ -271,13 +269,13 @@ main (int __attr_unused___ argc,
|
||||
|
||||
if (type_one_records_number == 0)
|
||||
{
|
||||
assert (type_two_records_number != 0);
|
||||
JERRY_ASSERT (type_two_records_number != 0);
|
||||
|
||||
free_type_one = false;
|
||||
}
|
||||
else if (type_two_records_number == 0)
|
||||
{
|
||||
assert (type_one_records_number != 0);
|
||||
JERRY_ASSERT (type_one_records_number != 0);
|
||||
|
||||
free_type_one = true;
|
||||
}
|
||||
@@ -288,10 +286,10 @@ main (int __attr_unused___ argc,
|
||||
|
||||
if (free_type_one)
|
||||
{
|
||||
assert (type_one_records_number > 0);
|
||||
JERRY_ASSERT (type_one_records_number > 0);
|
||||
int index_to_free = (rand () % type_one_records_number);
|
||||
|
||||
assert (index_to_free >= 0 && index_to_free < type_one_records_number);
|
||||
JERRY_ASSERT (index_to_free >= 0 && index_to_free < type_one_records_number);
|
||||
|
||||
storage.free_record_type_one (type_one_records[index_to_free]);
|
||||
|
||||
@@ -306,10 +304,10 @@ main (int __attr_unused___ argc,
|
||||
}
|
||||
else
|
||||
{
|
||||
assert (type_two_records_number > 0);
|
||||
JERRY_ASSERT (type_two_records_number > 0);
|
||||
int index_to_free = (rand () % type_two_records_number);
|
||||
|
||||
assert (index_to_free >= 0 && index_to_free < type_two_records_number);
|
||||
JERRY_ASSERT (index_to_free >= 0 && index_to_free < type_two_records_number);
|
||||
|
||||
storage.free_record_type_two (type_two_records[index_to_free]);
|
||||
|
||||
|
||||
@@ -22,7 +22,9 @@ foreach fileName [getSourceFileNames] {
|
||||
set is_in_comment "no"
|
||||
set is_in_pp_define "no"
|
||||
set is_in_class "no"
|
||||
set is_in_template "no"
|
||||
set parentheses_level 0
|
||||
set template_brackets_level 0
|
||||
|
||||
foreach token [getTokens $fileName 1 0 -1 -1 {}] {
|
||||
set type [lindex $token 3]
|
||||
@@ -36,6 +38,8 @@ foreach fileName [getSourceFileNames] {
|
||||
set is_in_pp_define "no"
|
||||
} elseif {$type == "class"} {
|
||||
set is_in_class "yes"
|
||||
} elseif {$type == "template"} {
|
||||
set is_in_template "yes"
|
||||
} elseif {$is_in_class == "yes" && $type == "semicolon" && $indent == 0} {
|
||||
set is_in_class "no"
|
||||
} elseif {$type == "ccomment"} {
|
||||
@@ -52,17 +56,20 @@ foreach fileName [getSourceFileNames] {
|
||||
incr indent -2
|
||||
}
|
||||
|
||||
if {$is_in_pp_define == "no" && $is_in_comment == "no" && $is_in_class == "no" && $parentheses_level == 0} {
|
||||
if {$is_in_pp_define == "no" && $is_in_comment == "no" && $parentheses_level == 0 &&
|
||||
$is_in_template == "no"} {
|
||||
set line [getLine $fileName $lineNumber]
|
||||
|
||||
if {$lineNumber != $lastCheckedLineNumber} {
|
||||
if {[string length $line] == 0} {
|
||||
}
|
||||
|
||||
if {[regexp {^[[:blank:]]*} $line match]} {
|
||||
set real_indent [string length $match]
|
||||
if {$indent != $real_indent} {
|
||||
if {![regexp {^[[:alnum:]_]{1,}:$} $line] || $real_indent != 0} {
|
||||
if {[regexp {^[[:blank:]]*(private:|public:|protected:)} $line]} {
|
||||
if {$indent != $real_indent + 2} {
|
||||
set exp_indent [expr {$indent - 2}]
|
||||
report $fileName $lineNumber "Indentation: $real_indent -> $exp_indent. Line: '$line'"
|
||||
}
|
||||
} elseif {![regexp {^[[:alnum:]_]{1,}:$} $line] || $real_indent != 0} {
|
||||
report $fileName $lineNumber "Indentation: $real_indent -> $indent. Line: '$line'"
|
||||
}
|
||||
}
|
||||
@@ -84,7 +91,7 @@ foreach fileName [getSourceFileNames] {
|
||||
}
|
||||
}
|
||||
if {$type == "rightbrace"} {
|
||||
if {![regexp {^[[:blank:]]*\}((( [a-z_\(][a-z0-9_\(\)]{0,}){1,})?;| /\*.*\*/| //.*)?$} $line]
|
||||
if {![regexp {^[[:blank:]]*\};?((( [a-z_\(][a-z0-9_\(\)]{0,}){1,})?;| /\*.*\*/| //.*)?$} $line]
|
||||
&& ![regexp {[^\{=]=[^\{=]\{.*\}[,;]?} $line]} {
|
||||
report $fileName $lineNumber "Right brace is not the only non-space character in the line and \
|
||||
is not single right brace followed by \[a-z0-9_() \] string and single semicolon character: '$line'"
|
||||
@@ -100,6 +107,17 @@ foreach fileName [getSourceFileNames] {
|
||||
incr parentheses_level -1
|
||||
}
|
||||
|
||||
if {$is_in_template == "yes"} {
|
||||
if {$type == "less"} {
|
||||
incr template_brackets_level
|
||||
} elseif {$type == "greater"} {
|
||||
incr template_brackets_level -1
|
||||
if {$template_brackets_level == 0} {
|
||||
set is_in_template "no"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set lastCheckedLineNumber $lineNumber
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user