summaryrefslogtreecommitdiffhomepage
path: root/docs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-08-11 17:58:15 +0200
committerTyge Løvset <[email protected]>2022-08-11 17:58:15 +0200
commit5cf6b762012168be51b32a1a85ab2bc33504f020 (patch)
tree9fd59787a0d33d23196b77cecbd31ef5d44e103a /docs
parent9831e8d6ee6772a4f9899cf9e3d36e3de47bbaf5 (diff)
downloadSTC-modified-5cf6b762012168be51b32a1a85ab2bc33504f020.tar.gz
STC-modified-5cf6b762012168be51b32a1a85ab2bc33504f020.zip
Fixed issue with cbox / carc. Minor update some examples.
Diffstat (limited to 'docs')
-rw-r--r--docs/carc_api.md12
-rw-r--r--docs/cbox_api.md8
2 files changed, 9 insertions, 11 deletions
diff --git a/docs/carc_api.md b/docs/carc_api.md
index 687e9547..243349a8 100644
--- a/docs/carc_api.md
+++ b/docs/carc_api.md
@@ -32,8 +32,8 @@ 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_from(i_valraw raw); // construct a new value in an carc from raw type.
-carc_X carc_X_make(i_val val); // make a carc from constructed val object. Faster than from_ptr().
+carc_X carc_X_new(i_valraw raw); // construct a new value in an carc from raw type.
+carc_X carc_X_from(i_val val); // create a carc from constructed val object. Faster than from_ptr().
carc_X carc_X_from_ptr(i_val* p); // create a carc from raw pointer. Takes ownership of p.
carc_X carc_X_clone(carc_X other); // return other with increased use count
@@ -96,18 +96,18 @@ int main()
// POPULATE s1 with shared pointers to Map:
Map *map;
- map = Stack_push(&s1, Arc_make(Map_init()))->get; // push empty map to s1.
+ map = Stack_push(&s1, Arc_from(Map_init()))->get; // push empty map to s1.
c_forarray (Map_raw, v, { {"Joey", 1990}, {"Mary", 1995}, {"Joanna", 1992}}) {
Map_emplace(map, v->first, v->second); // populate it.
}
- map = Stack_push(&s1, Arc_make(Map_init()))->get;
+ map = Stack_push(&s1, Arc_from(Map_init()))->get;
c_forarray (Map_raw, v, { {"Rosanna", 2001}, {"Brad", 1999}, {"Jack", 1980} }) {
Map_emplace(map, v->first, v->second);
}
// POPULATE s2:
- map = Stack_push(&s2, Arc_make(Map_init()))->get;
+ map = Stack_push(&s2, Arc_from(Map_init()))->get;
c_forarray (Map_raw, v, { {"Steve", 1979}, {"Rick", 1974}, {"Tracy", 2003} }) {
Map_emplace(map, v->first, v->second);
}
@@ -118,7 +118,7 @@ int main()
// Deep-copy (does not share) a Map from s1 to s2.
// s2 will contain two shared and two unshared maps.
- map = Stack_push(&s2, Arc_make(Map_clone(*s1.data[1].get)))->get;
+ map = Stack_push(&s2, Arc_from(Map_clone(*s1.data[1].get)))->get;
// Add one more element to the cloned map:
Map_emplace_or_assign(map, "Cloned", 2022);
diff --git a/docs/cbox_api.md b/docs/cbox_api.md
index 1119d930..9801ad92 100644
--- a/docs/cbox_api.md
+++ b/docs/cbox_api.md
@@ -68,7 +68,7 @@ void int_drop(int* x) {
#define i_type IBox
#define i_val int
#define i_valdrop int_drop // optional func, just to display elements destroyed
-#define i_valclone(x) x // must specify because i_valdrop was defined.
+#define i_valclone(x) x // must specified when i_valdrop is defined.
#include <stc/cbox.h>
#define i_type ISet
@@ -84,10 +84,8 @@ int main()
c_auto (IVec, vec) // declare and init vec, call drop at scope exit
c_auto (ISet, set) // similar
{
- c_forarray (IBox, v, {
- IBox_make(2021), IBox_make(2012),
- IBox_make(2022), IBox_make(2015),
- }) IVec_push(&vec, *v);
+ c_forarray (int, v, {2021, 2012, 2022, 2015})
+ IVec_emplace(&vec, *v); // same as: IVec_push(&vec, IBox_from(*v));
printf("vec:");
c_foreach (i, IVec, vec)