summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-05-19 11:22:03 +0200
committerTyge Løvset <[email protected]>2022-05-19 11:22:03 +0200
commitbb8484be936d82f0f01b99ca67a6de1508037e8f (patch)
tree07167891bf7c153380894e33377dd48816dfba99 /include
parent775d0b3fce76be7512671c711d4aa16a5fa34a40 (diff)
downloadSTC-modified-bb8484be936d82f0f01b99ca67a6de1508037e8f.tar.gz
STC-modified-bb8484be936d82f0f01b99ca67a6de1508037e8f.zip
Added _toval() in carc and cbox. Added dynamic polymorphism example, shape.c.
Diffstat (limited to 'include')
-rw-r--r--include/stc/carc.h3
-rw-r--r--include/stc/cbox.h3
-rw-r--r--include/stc/template.h2
3 files changed, 8 insertions, 0 deletions
diff --git a/include/stc/carc.h b/include/stc/carc.h
index 6c591d2c..e4a69e80 100644
--- a/include/stc/carc.h
+++ b/include/stc/carc.h
@@ -115,6 +115,9 @@ STC_INLINE _cx_self _cx_memb(_make)(_cx_value val) {
STC_INLINE _cx_raw _cx_memb(_toraw)(const _cx_self* self)
{ return i_keyto(self->get); }
+STC_INLINE _cx_value _cx_memb(_toval)(const _cx_self* self)
+ { return *self->get; }
+
STC_INLINE _cx_self _cx_memb(_move)(_cx_self* self) {
_cx_self ptr = *self;
self->get = NULL, self->use_count = NULL;
diff --git a/include/stc/cbox.h b/include/stc/cbox.h
index cb5cada3..73b437d4 100644
--- a/include/stc/cbox.h
+++ b/include/stc/cbox.h
@@ -97,6 +97,9 @@ STC_INLINE _cx_self _cx_memb(_make)(_cx_value val) {
STC_INLINE _cx_raw _cx_memb(_toraw)(const _cx_self* self)
{ return i_keyto(self->get); }
+STC_INLINE _cx_value _cx_memb(_toval)(const _cx_self* self)
+ { return *self->get; }
+
// destructor
STC_INLINE void _cx_memb(_drop)(_cx_self* self) {
if (self->get) {
diff --git a/include/stc/template.h b/include/stc/template.h
index f55a3354..6af10ace 100644
--- a/include/stc/template.h
+++ b/include/stc/template.h
@@ -114,6 +114,7 @@
#elif defined i_key_arcbox
#define i_key_bind i_key_arcbox
#define i_keyraw c_paste(i_key_arcbox, _value)
+ #define i_keyto c_paste(i_key, _toval)
#define i_eq c_paste(i_key_arcbox, _value_eq)
#endif
@@ -196,6 +197,7 @@
#elif defined i_val_arcbox
#define i_val_bind i_val_arcbox
#define i_valraw c_paste(i_val_arcbox, _value)
+ #define i_valto c_paste(i_val, _toval)
#endif
#ifdef i_val_bind