Implement Struct on VWA
[ruby.git] / internal / struct.h
blob9b56254541149e951ed47d162a0089eb18111ac0
1 #ifndef INTERNAL_STRUCT_H /*-*-C-*-vi:se ft=c:*/
2 #define INTERNAL_STRUCT_H
3 /**
4 * @author Ruby developers <ruby-core@ruby-lang.org>
5 * @copyright This file is a part of the programming language Ruby.
6 * Permission is hereby granted, to either redistribute and/or
7 * modify this file, provided that the conditions mentioned in the
8 * file COPYING are met. Consult the file for details.
9 * @brief Internal header for Struct.
11 #include "ruby/internal/stdbool.h" /* for bool */
12 #include "ruby/ruby.h" /* for struct RBasic */
14 enum {
15 RSTRUCT_EMBED_LEN_MASK = RUBY_FL_USER7 | RUBY_FL_USER6 | RUBY_FL_USER5 | RUBY_FL_USER4 |
16 RUBY_FL_USER3 | RUBY_FL_USER2 | RUBY_FL_USER1,
17 RSTRUCT_EMBED_LEN_SHIFT = (RUBY_FL_USHIFT+1),
18 RSTRUCT_TRANSIENT_FLAG = RUBY_FL_USER8,
21 struct RStruct {
22 struct RBasic basic;
23 union {
24 struct {
25 long len;
26 const VALUE *ptr;
27 } heap;
28 /* This is a length 1 array because:
29 * 1. GCC has a bug that does not optimize C flexible array members
30 * (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452)
31 * 2. Zero length arrays are not supported by all compilers
33 const VALUE ary[1];
34 } as;
37 #define RSTRUCT(obj) ((struct RStruct *)(obj))