Skip to content

Commit

Permalink
use C style comments instead of C++ style comments
Browse files Browse the repository at this point in the history
According to CONTRIBUTING.md,

Don't use C++ style comments

 /* This is the prefered comment style */

Use C++ style comments only for temporary comment e.g. commenting out some code lines.
  • Loading branch information
cubicdaiya committed Feb 28, 2014
1 parent 9b65a0d commit 67de10b
Show file tree
Hide file tree
Showing 20 changed files with 203 additions and 203 deletions.
Expand Up @@ -16,5 +16,5 @@ mrb_c_and_ruby_extension_example_gem_init(mrb_state* mrb) {


void void
mrb_c_and_ruby_extension_example_gem_final(mrb_state* mrb) { mrb_c_and_ruby_extension_example_gem_final(mrb_state* mrb) {
// finalizer /* finalizer */
} }
2 changes: 1 addition & 1 deletion examples/mrbgems/c_extension_example/src/example.c
Expand Up @@ -16,5 +16,5 @@ mrb_c_extension_example_gem_init(mrb_state* mrb) {


void void
mrb_c_extension_example_gem_final(mrb_state* mrb) { mrb_c_extension_example_gem_final(mrb_state* mrb) {
// finalizer /* finalizer */
} }
38 changes: 19 additions & 19 deletions include/mrbconf.h
Expand Up @@ -9,61 +9,61 @@


/* configuration options: */ /* configuration options: */
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */ /* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
//#define MRB_USE_FLOAT /* #define MRB_USE_FLOAT */


/* add -DMRB_INT16 to use 16bit integer for mrb_int; conflict with MRB_INT64 */ /* add -DMRB_INT16 to use 16bit integer for mrb_int; conflict with MRB_INT64 */
//#define MRB_INT16 /* #define MRB_INT16 */


/* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT16 */ /* add -DMRB_INT64 to use 64bit integer for mrb_int; conflict with MRB_INT16 */
//#define MRB_INT64 /* #define MRB_INT64 */


/* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT */ /* represent mrb_value in boxed double; conflict with MRB_USE_FLOAT */
//#define MRB_NAN_BOXING /* #define MRB_NAN_BOXING */


/* define on big endian machines; used by MRB_NAN_BOXING */ /* define on big endian machines; used by MRB_NAN_BOXING */
//#define MRB_ENDIAN_BIG /* #define MRB_ENDIAN_BIG */


/* represent mrb_value as a word (natural unit of data for the processor) */ /* represent mrb_value as a word (natural unit of data for the processor) */
// #define MRB_WORD_BOXING /* #define MRB_WORD_BOXING */


/* argv max size in mrb_funcall */ /* argv max size in mrb_funcall */
//#define MRB_FUNCALL_ARGC_MAX 16 /* #define MRB_FUNCALL_ARGC_MAX 16 */


/* number of object per heap page */ /* number of object per heap page */
//#define MRB_HEAP_PAGE_SIZE 1024 /* #define MRB_HEAP_PAGE_SIZE 1024 */


/* use segmented list for IV table */ /* use segmented list for IV table */
//#define MRB_USE_IV_SEGLIST /* #define MRB_USE_IV_SEGLIST */


/* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */ /* initial size for IV khash; ignored when MRB_USE_IV_SEGLIST is set */
//#define MRB_IVHASH_INIT_SIZE 8 /* #define MRB_IVHASH_INIT_SIZE 8 */


/* turn off generational GC by default */ /* turn off generational GC by default */
//#define MRB_GC_TURN_OFF_GENERATIONAL /* #define MRB_GC_TURN_OFF_GENERATIONAL */


/* default size of khash table bucket */ /* default size of khash table bucket */
//#define KHASH_DEFAULT_SIZE 32 /* #define KHASH_DEFAULT_SIZE 32 */


/* allocated memory address alignment */ /* allocated memory address alignment */
//#define POOL_ALIGNMENT 4 /* #define POOL_ALIGNMENT 4 */


/* page size of memory pool */ /* page size of memory pool */
//#define POOL_PAGE_SIZE 16000 /* #define POOL_PAGE_SIZE 16000 */


/* initial minimum size for string buffer */ /* initial minimum size for string buffer */
//#define MRB_STR_BUF_MIN_SIZE 128 /* #define MRB_STR_BUF_MIN_SIZE 128 */


/* arena size */ /* arena size */
//#define MRB_GC_ARENA_SIZE 100 /* #define MRB_GC_ARENA_SIZE 100 */


/* fixed size GC arena */ /* fixed size GC arena */
//#define MRB_GC_FIXED_ARENA /* #define MRB_GC_FIXED_ARENA */


/* -DDISABLE_XXXX to drop following features */ /* -DDISABLE_XXXX to drop following features */
//#define DISABLE_STDIO /* use of stdio */ /* #define DISABLE_STDIO */ /* use of stdio */


/* -DENABLE_XXXX to enable following features */ /* -DENABLE_XXXX to enable following features */
//#define ENABLE_DEBUG /* hooks for debugger */ /* #define ENABLE_DEBUG */ /* hooks for debugger */


/* end of configuration */ /* end of configuration */


Expand Down
2 changes: 1 addition & 1 deletion include/mruby.h
Expand Up @@ -304,7 +304,7 @@ mrb_value mrb_obj_clone(mrb_state *mrb, mrb_value self);


/* need to include <ctype.h> to use these macros */ /* need to include <ctype.h> to use these macros */
#ifndef ISPRINT #ifndef ISPRINT
//#define ISASCII(c) isascii((int)(unsigned char)(c)) /* #define ISASCII(c) isascii((int)(unsigned char)(c)) */
#define ISASCII(c) 1 #define ISASCII(c) 1
#define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c))) #define ISPRINT(c) (ISASCII(c) && isprint((int)(unsigned char)(c)))
#define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c))) #define ISSPACE(c) (ISASCII(c) && isspace((int)(unsigned char)(c)))
Expand Down
16 changes: 8 additions & 8 deletions include/mruby/dump.h
Expand Up @@ -55,17 +55,17 @@ mrb_irep *mrb_read_irep(mrb_state*, const uint8_t*);


#define MRB_DUMP_DEFAULT_STR_LEN 128 #define MRB_DUMP_DEFAULT_STR_LEN 128


// binary header /* binary header */
struct rite_binary_header { struct rite_binary_header {
uint8_t binary_identify[4]; // Binary Identifier uint8_t binary_identify[4]; /* Binary Identifier */
uint8_t binary_version[4]; // Binary Format Version uint8_t binary_version[4]; /* Binary Format Version */
uint8_t binary_crc[2]; // Binary CRC uint8_t binary_crc[2]; /* Binary CRC */
uint8_t binary_size[4]; // Binary Size uint8_t binary_size[4]; /* Binary Size */
uint8_t compiler_name[4]; // Compiler name uint8_t compiler_name[4]; /* Compiler name */
uint8_t compiler_version[4]; uint8_t compiler_version[4];
}; };


// section header /* section header */
#define RITE_SECTION_HEADER \ #define RITE_SECTION_HEADER \
uint8_t section_identify[4]; \ uint8_t section_identify[4]; \
uint8_t section_size[4] uint8_t section_size[4]
Expand All @@ -77,7 +77,7 @@ struct rite_section_header {
struct rite_section_irep_header { struct rite_section_irep_header {
RITE_SECTION_HEADER; RITE_SECTION_HEADER;


uint8_t rite_version[4]; // Rite Instruction Specification Version uint8_t rite_version[4]; /* Rite Instruction Specification Version */
}; };


struct rite_section_lineno_header { struct rite_section_lineno_header {
Expand Down
2 changes: 1 addition & 1 deletion include/mruby/khash.h
Expand Up @@ -24,7 +24,7 @@ typedef khint_t khiter_t;


#define UPPER_BOUND(x) ((x)>>2|(x)>>1) #define UPPER_BOUND(x) ((x)>>2|(x)>>1)


//extern uint8_t __m[]; /* extern uint8_t __m[]; */


/* mask for flags */ /* mask for flags */
static const uint8_t __m_empty[8] = {0x02, 0x08, 0x20, 0x80}; static const uint8_t __m_empty[8] = {0x02, 0x08, 0x20, 0x80};
Expand Down
6 changes: 3 additions & 3 deletions include/mruby/variable.h
Expand Up @@ -16,9 +16,9 @@ typedef struct global_variable {
mrb_value *data; mrb_value *data;
mrb_value (*getter)(void); mrb_value (*getter)(void);
void (*setter)(void); void (*setter)(void);
//void (*marker)(); /* void (*marker)(); */
//int block_trace; /* int block_trace; */
//struct trace_var *trace; /* struct trace_var *trace; */
} global_variable; } global_variable;


struct global_entry { struct global_entry {
Expand Down
2 changes: 1 addition & 1 deletion mrbgems/mruby-random/src/mt19937ar.c
Expand Up @@ -8,7 +8,7 @@
#include "mt19937ar.h" #include "mt19937ar.h"


/* Period parameters */ /* Period parameters */
//#define N 624 /* #define N 624 */
#define M 397 #define M 397
#define MATRIX_A 0x9908b0dfUL /* constant vector a */ #define MATRIX_A 0x9908b0dfUL /* constant vector a */
#define UPPER_MASK 0x80000000UL /* most significant w-r bits */ #define UPPER_MASK 0x80000000UL /* most significant w-r bits */
Expand Down
6 changes: 3 additions & 3 deletions mrbgems/mruby-random/src/random.h
@@ -1,7 +1,7 @@
/* /*
// random.h - Random module ** random.h - Random module
// **
// See Copyright Notice in mruby.h ** See Copyright Notice in mruby.h
*/ */


#ifndef RANDOM_H #ifndef RANDOM_H
Expand Down
10 changes: 5 additions & 5 deletions mrbgems/mruby-struct/src/struct.c
Expand Up @@ -216,15 +216,15 @@ mrb_struct_set_m(mrb_state *mrb, mrb_value obj)
return mrb_struct_set(mrb, obj, val); return mrb_struct_set(mrb, obj, val);
} }


#define is_notop_id(id) (id)//((id)>tLAST_TOKEN) #define is_notop_id(id) (id) /* ((id)>tLAST_TOKEN) */
#define is_local_id(id) (is_notop_id(id))//&&((id)&ID_SCOPE_MASK)==ID_LOCAL) #define is_local_id(id) (is_notop_id(id)) /* &&((id)&ID_SCOPE_MASK)==ID_LOCAL) */
int int
mrb_is_local_id(mrb_sym id) mrb_is_local_id(mrb_sym id)
{ {
return is_local_id(id); return is_local_id(id);
} }


#define is_const_id(id) (is_notop_id(id))//&&((id)&ID_SCOPE_MASK)==ID_CONST) #define is_const_id(id) (is_notop_id(id)) /* &&((id)&ID_SCOPE_MASK)==ID_CONST) */
int int
mrb_is_const_id(mrb_sym id) mrb_is_const_id(mrb_sym id)
{ {
Expand All @@ -251,7 +251,7 @@ make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * k
} }
if (mrb_const_defined_at(mrb, klass, id)) { if (mrb_const_defined_at(mrb, klass, id)) {
mrb_warn(mrb, "redefining constant Struct::%S", name); mrb_warn(mrb, "redefining constant Struct::%S", name);
//?rb_mod_remove_const(klass, mrb_sym2name(mrb, id)); /* ?rb_mod_remove_const(klass, mrb_sym2name(mrb, id)); */
} }
c = mrb_define_class_under(mrb, klass, RSTRING_PTR(name), klass); c = mrb_define_class_under(mrb, klass, RSTRING_PTR(name), klass);
} }
Expand All @@ -262,7 +262,7 @@ make_struct(mrb_state *mrb, mrb_value name, mrb_value members, struct RClass * k
mrb_define_class_method(mrb, c, "new", mrb_instance_new, MRB_ARGS_ANY()); mrb_define_class_method(mrb, c, "new", mrb_instance_new, MRB_ARGS_ANY());
mrb_define_class_method(mrb, c, "[]", mrb_instance_new, MRB_ARGS_ANY()); mrb_define_class_method(mrb, c, "[]", mrb_instance_new, MRB_ARGS_ANY());
mrb_define_class_method(mrb, c, "members", mrb_struct_s_members_m, MRB_ARGS_NONE()); mrb_define_class_method(mrb, c, "members", mrb_struct_s_members_m, MRB_ARGS_NONE());
//RSTRUCT(nstr)->basic.c->super = c->c; /* RSTRUCT(nstr)->basic.c->super = c->c; */
ptr_members = RARRAY_PTR(members); ptr_members = RARRAY_PTR(members);
len = RARRAY_LEN(members); len = RARRAY_LEN(members);
for (i=0; i< len; i++) { for (i=0; i< len; i++) {
Expand Down
2 changes: 1 addition & 1 deletion mrbgems/mruby-time/src/time.c
Expand Up @@ -137,7 +137,7 @@ mrb_time_update_datetime(struct mrb_time *self)
} }
if (!aid) return NULL; if (!aid) return NULL;
#ifdef NO_GMTIME_R #ifdef NO_GMTIME_R
self->datetime = *aid; // copy data self->datetime = *aid; /* copy data */
#endif #endif


return self; return self;
Expand Down
1 change: 0 additions & 1 deletion src/class.c
Expand Up @@ -1931,7 +1931,6 @@ mrb_init_class(mrb_state *mrb)
struct RClass *obj; /* Object */ struct RClass *obj; /* Object */
struct RClass *mod; /* Module */ struct RClass *mod; /* Module */
struct RClass *cls; /* Class */ struct RClass *cls; /* Class */
//struct RClass *krn; /* Kernel */


/* boot class hierarchy */ /* boot class hierarchy */
bob = boot_defclass(mrb, 0); bob = boot_defclass(mrb, 0);
Expand Down
20 changes: 10 additions & 10 deletions src/codegen.c
Expand Up @@ -535,15 +535,15 @@ for_body(codegen_scope *s, node *tree)
node *n2; node *n2;
mrb_code c; mrb_code c;


// generate receiver /* generate receiver */
codegen(s, tree->cdr->car, VAL); codegen(s, tree->cdr->car, VAL);
// generate loop-block /* generate loop-block */
s = scope_new(s->mrb, s, tree->car); s = scope_new(s->mrb, s, tree->car);


lp = loop_push(s, LOOP_FOR); lp = loop_push(s, LOOP_FOR);
lp->pc1 = new_label(s); lp->pc1 = new_label(s);


// generate loop variable /* generate loop variable */
n2 = tree->car; n2 = tree->car;
if (n2->car && !n2->car->cdr && !n2->cdr) { if (n2->car && !n2->car->cdr && !n2->cdr) {
genop(s, MKOP_Ax(OP_ENTER, 0x40000)); genop(s, MKOP_Ax(OP_ENTER, 0x40000));
Expand Down Expand Up @@ -718,7 +718,7 @@ gen_values(codegen_scope *s, node *t, int val)
int is_splat; int is_splat;


while (t) { while (t) {
is_splat = (intptr_t)t->car->car == NODE_SPLAT; // splat mode is_splat = (intptr_t)t->car->car == NODE_SPLAT; /* splat mode */
if (n >= 127 || is_splat) { if (n >= 127 || is_splat) {
if (val) { if (val) {
pop_n(n); pop_n(n);
Expand Down Expand Up @@ -756,7 +756,7 @@ gen_values(codegen_scope *s, node *t, int val)
} }
return -1; return -1;
} }
// normal (no splat) mode /* normal (no splat) mode */
codegen(s, t->car, val); codegen(s, t->car, val);
n++; n++;
t = t->cdr; t = t->cdr;
Expand Down Expand Up @@ -1531,7 +1531,7 @@ codegen(codegen_scope *s, node *tree, int val)
int rhs = cursp(); int rhs = cursp();


if ((intptr_t)t->car == NODE_ARRAY && nosplat(t->cdr)) { if ((intptr_t)t->car == NODE_ARRAY && nosplat(t->cdr)) {
// fixed rhs /* fixed rhs */
t = t->cdr; t = t->cdr;
while (t) { while (t) {
codegen(s, t->car, VAL); codegen(s, t->car, VAL);
Expand Down Expand Up @@ -1580,7 +1580,7 @@ codegen(codegen_scope *s, node *tree, int val)
} }
} }
else { else {
// variable rhs /* variable rhs */
codegen(s, t, VAL); codegen(s, t, VAL);
gen_vmassignment(s, tree->car, rhs, val); gen_vmassignment(s, tree->car, rhs, val);
} }
Expand Down Expand Up @@ -1913,7 +1913,7 @@ codegen(codegen_scope *s, node *tree, int val)
break; break;


case NODE_ARG: case NODE_ARG:
// should not happen /* should not happen */
break; break;


case NODE_BLOCK_ARG: case NODE_BLOCK_ARG:
Expand Down Expand Up @@ -2444,7 +2444,7 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *lv)
} }
p->lineno = prev->lineno; p->lineno = prev->lineno;


// debug setting /* debug setting */
p->debug_start_pos = 0; p->debug_start_pos = 0;
if(p->filename) { if(p->filename) {
mrb_debug_info_alloc(mrb, p->irep); mrb_debug_info_alloc(mrb, p->irep);
Expand Down Expand Up @@ -2921,7 +2921,7 @@ mrb_generate_code(mrb_state *mrb, parser_state *p)
scope->filename = p->filename; scope->filename = p->filename;
scope->filename_index = p->current_filename_index; scope->filename_index = p->current_filename_index;
if (setjmp(scope->jmp) == 0) { if (setjmp(scope->jmp) == 0) {
// prepare irep /* prepare irep */
codegen(scope, p->tree, NOVAL); codegen(scope, p->tree, NOVAL);
proc = mrb_proc_new(mrb, scope->irep); proc = mrb_proc_new(mrb, scope->irep);
mrb_irep_decref(mrb, scope->irep); mrb_irep_decref(mrb, scope->irep);
Expand Down
13 changes: 7 additions & 6 deletions src/crc.c
Expand Up @@ -8,12 +8,13 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>


// Calculate CRC (CRC-16-CCITT) /* Calculate CRC (CRC-16-CCITT)
// **
// 0000_0000_0000_0000_0000_0000_0000_0000 ** 0000_0000_0000_0000_0000_0000_0000_0000
// ^|------- CRC -------|- work --| ** ^|------- CRC -------|- work --|
// carry ** carry
#define CRC_16_CCITT 0x11021ul //x^16+x^12+x^5+1 */
#define CRC_16_CCITT 0x11021ul /* x^16+x^12+x^5+1 */
#define CRC_XOR_PATTERN (CRC_16_CCITT << 8) #define CRC_XOR_PATTERN (CRC_16_CCITT << 8)
#define CRC_CARRY_BIT (0x01000000) #define CRC_CARRY_BIT (0x01000000)


Expand Down
14 changes: 7 additions & 7 deletions src/debug.c
Expand Up @@ -10,7 +10,7 @@ get_file(mrb_irep_debug_info *info, uint32_t pc)
int32_t count; int32_t count;


if(pc >= info->pc_count) { return NULL; } if(pc >= info->pc_count) { return NULL; }
// get upper bound /* get upper bound */
ret = info->files; ret = info->files;
count = info->flen; count = info->flen;
while (count > 0) { while (count > 0) {
Expand All @@ -24,9 +24,9 @@ get_file(mrb_irep_debug_info *info, uint32_t pc)


--ret; --ret;


// check returning file exists inside debug info /* check returning file exists inside debug info */
mrb_assert(info->files <= ret && ret < (info->files + info->flen)); mrb_assert(info->files <= ret && ret < (info->files + info->flen));
// check pc is within the range of returning file /* check pc is within the range of returning file */
mrb_assert((*ret)->start_pos <= pc && mrb_assert((*ret)->start_pos <= pc &&
pc < (((ret + 1 - info->files) < info->flen) pc < (((ret + 1 - info->files) < info->flen)
? (*(ret+1))->start_pos : info->pc_count)); ? (*(ret+1))->start_pos : info->pc_count));
Expand Down Expand Up @@ -77,7 +77,7 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc)
return f->line_ary[pc - f->start_pos]; return f->line_ary[pc - f->start_pos];


case mrb_debug_line_flat_map: { case mrb_debug_line_flat_map: {
// get upper bound /* get upper bound */
mrb_irep_debug_info_line *ret = f->line_flat_map; mrb_irep_debug_info_line *ret = f->line_flat_map;
uint32_t count = f->line_entry_count; uint32_t count = f->line_entry_count;
while (count > 0) { while (count > 0) {
Expand All @@ -91,9 +91,9 @@ mrb_debug_get_line(mrb_irep *irep, uint32_t pc)


--ret; --ret;


// check line entry pointer range /* check line entry pointer range */
mrb_assert(f->line_flat_map <= ret && ret < (f->line_flat_map + f->line_entry_count)); mrb_assert(f->line_flat_map <= ret && ret < (f->line_flat_map + f->line_entry_count));
// check pc range /* check pc range */
mrb_assert(ret->start_pos <= pc && mrb_assert(ret->start_pos <= pc &&
pc < (((ret + 1 - f->line_flat_map) < f->line_entry_count) pc < (((ret + 1 - f->line_flat_map) < f->line_entry_count)
? (ret+1)->start_pos : irep->debug_info->pc_count)); ? (ret+1)->start_pos : irep->debug_info->pc_count));
Expand Down Expand Up @@ -185,7 +185,7 @@ mrb_debug_info_append_file(mrb_state *mrb, mrb_irep *irep,
m.line = irep->lines[start_pos + i]; m.line = irep->lines[start_pos + i];
ret->line_flat_map[ret->line_entry_count] = m; ret->line_flat_map[ret->line_entry_count] = m;


// update /* update */
++ret->line_entry_count; ++ret->line_entry_count;
prev_line = irep->lines[start_pos + i]; prev_line = irep->lines[start_pos + i];
} }
Expand Down

0 comments on commit 67de10b

Please sign in to comment.