Browse code

better README.md

Nat! authored on 24-05-2016 11:41:29
Showing 2 changed files
... ...
@@ -1,3 +1,36 @@
1 1
 # mulle-vararg
2 2
 
3
-The variable argument passing scheme used in the MetaABI of mulle_objc.
4 3
\ No newline at end of file
4
+The variable argument passing scheme used in the MetaABI of mulle_objc.
5
+
6
+## How it works
7
+
8
+### Remember the C argument promotion rules
9
+
10
+1. char and short to int/unsigned int 
11
+2. float to double
12
+
13
+### The arguments are layed out struct-like
14
+
15
+A method like `stringWithFormat:(NSString *) format, ...`
16
+which is called like this 
17
+
18
+```
19
+[NSString stringWithFormat:@"%d %f %lld", (char) 'x', (float) 0.2, 1848LL];
20
+```
21
+
22
+could access the arguments as if they were in a struct like this
23
+
24
+```
25
+struct
26
+{
27
+   NSString  *format;
28
+   struct 
29
+   {
30
+      int         value1;
31
+      double      value2;
32
+      long long   value3;
33
+   } varargs;
34
+} _param;
35
+```
36
+
37
+But that's what mulle-vararg does for you.
... ...
@@ -37,6 +37,7 @@
37 37
 /* End PBXContainerItemProxy section */
38 38
 
39 39
 /* Begin PBXFileReference section */
40
+		415867FC1CF4567E003CF8CF /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
40 41
 		41998A251CB668A200D18DD8 /* libmulle_vararg.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libmulle_vararg.a; sourceTree = BUILT_PRODUCTS_DIR; };
41 42
 		41998A2D1CB668C400D18DD8 /* mulle_align.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mulle_align.h; sourceTree = "<group>"; };
42 43
 		41998A2E1CB668C400D18DD8 /* mulle_vararg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mulle_vararg.h; sourceTree = "<group>"; };
... ...
@@ -74,6 +75,7 @@
74 75
 		41998A1C1CB668A200D18DD8 = {
75 76
 			isa = PBXGroup;
76 77
 			children = (
78
+				415867FC1CF4567E003CF8CF /* README.md */,
77 79
 				41D2265C1CD65CB800C06D8C /* RELEASENOTES.md */,
78 80
 				41998A311CB6693400D18DD8 /* mulle-configuration */,
79 81
 				41998A2C1CB668AD00D18DD8 /* src */,