[PATCH] Fix a few code typos in the Block ABI spec

Boris DuĊĦek me at dusek.me
Wed Jan 8 13:00:17 PST 2014


http://llvm-reviews.chandlerc.com/D2521

Files:
  docs/Block-ABI-Apple.rst

Index: docs/Block-ABI-Apple.rst
===================================================================
--- docs/Block-ABI-Apple.rst
+++ docs/Block-ABI-Apple.rst
@@ -144,7 +144,7 @@
     static struct __block_descriptor_1 {
         unsigned long int reserved;
         unsigned long int Block_size;
-    } __block_descriptor_1 = { 0, sizeof(struct __block_literal_1), __block_invoke_1 };
+    } __block_descriptor_1 = { 0, sizeof(struct __block_literal_1) };
 
 and where the ``Block`` literal itself appears:
 
@@ -270,8 +270,8 @@
         struct __block_literal_3 *const existingBlock;
     };
     
-    void __block_invoke_4(struct __block_literal_2 *_block) {
-       __block->existingBlock->invoke(__block->existingBlock);
+    void __block_invoke_4(struct __block_literal_4 *_block) {
+       _block->existingBlock->invoke(_block->existingBlock);
     }
     
     void __block_copy_4(struct __block_literal_4 *dst, struct __block_literal_4 *src) {
@@ -487,7 +487,7 @@
 
     struct _block_byref_i {
         void *isa;  // set to NULL
-        struct _block_byref_voidBlock *forwarding;
+        struct _block_byref_i *forwarding;
         int flags;   //refcount;
         int size;
         void (*byref_keep)(struct _block_byref_i *dst, struct _block_byref_i *src);
@@ -506,37 +506,37 @@
     };
     
     void __block_invoke_5(struct __block_literal_5 *_block) {
-       _block->forwarding->captured_i = 10;
+       _block->i_holder->forwarding->captured_i = 10;
     }
     
     void __block_copy_5(struct __block_literal_5 *dst, struct __block_literal_5 *src) {
          //_Block_byref_assign_copy(&dst->captured_i, src->captured_i);
-         _Block_object_assign(&dst->captured_i, src->captured_i, BLOCK_FIELD_IS_BYREF | BLOCK_BYREF_CALLER);
+         _Block_object_assign(&dst->i_holder, src->i_holder, BLOCK_FIELD_IS_BYREF | BLOCK_BYREF_CALLER);
     }
     
     void __block_dispose_5(struct __block_literal_5 *src) {
          //_Block_byref_release(src->captured_i);
-         _Block_object_dispose(src->captured_i, BLOCK_FIELD_IS_BYREF | BLOCK_BYREF_CALLER);
+         _Block_object_dispose(src->i_holder, BLOCK_FIELD_IS_BYREF | BLOCK_BYREF_CALLER);
     }
     
     static struct __block_descriptor_5 {
         unsigned long int reserved;
         unsigned long int Block_size;
         void (*copy_helper)(struct __block_literal_5 *dst, struct __block_literal_5 *src);
         void (*dispose_helper)(struct __block_literal_5 *);
-    } __block_descriptor_5 = { 0, sizeof(struct __block_literal_5) __block_copy_5, __block_dispose_5 };
+    } __block_descriptor_5 = { 0, sizeof(struct __block_literal_5), __block_copy_5, __block_dispose_5 };
 
 and:
 
 .. code-block:: c
 
-    struct _block_byref_i i = {( .forwarding=&i, .flags=0, .size=sizeof(struct _block_byref_i) )};
+    struct _block_byref_i i = {( .forwarding=&i, .flags=0, .size=sizeof(struct _block_byref_i), .captured_i=2 )};
     struct __block_literal_5 _block_literal = {
           &_NSConcreteStackBlock,
           (1<<25)|(1<<29), <uninitialized>,
           __block_invoke_5,
           &__block_descriptor_5,
-          2,
+          &i,
     };
 
 Importing ``__attribute__((NSObject))`` ``__block`` variables
@@ -756,7 +756,7 @@
        printf("%d\n", _block->foo.value());
     }
     
-    void __block_literal_10(struct __block_literal_10 *dst, struct __block_literal_10 *src) {
+    void __block_copy_10(struct __block_literal_10 *dst, struct __block_literal_10 *src) {
          FOO_ctor(&dst->foo, &src->foo);
     }
     
@@ -785,7 +785,7 @@
         &__block_descriptor_10,
        };
        comp_ctor(&_block_literal->foo, &foo);  // const copy into stack version
-       struct __block_literal_10 &block = &_block_literal;  // assign literal to block variable
+       struct __block_literal_10 *block = &_block_literal;  // assign literal to block variable
        block->invoke(block);    // invoke block
        comp_dtor(&_block_literal->foo); // destroy stack version of const block copy
        comp_dtor(&foo); // destroy original version
@@ -862,7 +862,7 @@
 
 .. code-block:: c
 
-    _Block_object_dispose(->target, BLOCK_FIELD_<appropo>);
+    _Block_object_dispose(src->target, BLOCK_FIELD_<appropo>);
 
 in the dispose helper where ``<appropo>`` is:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2521.1.patch
Type: text/x-patch
Size: 4274 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140108/938e4de3/attachment.bin>


More information about the cfe-commits mailing list