• R/O
  • SSH

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisiona31b7889d4daa4ddc1f1d2568a7f50ac64fbd34d (tree)
Time2023-01-29 21:02:39
AuthorAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

ToDo: No Name Collisions

Change Summary

Incremental Difference

diff -r 93e8af769bc0 -r a31b7889d4da CCastle/3.Design/B.Workshop/CC2Cpy/zz.todo.rst
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CCastle/3.Design/B.Workshop/CC2Cpy/zz.todo.rst Sun Jan 29 13:02:39 2023 +0100
@@ -0,0 +1,50 @@
1+TODO (CC2Cpy)
2+*************
3+
4+No Name Collisions
5+==================
6+
7+.. todo::
8+
9+ When we generate C code, all names are globals -- *there are no names in C*!
10+ |BR|
11+ So, when a file (or package etc) defines a component (or protocol, ect), that happens to have the same name as one in
12+ another file; the clash. This is known as a Name Collision.
13+
14+ This has to be prevented
15+
16+.. tip::
17+
18+ There are several ways how to circumvent that, like:
19+
20+ #. Use ‘static’ when possible -- this make the issue smaller, but does not solve it (IMHO)
21+ #. Use a C++ compiler, that has namespaces -- it’s a workaround -- I don’t prefer that
22+ #. Prefix all generated names with a **NS-prefix** (*NS::NameSpace*)
23+
24+ For example ``component Sieve`` should result not in:
25+
26+ * **struct CC_B_ComponentInterface** ``cc_CI_Sieve``,
27+ * **struct CC_B_ComponentClass** ``cc_C_Sieve``, and
28+ * *typedef struct { ... }* ``CC_C_Sieve``.
29+
30+ But in:
31+
32+ * **struct CC_B_ComponentInterface** ``{NS_hashId}_cc_CI_Sieve``,
33+ * **struct CC_B_ComponentClass** ``{NS_hashId}_cc_C_Sieve``, and
34+ * *typedef struct { ... }* ``{NS_hashId}_CC_C_Sieve``.
35+
36+ Where **{NS_hashId}**, the result of `NS_hashId(dottedNamePath:str)->shortSting` is stable
37+ - python’ hash() will not work
38+ - See `HashIds<https://hashids.org/python/`__ for an examle -- but not accepting string-input
39+ - MD5 is provably fine -- no need to be (crypto) safe
40+
41+ Or, possible the order should be
42+
43+ * **struct CC_B_ComponentInterface** ``cc_CI_{NS_hashId}_Sieve``,
44+ * **struct CC_B_ComponentClass** ``cc_C_{NS_hashId}_Sieve``, and
45+ * *typedef struct { ... }* ``CC_C_{NS_hashId}_Sieve``.
46+
47+
48+
49+
50+