diff options
| author | Tyge Løvset <[email protected]> | 2022-04-20 11:51:00 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-04-20 11:51:00 +0200 |
| commit | b06500c3920ae7ec56489d4dfe05f6a33af85a31 (patch) | |
| tree | a725f67d20de40e73fb1dcb9165835579a42c739 | |
| parent | 7c88fc11ef62d5be83fe34fe72da6eadfd64ba6b (diff) | |
| download | STC-modified-b06500c3920ae7ec56489d4dfe05f6a33af85a31.tar.gz STC-modified-b06500c3920ae7ec56489d4dfe05f6a33af85a31.zip | |
Final carc / cbox cleanup.
| -rw-r--r-- | docs/carc_api.md | 2 | ||||
| -rw-r--r-- | docs/cbox_api.md | 2 | ||||
| -rw-r--r-- | include/stc/carc.h | 6 | ||||
| -rw-r--r-- | include/stc/cbox.h | 8 |
4 files changed, 10 insertions, 8 deletions
diff --git a/docs/carc_api.md b/docs/carc_api.md index cc5b3f41..90aec0ed 100644 --- a/docs/carc_api.md +++ b/docs/carc_api.md @@ -32,7 +32,7 @@ See similar c++ class [std::shared_ptr](https://en.cppreference.com/w/cpp/memory ## Methods ```c carc_X carc_X_init(); // empty shared pointer -carc_X carc_X_make(i_valraw raw); // construct owned value from raw type +carc_X carc_X_make(i_valraw raw); // create owned value from raw type, if defined. carc_X carc_X_from(i_val val); // create new heap allocated object. Take ownership of val. carc_X carc_X_from_ptr(i_val* p); // create a carc from raw pointer. Takes ownership of p. diff --git a/docs/cbox_api.md b/docs/cbox_api.md index 556c56df..a4e88801 100644 --- a/docs/cbox_api.md +++ b/docs/cbox_api.md @@ -31,7 +31,7 @@ compare the pointer addresses when used. Additionally, `c_no_clone` or `i_is_fwd ## Methods ```c cbox_X cbox_X_init(); // return an empty cbox -cbox_X cbox_X_make(i_valraw raw); // create owned value from raw type. +cbox_X cbox_X_make(i_valraw raw); // create owned value from raw type, if defined. cbox_X cbox_X_from(i_val val); // allocate new heap object with val. Take ownership of val. cbox_X cbox_X_from_ptr(i_val* p); // create a cbox from a pointer. Takes ownership of p. diff --git a/include/stc/carc.h b/include/stc/carc.h index a061a606..7f9c4390 100644 --- a/include/stc/carc.h +++ b/include/stc/carc.h @@ -143,8 +143,10 @@ _cx_memb(_reset_from)(_cx_self* self, i_val val) { *self = _cx_memb(_from)(val);
}
-STC_INLINE _cx_self
-_cx_memb(_make)(_cx_raw raw) { return _cx_memb(_from)(i_valfrom(raw)); }
+#if !defined _i_no_clone
+ STC_INLINE _cx_self
+ _cx_memb(_make)(_cx_raw raw) { return _cx_memb(_from)(i_valfrom(raw)); }
+#endif // !_i_no_clone
// does not use i_valfrom, so we can bypass c_no_clone
STC_INLINE _cx_self
diff --git a/include/stc/cbox.h b/include/stc/cbox.h index 690c8a7f..c2ecbae4 100644 --- a/include/stc/cbox.h +++ b/include/stc/cbox.h @@ -117,11 +117,11 @@ _cx_memb(_reset_from)(_cx_self* self, i_val val) { else self->get = c_new(i_val, val);
}
-STC_INLINE _cx_self
-_cx_memb(_make)(_cx_raw raw) { return _cx_memb(_from)(i_valfrom(raw)); }
-
#if !defined _i_no_clone
STC_INLINE _cx_self
+ _cx_memb(_make)(_cx_raw raw) { return _cx_memb(_from)(i_valfrom(raw)); }
+
+ STC_INLINE _cx_self
_cx_memb(_clone)(_cx_self other) {
if (!other.get) return other;
i_valraw r = i_valto(other.get);
@@ -134,7 +134,7 @@ _cx_memb(_make)(_cx_raw raw) { return _cx_memb(_from)(i_valfrom(raw)); } _cx_memb(_drop)(self);
*self = _cx_memb(_clone)(other);
}
-#endif
+#endif // !_i_no_clone
STC_INLINE void
_cx_memb(_take)(_cx_self* self, _cx_self other) {
|
