ruby_deep_clone 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/ext/deep_clone/deep_clone.h +84 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZTNhNTQzYjVkMDY3Nzc0OWUzMDQzY2YzMzdlNGE1NDNkNmYyNjgzMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzkwYmZiMWI0ODdmYmNkMWJhMDEzNTdjODdhNjc1MzMxNGZkZWRkMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjE5MjVkMWQ1NDVhYjA5MzA0NzgzZmMwODgxZGM2OTFmZjFhYzdmYjlhNDQ0
|
10
|
+
NTI0OGE5NmU2ZTU3ZjlkMTM5YjM2Y2Y2NDcwYWJlY2ZkY2ZjYzJmMjFmNjgy
|
11
|
+
OWYyYjlmNjU0MzY1NmFmZTBjYmVlYzYwYzk0ZTcwZTAxNmQxOTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTk5ZTkyNjkyOGJiMWYwOGNmMTBiN2M0Njg1NDIxYmJiODZiMGNjODY1Yjcy
|
14
|
+
MGY2OWZhNGYwYWE0ZTZlMjJiODFiZTBmOTgyMmM2ZGIyNDQ1MmMzNjRiZGRh
|
15
|
+
MjA4ZmFiMDFjN2RiZGFkNDE4ZTE2MjMwM2E5YzFkMjJmYTEwYjY=
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#ifndef DEEP_CLONE_H
|
2
|
+
# define DEEP_CLONE_H
|
3
|
+
|
4
|
+
# include <ruby.h>
|
5
|
+
# include <ruby/st.h>
|
6
|
+
# include <ruby/version.h>
|
7
|
+
|
8
|
+
struct dump_call_arg
|
9
|
+
{
|
10
|
+
VALUE obj;
|
11
|
+
VALUE tracker;
|
12
|
+
VALUE src;
|
13
|
+
};
|
14
|
+
|
15
|
+
# define DC_DEBUG 0
|
16
|
+
|
17
|
+
# define OBJ_UNFREEZE(x) FL_UNSET((x), FL_FREEZE)
|
18
|
+
|
19
|
+
# ifdef SA_EMPTY
|
20
|
+
// Gotta do this because of 1.9.3's falcon patch
|
21
|
+
struct rb_classext_struct
|
22
|
+
{
|
23
|
+
sa_table m_tbl;
|
24
|
+
sa_table iv_tbl;
|
25
|
+
sa_table const_tbl;
|
26
|
+
sa_table iv_index_tbl;
|
27
|
+
};
|
28
|
+
|
29
|
+
# define TABLE_FOREACH sa_foreach
|
30
|
+
|
31
|
+
# define DC_RCLASS_EXT(c) (RCLASS(c)->ptr)
|
32
|
+
# define DC_RCLASS_IV_INDEX_TBL(c) (&DC_RCLASS_EXT(c)->iv_index_tbl)
|
33
|
+
# else
|
34
|
+
// Make it work with vanilla ruby (including 2.0)
|
35
|
+
# define TABLE_FOREACH st_foreach
|
36
|
+
|
37
|
+
# if RUBY_API_VERSION_CODE >= 20100
|
38
|
+
# if RUBY_API_VERSION_CODE >= 20300
|
39
|
+
// In Ruby 2.3, struct RClass was moved into internal.h and cannot be accessed
|
40
|
+
// directly.
|
41
|
+
|
42
|
+
// From ruby/ruby.h v2.2.4.
|
43
|
+
typedef struct rb_classext_struct rb_classext_t;
|
44
|
+
|
45
|
+
// RClass is defined as RClassDeprecated, which in turn only contains the 'basic' field.
|
46
|
+
# undef RClass
|
47
|
+
|
48
|
+
// RClass as defined in Ruby 2.2.4.
|
49
|
+
struct RClass
|
50
|
+
{
|
51
|
+
struct RBasic basic;
|
52
|
+
VALUE super;
|
53
|
+
rb_classext_t *ptr;
|
54
|
+
struct method_table_wrapper *m_tbl_wrapper;
|
55
|
+
};
|
56
|
+
# endif
|
57
|
+
|
58
|
+
// In Ruby 2.1, iv_index_tbl was moved into internal.h and cannot be accessed
|
59
|
+
// directly. We work around this by defining our own RCLASS helpers (since the
|
60
|
+
// rb_classext_struct returned by RCLASS_EXT is also effectively private).
|
61
|
+
typedef struct dc_iv_tbl_classext_struct
|
62
|
+
{
|
63
|
+
struct st_table *iv_index_tbl;
|
64
|
+
} dc_iv_tbl_classext_t;
|
65
|
+
|
66
|
+
# define DC_RCLASS_EXT(c) ((dc_iv_tbl_classext_t*) RCLASS(c)->ptr)
|
67
|
+
# define DC_RCLASS_IV_INDEX_TBL(c) (DC_RCLASS_EXT(c)->iv_index_tbl)
|
68
|
+
# else
|
69
|
+
# define DC_RCLASS_IV_INDEX_TBL(c) (RCLASS(c)->iv_index_tbl)
|
70
|
+
# endif
|
71
|
+
# endif
|
72
|
+
|
73
|
+
# define DC_ROBJECT_IV_INDEX_TBL(o) ((RBASIC(o)->flags & ROBJECT_EMBED) ?\
|
74
|
+
DC_RCLASS_IV_INDEX_TBL(rb_obj_class(o)) :\
|
75
|
+
ROBJECT(o)->as.heap.iv_index_tbl)
|
76
|
+
|
77
|
+
VALUE DeepClone = Qnil;
|
78
|
+
|
79
|
+
void Init_deep_clone();
|
80
|
+
static int clone_variable(st_data_t key, st_data_t index, struct dump_call_arg *arg);
|
81
|
+
static int hash_each(VALUE key, VALUE value, struct dump_call_arg *arg);
|
82
|
+
static VALUE clone_object(VALUE object, VALUE tracker);
|
83
|
+
VALUE deep_clone(int argc,VALUE argv);
|
84
|
+
#endif
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_deep_clone
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthias Balmer
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -65,6 +65,7 @@ extensions:
|
|
65
65
|
extra_rdoc_files: []
|
66
66
|
files:
|
67
67
|
- ext/deep_clone/deep_clone.c
|
68
|
+
- ext/deep_clone/deep_clone.h
|
68
69
|
- ext/deep_clone/extconf.rb
|
69
70
|
- lib/deep_clone.rb
|
70
71
|
homepage: https://github.com/balmma/ruby-deepclone
|