summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-03 12:43:50 +0200
committerTyge Løvset <[email protected]>2023-04-03 18:24:41 +0200
commita3dc31d5393d051ad4dacb314452d3c6ec8a74b7 (patch)
tree35c11eb9542ef448ab6a40642a17f7a4025df823
parente88b655ca8cf28d357f5088c205857954ad269e2 (diff)
downloadSTC-modified-a3dc31d5393d051ad4dacb314452d3c6ec8a74b7.tar.gz
STC-modified-a3dc31d5393d051ad4dacb314452d3c6ec8a74b7.zip
Split priv/template.h in two files to make mksingle.sh work.
-rw-r--r--include/stc/algo/csort.h6
-rw-r--r--include/stc/carc.h2
-rw-r--r--include/stc/cbox.h2
-rw-r--r--include/stc/cdeq.h2
-rw-r--r--include/stc/clist.h2
-rw-r--r--include/stc/cmap.h2
-rw-r--r--include/stc/cpque.h2
-rw-r--r--include/stc/csmap.h6
-rw-r--r--include/stc/cstack.h2
-rw-r--r--include/stc/cvec.h2
-rw-r--r--include/stc/priv/altnames.h3
-rw-r--r--include/stc/priv/template.h64
-rw-r--r--include/stc/priv/untemplate.h78
-rw-r--r--misc/examples/forfilter.c16
14 files changed, 99 insertions, 90 deletions
diff --git a/include/stc/algo/csort.h b/include/stc/algo/csort.h
index c452064f..02ac4e34 100644
--- a/include/stc/algo/csort.h
+++ b/include/stc/algo/csort.h
@@ -20,8 +20,8 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#include <stc/ccommon.h>
-#include <stc/priv/template.h>
+#include "../ccommon.h"
+#include "../priv/template.h"
/* Generic Quicksort in C, performs as fast as c++ std::sort().
template params:
@@ -86,4 +86,4 @@ static inline void c_PASTE(cqsort_, i_tag)(i_val arr[], intptr_t lo, intptr_t hi
static inline void c_PASTE(csort_, i_tag)(i_val arr[], intptr_t n)
{ c_PASTE(cqsort_, i_tag)(arr, 0, n - 1); }
-#include <stc/priv/template.h>
+#include "../priv/untemplate.h"
diff --git a/include/stc/carc.h b/include/stc/carc.h
index 5d38d2e7..16d3a2d4 100644
--- a/include/stc/carc.h
+++ b/include/stc/carc.h
@@ -210,4 +210,4 @@ STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* self)
#undef _i_eq
#undef _i_atomic_inc
#undef _i_atomic_dec_and_test
-#include "priv/template.h"
+#include "priv/untemplate.h"
diff --git a/include/stc/cbox.h b/include/stc/cbox.h
index 6cc86c6f..4d2cb1f1 100644
--- a/include/stc/cbox.h
+++ b/include/stc/cbox.h
@@ -194,4 +194,4 @@ STC_INLINE uint64_t _cx_memb(_hash)(const _cx_self* self)
#endif
#undef _i_eq
-#include "priv/template.h"
+#include "priv/untemplate.h"
diff --git a/include/stc/cdeq.h b/include/stc/cdeq.h
index a032722b..ef1700f5 100644
--- a/include/stc/cdeq.h
+++ b/include/stc/cdeq.h
@@ -442,5 +442,5 @@ _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) {
#endif // !c_no_cmp
#endif // !_i_queue
#endif // IMPLEMENTATION
-#include "priv/template.h"
#define CDEQ_H_INCLUDED
+#include "priv/untemplate.h"
diff --git a/include/stc/clist.h b/include/stc/clist.h
index ca02ae3c..6e6b6d45 100644
--- a/include/stc/clist.h
+++ b/include/stc/clist.h
@@ -404,4 +404,4 @@ STC_DEF bool _cx_memb(_sort_with)(_cx_self* self, int(*cmp)(const _cx_value*, co
#endif // !c_no_cmp
#endif // i_implement
#define CLIST_H_INCLUDED
-#include "priv/template.h"
+#include "priv/untemplate.h"
diff --git a/include/stc/cmap.h b/include/stc/cmap.h
index 437a5982..1976738d 100644
--- a/include/stc/cmap.h
+++ b/include/stc/cmap.h
@@ -481,4 +481,4 @@ _cx_memb(_erase_entry)(_cx_self* self, _cx_value* _val) {
#undef _i_MAP_ONLY
#undef _i_SET_ONLY
#define CMAP_H_INCLUDED
-#include "priv/template.h"
+#include "priv/untemplate.h"
diff --git a/include/stc/cpque.h b/include/stc/cpque.h
index f3ca7081..023c9d27 100644
--- a/include/stc/cpque.h
+++ b/include/stc/cpque.h
@@ -160,4 +160,4 @@ _cx_memb(_push)(_cx_self* self, _cx_value value) {
#endif
#define CPQUE_H_INCLUDED
-#include "priv/template.h"
+#include "priv/untemplate.h"
diff --git a/include/stc/csmap.h b/include/stc/csmap.h
index d0a877c4..716c1bfe 100644
--- a/include/stc/csmap.h
+++ b/include/stc/csmap.h
@@ -48,9 +48,6 @@ int main(void) {
csmap_sx_drop(&m);
}
*/
-#ifdef STC_CSMAP_V1
-#include "alt/csmap.h"
-#else
#include "ccommon.h"
#ifndef CSMAP_H_INCLUDED
@@ -598,5 +595,4 @@ _cx_memb(_drop)(_cx_self* self) {
#undef _i_MAP_ONLY
#undef _i_SET_ONLY
#define CSMAP_H_INCLUDED
-#include "priv/template.h"
-#endif // !STC_CSMAP_V1
+#include "priv/untemplate.h"
diff --git a/include/stc/cstack.h b/include/stc/cstack.h
index 0f855dc9..1fc3f377 100644
--- a/include/stc/cstack.h
+++ b/include/stc/cstack.h
@@ -189,4 +189,4 @@ STC_INLINE void _cx_memb(_next)(_cx_iter* it)
STC_INLINE _cx_iter _cx_memb(_advance)(_cx_iter it, size_t n)
{ if ((it.ref += n) >= it.end) it.ref = NULL ; return it; }
-#include "priv/template.h"
+#include "priv/untemplate.h"
diff --git a/include/stc/cvec.h b/include/stc/cvec.h
index 4fe5ddab..e257f85a 100644
--- a/include/stc/cvec.h
+++ b/include/stc/cvec.h
@@ -438,4 +438,4 @@ STC_DEF int _cx_memb(_value_cmp)(const _cx_value* x, const _cx_value* y) {
#endif // !c_no_cmp
#endif // i_implement
#define CVEC_H_INCLUDED
-#include "priv/template.h"
+#include "priv/untemplate.h"
diff --git a/include/stc/priv/altnames.h b/include/stc/priv/altnames.h
index 8fa326f1..723b6a66 100644
--- a/include/stc/priv/altnames.h
+++ b/include/stc/priv/altnames.h
@@ -32,6 +32,3 @@
#define c_WITH c_with
#define c_SCOPE c_scope
#define c_DEFER c_defer
-#define c_NEW c_new
-#define c_ARRAYLEN c_arraylen
-#define c_ARGSV c_SV // [deprecated]
diff --git a/include/stc/priv/template.h b/include/stc/priv/template.h
index 5ea0cf4f..250a3dda 100644
--- a/include/stc/priv/template.h
+++ b/include/stc/priv/template.h
@@ -20,7 +20,9 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-#ifndef _i_template
+#ifdef _i_template
+ #error template.h already included
+#endif
#define _i_template
#ifndef STC_TEMPLATE_H_INCLUDED
@@ -290,63 +292,3 @@
#ifndef _i_has_from
#define i_no_emplace
#endif
-
-#else // ============================================================
-
-#undef i_type
-#undef i_tag
-#undef i_imp
-#undef i_opt
-#undef i_less
-#undef i_cmp
-#undef i_eq
-#undef i_hash
-#undef i_rawclass
-#undef i_capacity
-#undef i_ssize
-
-#undef i_val
-#undef i_val_str
-#undef i_val_ssv
-#undef i_valboxed
-#undef i_valclass
-#undef i_valraw
-#undef i_valclone
-#undef i_valfrom
-#undef i_valto
-#undef i_valdrop
-
-#undef i_key
-#undef i_key_str
-#undef i_key_ssv
-#undef i_keyboxed
-#undef i_keyclass
-#undef i_keyraw
-#undef i_keyclone
-#undef i_keyfrom
-#undef i_keyto
-#undef i_keydrop
-
-#undef i_header
-#undef i_implement
-#undef i_static
-#undef i_extern
-
-#undef i_allocator
-#undef i_malloc
-#undef i_calloc
-#undef i_realloc
-#undef i_free
-
-#undef i_no_cmp
-#undef i_no_hash
-#undef i_no_clone
-#undef i_no_emplace
-#undef i_is_forward
-
-#undef _i_prefix
-#undef _i_expandby
-#undef _i_has_from
-#undef _i_has_eq
-#undef _i_template
-#endif
diff --git a/include/stc/priv/untemplate.h b/include/stc/priv/untemplate.h
new file mode 100644
index 00000000..27c6a890
--- /dev/null
+++ b/include/stc/priv/untemplate.h
@@ -0,0 +1,78 @@
+/* MIT License
+ *
+ * Copyright (c) 2023 Tyge Løvset
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#undef i_type
+#undef i_tag
+#undef i_imp
+#undef i_opt
+#undef i_less
+#undef i_cmp
+#undef i_eq
+#undef i_hash
+#undef i_rawclass
+#undef i_capacity
+#undef i_ssize
+
+#undef i_val
+#undef i_val_str
+#undef i_val_ssv
+#undef i_valboxed
+#undef i_valclass
+#undef i_valraw
+#undef i_valclone
+#undef i_valfrom
+#undef i_valto
+#undef i_valdrop
+
+#undef i_key
+#undef i_key_str
+#undef i_key_ssv
+#undef i_keyboxed
+#undef i_keyclass
+#undef i_keyraw
+#undef i_keyclone
+#undef i_keyfrom
+#undef i_keyto
+#undef i_keydrop
+
+#undef i_header
+#undef i_implement
+#undef i_static
+#undef i_extern
+
+#undef i_allocator
+#undef i_malloc
+#undef i_calloc
+#undef i_realloc
+#undef i_free
+
+#undef i_no_cmp
+#undef i_no_hash
+#undef i_no_clone
+#undef i_no_emplace
+#undef i_is_forward
+
+#undef _i_prefix
+#undef _i_expandby
+#undef _i_has_from
+#undef _i_has_eq
+#undef _i_template
diff --git a/misc/examples/forfilter.c b/misc/examples/forfilter.c
index 0d72bd1b..daea68b9 100644
--- a/misc/examples/forfilter.c
+++ b/misc/examples/forfilter.c
@@ -9,10 +9,6 @@
#define i_val int
#include <stc/cstack.h>
-#define i_type SVec
-#define i_valclass csview
-#include <stc/cstack.h>
-
// filters and transforms:
#define flt_skipValue(i, x) (*i.ref != (x))
#define flt_isEven(i) ((*i.ref & 1) == 0)
@@ -55,11 +51,9 @@ fn main() {
println!("{:?}", vector); // Print result
}
*/
-
void demo2(void)
{
IVec vector = {0};
-
c_forfilter (x, crange, crange_object(INT64_MAX),
c_flt_skipwhile(x, *x.ref != 11) &&
(*x.ref % 2) != 0 &&
@@ -67,11 +61,9 @@ void demo2(void)
){
IVec_push(&vector, (int)(*x.ref * *x.ref));
}
+ c_foreach (x, IVec, vector) printf(" %d", *x.ref);
- c_foreach (x, IVec, vector)
- printf(" %d", *x.ref);
puts("");
-
IVec_drop(&vector);
}
@@ -88,6 +80,10 @@ fn main() {
println!("{:?}", words_containing_i);
}
*/
+#define i_type SVec
+#define i_valclass csview
+#include <stc/cstack.h>
+
void demo3(void)
{
const char* sentence = "This is a sentence in C99.";
@@ -102,8 +98,8 @@ void demo3(void)
c_foreach (w, SVec, words_containing_i)
printf(" %.*s", c_SV(*w.ref));
- puts("");
+ puts("");
c_drop(SVec, &words, &words_containing_i);
}