]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/cc: translate C Eface type as Go interface{}
authorRuss Cox <rsc@golang.org>
Thu, 28 Aug 2014 03:41:27 +0000 (23:41 -0400)
committerRuss Cox <rsc@golang.org>
Thu, 28 Aug 2014 03:41:27 +0000 (23:41 -0400)
This will allow structs containing Efaces in C to be
manipulated as structs containing real interfaces in Go.
The eface struct is still defined for use by Go code.

LGTM=iant
R=golang-codereviews, iant
CC=dvyukov, golang-codereviews, khr, r
https://golang.org/cl/133980044

src/cmd/cc/godefs.c

index edb8a5e28760c21f50c66b629930ce951aa8238a..20915ca8caec669cbea31e25fa23be46ee737140 100644 (file)
@@ -218,11 +218,13 @@ printtypename(Type *t)
                        n = s->name;
                else if(t->tag)
                        n = t->tag->name;
-               if(strcmp(n, "String") == 0){
+               if(strcmp(n, "String") == 0)
                        Bprint(&outbuf, "string");
-               } else if(strcmp(n, "Slice") == 0){
+               else if(strcmp(n, "Slice") == 0)
                        Bprint(&outbuf, "[]byte");
-               } else
+               else if(strcmp(n, "Eface") == 0)
+                       Bprint(&outbuf, "interface{}");
+               else
                        Bprint(&outbuf, "%U", n);
                break;
        case TFUNC: