diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/ruby/internal/abi.h | 2 | ||||
| -rw-r--r-- | include/ruby/internal/core/rdata.h | 18 | ||||
| -rw-r--r-- | include/ruby/internal/core/rtypeddata.h | 1 |
3 files changed, 14 insertions, 7 deletions
diff --git a/include/ruby/internal/abi.h b/include/ruby/internal/abi.h index e6d1fa7e8f..0c99d93bf9 100644 --- a/include/ruby/internal/abi.h +++ b/include/ruby/internal/abi.h @@ -24,7 +24,7 @@ * In released versions of Ruby, this number is not defined since teeny * versions of Ruby should guarantee ABI compatibility. */ -#define RUBY_ABI_VERSION 1 +#define RUBY_ABI_VERSION 2 /* Windows does not support weak symbols so ruby_abi_version will not exist * in the shared library. */ diff --git a/include/ruby/internal/core/rdata.h b/include/ruby/internal/core/rdata.h index cee5e7b5ea..5ebeb2473e 100644 --- a/include/ruby/internal/core/rdata.h +++ b/include/ruby/internal/core/rdata.h @@ -116,12 +116,24 @@ typedef void (*RUBY_DATA_FUNC)(void*); * @shyouhei tried to add RBIMPL_ATTR_DEPRECATED for this type but that yielded * too many warnings in the core. Maybe we want to retry later... Just add * deprecated document for now. + * + * RData shares its initial fields with struct ::RTypedData so the VM can handle + * per-object fields without checking whether a T_DATA object is typed or legacy. */ struct RData { /** Basic part, including flags and class. */ struct RBasic basic; + /** @internal Direct reference to the slots that hold instance variables, if any. */ + VALUE fields_obj; + + /** @internal Padding where ::RTypedData stores its type, so both structs place data at the same offset. */ + VALUE _reserved; + + /** Pointer to the actual C level struct that you want to wrap. */ + void *data; + /** * This function is called when the object is experiencing GC marks. If it * contains references to other Ruby objects, you need to mark them also. @@ -141,12 +153,6 @@ struct RData { * impossible at that moment (that is why GC runs). */ RUBY_DATA_FUNC dfree; - - /** Pointer to the actual C level struct that you want to wrap. - * This is after dmark and dfree to allow DATA_PTR to continue to work for - * both RData and non-embedded RTypedData. - */ - void *data; }; RBIMPL_SYMBOL_EXPORT_BEGIN() diff --git a/include/ruby/internal/core/rtypeddata.h b/include/ruby/internal/core/rtypeddata.h index 22bf46eb03..0b189c7ef8 100644 --- a/include/ruby/internal/core/rtypeddata.h +++ b/include/ruby/internal/core/rtypeddata.h @@ -405,6 +405,7 @@ struct RTypedData { }; #if !defined(__cplusplus) || __cplusplus >= 201103L +RBIMPL_STATIC_ASSERT(fields_obj_in_rdata, offsetof(struct RData, fields_obj) == offsetof(struct RTypedData, fields_obj)); RBIMPL_STATIC_ASSERT(data_in_rtypeddata, offsetof(struct RData, data) == offsetof(struct RTypedData, data)); #endif |
