1 // Copyright 2010 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 typedef unsigned char byte;
11 typedef struct __go_interface Iface;
12 typedef struct __go_empty_interface Eface;
14 func setiface(typ *byte, x *byte, ret *byte) {
15 struct __go_interface_type *t;
16 const struct __go_type_descriptor* xt;
18 /* FIXME: We should check __type_descriptor to verify that
19 this is really a type descriptor. */
20 t = (struct __go_interface_type *)typ;
21 if(t->__methods.__count == 0) {
22 // already an empty interface
23 *(Eface*)ret = *(Eface*)x;
26 xt = ((Eface*)x)->__type_descriptor;
28 // can assign nil to any interface
29 ((Iface*)ret)->__methods = nil;
30 ((Iface*)ret)->__object = nil;
33 ((Iface*)ret)->__methods = __go_convert_interface(&t->__common, xt);
34 ((Iface*)ret)->__object = ((Eface*)x)->__object;