diff options
author | Wayne Meissner <wmeissner@gmail.com> | 2012-08-04 23:16:38 +1000 |
---|---|---|
committer | Wayne Meissner <wmeissner@gmail.com> | 2012-08-04 23:16:38 +1000 |
commit | 72977b2a21e2b3092bcd362e61d5947a2915cce3 (patch) | |
tree | a5f19a3aa220ddc035edbd154c18cf43329165c4 | |
parent | 50841dbca4a2c84dfe5265aaf740d42b8558aa44 (diff) | |
download | ffi-72977b2a21e2b3092bcd362e61d5947a2915cce3.tar.gz |
Convert C++ style comments to C /* */ style
-rw-r--r-- | ext/ffi_c/AbstractMemory.c | 33 | ||||
-rw-r--r-- | ext/ffi_c/AbstractMemory.h | 2 | ||||
-rw-r--r-- | ext/ffi_c/Buffer.c | 4 | ||||
-rw-r--r-- | ext/ffi_c/Call.c | 9 | ||||
-rw-r--r-- | ext/ffi_c/ClosurePool.c | 2 | ||||
-rw-r--r-- | ext/ffi_c/DynamicLibrary.c | 4 | ||||
-rw-r--r-- | ext/ffi_c/Function.c | 51 | ||||
-rw-r--r-- | ext/ffi_c/Function.h | 2 | ||||
-rw-r--r-- | ext/ffi_c/MethodHandle.c | 2 | ||||
-rw-r--r-- | ext/ffi_c/Pointer.c | 2 | ||||
-rw-r--r-- | ext/ffi_c/Struct.c | 10 | ||||
-rw-r--r-- | ext/ffi_c/StructByValue.c | 2 | ||||
-rw-r--r-- | ext/ffi_c/StructLayout.c | 4 | ||||
-rw-r--r-- | ext/ffi_c/Thread.c | 4 | ||||
-rw-r--r-- | ext/ffi_c/Type.c | 6 | ||||
-rw-r--r-- | ext/ffi_c/Types.c | 6 | ||||
-rw-r--r-- | ext/ffi_c/ffi.c | 2 |
17 files changed, 74 insertions, 71 deletions
diff --git a/ext/ffi_c/AbstractMemory.c b/ext/ffi_c/AbstractMemory.c index 36bbf0c..1b3ed46 100644 --- a/ext/ffi_c/AbstractMemory.c +++ b/ext/ffi_c/AbstractMemory.c @@ -651,25 +651,24 @@ memory_op_put_strptr(AbstractMemory* ptr, long offset, VALUE value) static MemoryOp memory_op_strptr = { memory_op_get_strptr, memory_op_put_strptr }; -//static MemoryOp memory_op_pointer = { memory_op_get_pointer, memory_op_put_pointer }; MemoryOps rbffi_AbstractMemoryOps = { - &memory_op_int8, //.int8 - &memory_op_uint8, //.uint8 - &memory_op_int16, //.int16 - &memory_op_uint16, //.uint16 - &memory_op_int32, //.int32 - &memory_op_uint32, //.uint32 - &memory_op_int64, //.int64 - &memory_op_uint64, //.uint64 - &memory_op_long, //.slong - &memory_op_ulong, //.uslong - &memory_op_float32, //.float32 - &memory_op_float64, //.float64 - &memory_op_longdouble, //.longdouble - &memory_op_pointer, //.pointer - &memory_op_strptr, //.strptr - &memory_op_bool //.boolOp + &memory_op_int8, /*.int8 */ + &memory_op_uint8, /* .uint8 */ + &memory_op_int16, /* .int16 */ + &memory_op_uint16, /* .uint16 */ + &memory_op_int32, /* .int32 */ + &memory_op_uint32, /* .uint32 */ + &memory_op_int64, /* .int64 */ + &memory_op_uint64, /* .uint64 */ + &memory_op_long, /* .slong */ + &memory_op_ulong, /* .uslong */ + &memory_op_float32, /* .float32 */ + &memory_op_float64, /* .float64 */ + &memory_op_longdouble, /* .longdouble */ + &memory_op_pointer, /* .pointer */ + &memory_op_strptr, /* .strptr */ + &memory_op_bool /* .boolOp */ }; void diff --git a/ext/ffi_c/AbstractMemory.h b/ext/ffi_c/AbstractMemory.h index c0e79c3..85b0407 100644 --- a/ext/ffi_c/AbstractMemory.h +++ b/ext/ffi_c/AbstractMemory.h @@ -70,7 +70,7 @@ typedef struct { } MemoryOps; struct AbstractMemory_ { - char* address; // Use char* instead of void* to ensure adding to it works correctly + char* address; /* Use char* instead of void* to ensure adding to it works correctly */ long size; int flags; int typeSize; diff --git a/ext/ffi_c/Buffer.c b/ext/ffi_c/Buffer.c index 49b90cc..8f8b286 100644 --- a/ext/ffi_c/Buffer.c +++ b/ext/ffi_c/Buffer.c @@ -41,7 +41,7 @@ typedef struct Buffer { union { VALUE rbParent; /* link to parent buffer */ char* storage; /* start of malloc area */ - long embed[BUFFER_EMBED_MAXLEN / sizeof(long)]; // storage for tiny allocations + long embed[BUFFER_EMBED_MAXLEN / sizeof(long)]; /* storage for tiny allocations */ } data; } Buffer; @@ -151,7 +151,7 @@ buffer_initialize_copy(VALUE self, VALUE other) dst->memory.size = src->size; dst->memory.typeSize = src->typeSize; - // finally, copy the actual buffer contents + /* finally, copy the actual buffer contents */ memcpy(dst->memory.address, src->address, src->size); return self; diff --git a/ext/ffi_c/Call.c b/ext/ffi_c/Call.c index aa7310a..856d485 100644 --- a/ext/ffi_c/Call.c +++ b/ext/ffi_c/Call.c @@ -314,8 +314,10 @@ rbffi_CallFunction(int argc, VALUE* argv, void* function, FunctionType* fnInfo) if (unlikely(fnInfo->blocking)) { BlockingCall* bc; - // due to the way thread switching works on older ruby variants, we - // cannot allocate anything passed to the blocking function on the stack + /* + * due to the way thread switching works on older ruby variants, we + * cannot allocate anything passed to the blocking function on the stack + */ ffiValues = ALLOC_N(void *, fnInfo->parameterCount); params = ALLOC_N(FFIStorage, fnInfo->parameterCount); bc = ALLOC_N(BlockingCall, 1); @@ -432,14 +434,13 @@ callback_param(VALUE proc, VALUE cbInfo) return NULL ; } - // Handle Function pointers here + /* Handle Function pointers here */ if (rb_obj_is_kind_of(proc, rbffi_FunctionClass)) { AbstractMemory* ptr; Data_Get_Struct(proc, AbstractMemory, ptr); return ptr->address; } - //callback = rbffi_NativeCallback_ForProc(proc, cbInfo); callback = rbffi_Function_ForProc(cbInfo, proc); RB_GC_GUARD(callback); diff --git a/ext/ffi_c/ClosurePool.c b/ext/ffi_c/ClosurePool.c index 0e6e4dd..c910128 100644 --- a/ext/ffi_c/ClosurePool.c +++ b/ext/ffi_c/ClosurePool.c @@ -206,7 +206,7 @@ rbffi_Closure_Free(Closure* closure) if (closure != NULL) { ClosurePool* pool = closure->pool; long refcnt; - // Just push it on the front of the free list + /* Just push it on the front of the free list */ closure->next = pool->list; pool->list = closure; refcnt = --(pool->refcnt); diff --git a/ext/ffi_c/DynamicLibrary.c b/ext/ffi_c/DynamicLibrary.c index a314cab..60f51e1 100644 --- a/ext/ffi_c/DynamicLibrary.c +++ b/ext/ffi_c/DynamicLibrary.c @@ -155,7 +155,7 @@ library_dlerror(VALUE self) static void library_free(Library* library) { - // dlclose() on MacOS tends to segfault - avoid it + /* dlclose() on MacOS tends to segfault - avoid it */ #ifndef __APPLE__ if (library->handle != NULL) { dl_close(library->handle); @@ -270,7 +270,7 @@ rbffi_DynamicLibrary_Init(VALUE moduleFFI) * Document-const: FFI::NativeLibrary * Backward compatibility for FFI::DynamicLibrary */ - rb_define_const(moduleFFI, "NativeLibrary", LibraryClass); // backwards compat library + rb_define_const(moduleFFI, "NativeLibrary", LibraryClass); /* backwards compat library */ rb_define_alloc_func(LibraryClass, library_allocate); rb_define_singleton_method(LibraryClass, "open", library_open, 2); rb_define_singleton_method(LibraryClass, "last_error", library_dlerror, 0); diff --git a/ext/ffi_c/Function.c b/ext/ffi_c/Function.c index 081f2ba..722a7a5 100644 --- a/ext/ffi_c/Function.c +++ b/ext/ffi_c/Function.c @@ -199,11 +199,11 @@ function_initialize(int argc, VALUE* argv, VALUE self) nargs = rb_scan_args(argc, argv, "22", &rbReturnType, &rbParamTypes, &rbProc, &rbOptions); - // - // Callback with block, - // e.g. Function.new(:int, [ :int ]) { |i| blah } - // or Function.new(:int, [ :int ], { :convention => :stdcall }) { |i| blah } - // + /* + * Callback with block, + * e.g. Function.new(:int, [ :int ]) { |i| blah } + * or Function.new(:int, [ :int ], { :convention => :stdcall }) { |i| blah } + */ if (rb_block_given_p()) { if (nargs > 3) { rb_raise(rb_eArgError, "cannot create function with both proc/address and block"); @@ -211,11 +211,12 @@ function_initialize(int argc, VALUE* argv, VALUE self) rbOptions = rbProc; rbProc = rb_block_proc(); } else { - // Callback with proc, or Function with address - // e.g. Function.new(:int, [ :int ], Proc.new { |i| }) - // Function.new(:int, [ :int ], Proc.new { |i| }, { :convention => :stdcall }) - // Function.new(:int, [ :int ], addr) - // Function.new(:int, [ :int ], addr, { :convention => :stdcall }) + /* Callback with proc, or Function with address + * e.g. Function.new(:int, [ :int ], Proc.new { |i| }) + * Function.new(:int, [ :int ], Proc.new { |i| }, { :convention => :stdcall }) + * Function.new(:int, [ :int ], addr) + * Function.new(:int, [ :int ], addr, { :convention => :stdcall }) + */ } infoArgv[0] = rbReturnType; @@ -381,9 +382,9 @@ function_attach(VALUE self, VALUE module, VALUE name) fn->methodHandle = rbffi_MethodHandle_Alloc(fn->info, fn->base.memory.address); } - // - // Stash the Function in a module variable so it does not get garbage collected - // + /* + * Stash the Function in a module variable so it does not get garbage collected + */ snprintf(var, sizeof(var), "@@%s", StringValueCStr(name)); rb_cv_set(module, var, self); @@ -470,7 +471,7 @@ callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data) pthread_mutex_init(&cb.async_mutex, NULL); pthread_cond_init(&cb.async_cond, NULL); - // Now signal the async callback thread + /* Now signal the async callback thread */ pthread_mutex_lock(&async_cb_mutex); empty = async_cb_list == NULL; cb.next = async_cb_list; @@ -478,7 +479,7 @@ callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data) pthread_mutex_unlock(&async_cb_mutex); #if !defined(HAVE_RB_THREAD_BLOCKING_REGION) - // Only signal if the list was empty + /* Only signal if the list was empty */ if (empty) { char c; write(async_cb_pipe[1], &c, 1); @@ -487,7 +488,7 @@ callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data) pthread_cond_signal(&async_cb_cond); #endif - // Wait for the thread executing the ruby callback to signal it is done + /* Wait for the thread executing the ruby callback to signal it is done */ pthread_mutex_lock(&cb.async_mutex); while (!cb.done) { pthread_cond_wait(&cb.async_cond, &cb.async_mutex); @@ -502,7 +503,7 @@ callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data) cb.async_event = CreateEvent(NULL, FALSE, FALSE, NULL); - // Now signal the async callback thread + /* Now signal the async callback thread */ EnterCriticalSection(&async_cb_lock); empty = async_cb_list == NULL; cb.next = async_cb_list; @@ -510,7 +511,7 @@ callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data) LeaveCriticalSection(&async_cb_lock); #if !defined(HAVE_RB_THREAD_BLOCKING_REGION) - // Only signal if the list was empty + /* Only signal if the list was empty */ if (empty) { char c; write(async_cb_pipe[1], &c, 1); @@ -519,7 +520,7 @@ callback_invoke(ffi_cif* cif, void* retval, void** parameters, void* user_data) SetEvent(async_cb_cond); #endif - // Wait for the thread executing the ruby callback to signal it is done + /* Wait for the thread executing the ruby callback to signal it is done */ WaitForSingleObject(cb.async_event, INFINITE); CloseHandle(cb.async_event); #endif @@ -545,7 +546,7 @@ async_cb_event(void* unused) while (!w.stop) { rb_thread_blocking_region(async_cb_wait, &w, async_cb_stop, &w); if (w.cb != NULL) { - // Start up a new ruby thread to run the ruby callback + /* Start up a new ruby thread to run the ruby callback */ rb_thread_create(async_cb_call, w.cb); } } @@ -574,7 +575,7 @@ async_cb_event(void* unused) while (cb != NULL) { struct gvl_callback* next = cb->next; - // Start up a new ruby thread to run the ruby callback + /* Start up a new ruby thread to run the ruby callback */ rb_thread_create(async_cb_call, cb); cb = next; } @@ -606,7 +607,7 @@ async_cb_event(void* unused) while (cb != NULL) { struct gvl_callback* next = cb->next; - // Start up a new ruby thread to run the ruby callback + /* Start up a new ruby thread to run the ruby callback */ rb_thread_create(async_cb_call, cb); cb = next; } @@ -696,7 +697,7 @@ async_cb_call(void *data) callback_with_gvl(cb); - // Signal the original native thread that the ruby code has completed + /* Signal the original native thread that the ruby code has completed */ #ifdef _WIN32 SetEvent(cb->async_event); #else @@ -799,7 +800,7 @@ callback_with_gvl(void* data) break; } - // Convert the native value into a custom ruby value + /* Convert the native value into a custom ruby value */ if (unlikely(cbInfo->parameterTypes[i]->nativeType == NATIVE_MAPPED)) { VALUE values[] = { param, Qnil }; param = rb_funcall2(((MappedType *) cbInfo->parameterTypes[i])->rbConverter, id_from_native, 2, values); @@ -853,7 +854,7 @@ callback_with_gvl(void* data) if (TYPE(rbReturnValue) == T_DATA && rb_obj_is_kind_of(rbReturnValue, rbffi_PointerClass)) { *((void **) retval) = ((AbstractMemory *) DATA_PTR(rbReturnValue))->address; } else { - // Default to returning NULL if not a value pointer object. handles nil case as well + /* Default to returning NULL if not a value pointer object. handles nil case as well */ *((void **) retval) = NULL; } break; diff --git a/ext/ffi_c/Function.h b/ext/ffi_c/Function.h index 0105f1f..fee90ba 100644 --- a/ext/ffi_c/Function.h +++ b/ext/ffi_c/Function.h @@ -41,7 +41,7 @@ typedef struct FunctionType_ FunctionType; #include "ClosurePool.h" struct FunctionType_ { - Type type; // The native type of a FunctionInfo object + Type type; /* The native type of a FunctionInfo object */ VALUE rbReturnType; VALUE rbParameterTypes; diff --git a/ext/ffi_c/MethodHandle.c b/ext/ffi_c/MethodHandle.c index 8059ef1..7f33891 100644 --- a/ext/ffi_c/MethodHandle.c +++ b/ext/ffi_c/MethodHandle.c @@ -311,7 +311,7 @@ prep_trampoline(void* ctx, void* code, Closure* closure, char* errmsg, size_t er caddr_t ptr = (caddr_t) code; memcpy(ptr, &ffi_trampoline, trampoline_size()); - // Patch the context and function addresses into the stub code + /* Patch the context and function addresses into the stub code */ *(intptr_t *)(ptr + trampoline_ctx_offset) = (intptr_t) closure; *(intptr_t *)(ptr + trampoline_func_offset) = (intptr_t) custom_trampoline; diff --git a/ext/ffi_c/Pointer.c b/ext/ffi_c/Pointer.c index 6766dc2..1b0d0ca 100644 --- a/ext/ffi_c/Pointer.c +++ b/ext/ffi_c/Pointer.c @@ -181,7 +181,7 @@ ptr_initialize_copy(VALUE self, VALUE other) dst->memory.size = src->size; dst->memory.typeSize = src->typeSize; - // finally, copy the actual memory contents + /* finally, copy the actual memory contents */ memcpy(dst->memory.address, src->address, src->size); return self; diff --git a/ext/ffi_c/Struct.c b/ext/ffi_c/Struct.c index b5d1e57..c18c566 100644 --- a/ext/ffi_c/Struct.c +++ b/ext/ffi_c/Struct.c @@ -139,11 +139,11 @@ struct_initialize_copy(VALUE self, VALUE other) dst->rbLayout = src->rbLayout; dst->layout = src->layout; - // - // A new MemoryPointer instance is allocated here instead of just calling - // #dup on rbPointer, since the Pointer may not know its length, or may - // be longer than just this struct. - // + /* + * A new MemoryPointer instance is allocated here instead of just calling + * #dup on rbPointer, since the Pointer may not know its length, or may + * be longer than just this struct. + */ if (src->pointer->address != NULL) { dst->rbPointer = rbffi_MemoryPointer_NewInstance(1, src->layout->size, false); dst->pointer = MEMORY(dst->rbPointer); diff --git a/ext/ffi_c/StructByValue.c b/ext/ffi_c/StructByValue.c index f93be8e..5b123ee 100644 --- a/ext/ffi_c/StructByValue.c +++ b/ext/ffi_c/StructByValue.c @@ -87,7 +87,7 @@ sbv_initialize(VALUE self, VALUE rbStructClass) sbv->rbStructClass = rbStructClass; sbv->rbStructLayout = rbLayout; - // We can just use everything from the ffi_type directly + /* We can just use everything from the ffi_type directly */ *sbv->base.ffiType = *layout->base.ffiType; return self; diff --git a/ext/ffi_c/StructLayout.c b/ext/ffi_c/StructLayout.c index 8b1299f..36df230 100644 --- a/ext/ffi_c/StructLayout.c +++ b/ext/ffi_c/StructLayout.c @@ -281,7 +281,7 @@ array_field_put(VALUE self, VALUE pointer, VALUE value) rb_raise(rb_eIndexError, "array too large"); } - // clear the contents in case of a short write + /* clear the contents in case of a short write */ checkWrite(memory); checkBounds(memory, f->offset, f->type->ffiType->size); if (count < array->length) { @@ -289,7 +289,7 @@ array_field_put(VALUE self, VALUE pointer, VALUE value) 0, (array->length - count) * array->componentType->ffiType->size); } - // now copy each element in + /* now copy each element in */ if ((op = get_memory_op(array->componentType)) != NULL) { for (i = 0; i < count; ++i) { diff --git a/ext/ffi_c/Thread.c b/ext/ffi_c/Thread.c index 04212b8..6b99b3f 100644 --- a/ext/ffi_c/Thread.c +++ b/ext/ffi_c/Thread.c @@ -76,7 +76,7 @@ rbffi_thread_has_gvl_p(void) return rbffi_active_thread.valid && pthread_equal(rbffi_active_thread.id, pthread_self()); #endif } -#endif // HAVE_RUBY_THREAD_HAS_GVL_P +#endif /* HAVE_RUBY_THREAD_HAS_GVL_P */ #ifndef HAVE_RB_THREAD_BLOCKING_REGION @@ -322,5 +322,5 @@ rbffi_thread_blocking_region(VALUE (*func)(void *), void *data1, void (*ubf)(voi #endif /* !_WIN32 */ -#endif // HAVE_RB_THREAD_BLOCKING_REGION +#endif /* HAVE_RB_THREAD_BLOCKING_REGION */ diff --git a/ext/ffi_c/Type.c b/ext/ffi_c/Type.c index 5367a88..bec7d9b 100644 --- a/ext/ffi_c/Type.c +++ b/ext/ffi_c/Type.c @@ -193,7 +193,7 @@ rbffi_type_size(VALUE type) } } - // Not found - call up to the ruby version to resolve + /* Not found - call up to the ruby version to resolve */ return NUM2INT(rb_funcall2(rbffi_FFIModule, id_type_size, 1, &type)); } else { @@ -321,14 +321,14 @@ rbffi_Type_Init(VALUE moduleFFI) rb_define_method(rbffi_TypeClass, "alignment", type_alignment, 0); rb_define_method(rbffi_TypeClass, "inspect", type_inspect, 0); - // Make Type::Builtin non-allocatable + /* Make Type::Builtin non-allocatable */ rb_undef_method(CLASS_OF(classBuiltinType), "new"); rb_define_method(classBuiltinType, "inspect", builtin_type_inspect, 0); rb_global_variable(&rbffi_TypeClass); rb_global_variable(&classBuiltinType); - // Define all the builtin types + /* Define all the builtin types */ #define T(x, ffiType) do { \ VALUE t = Qnil; \ rb_define_const(rbffi_TypeClass, #x, t = builtin_type_new(classBuiltinType, NATIVE_##x, ffiType, #x)); \ diff --git a/ext/ffi_c/Types.c b/ext/ffi_c/Types.c index d0a1c29..2dc1c92 100644 --- a/ext/ffi_c/Types.c +++ b/ext/ffi_c/Types.c @@ -98,8 +98,10 @@ rbffi_NativeValue_ToRuby(Type* type, VALUE rbType, const void* ptr) } case NATIVE_MAPPED: { - // For mapped types, first convert to the real native type, then upcall to - // ruby to convert to the expected return type + /* + * For mapped types, first convert to the real native type, then upcall to + * ruby to convert to the expected return type + */ MappedType* m = (MappedType *) type; VALUE values[2], rbReturnValue; diff --git a/ext/ffi_c/ffi.c b/ext/ffi_c/ffi.c index 1b92818..51a5948 100644 --- a/ext/ffi_c/ffi.c +++ b/ext/ffi_c/ffi.c @@ -59,7 +59,7 @@ Init_ffi_c(void) { rb_global_variable(&moduleFFI); - // FFI::Type needs to be initialized before most other classes + /* FFI::Type needs to be initialized before most other classes */ rbffi_Type_Init(moduleFFI); rbffi_DataConverter_Init(moduleFFI); |