Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(138)

Issue 472041: cgo can now handle "manual" structs. These are structs

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 9 months ago by JamesAguilar
Modified:
6 years, 7 months ago
Reviewers:
dairon.medina
Visibility:
Public.

Description

cgo can now handle "manual" structs. These are structs that are declared explicitly rather than through typedefs. They are useful when the C code being adapted does not typedef the structs to a C name and instead refers to them directly. You can refer to structs like this using types like C.struct_structname. This change also includes a change for go-mode.el which will correct an indentation problem when indenting identifiers that contain keywords followed by underscores. Both of these fixes are total hacks and are probably not ultimately sufficient. One potential problem with the coerced struct names is that it still does not work if the C code takes a hybrid approach. For example typedef struct foo { int a; } foo; void do_a(struct foo *f); void do_b(foo *f); Both do_a and do_b are valid C code, but it doesn't seem like there's a way to make them both accessible from C.foo or C.struct_foo at this point. cgo still needs to be enhanced to handle this case. I would appreciate advice on how to test this change in a way that would prevent it from breaking in the future. Although maybe that's not so much of a concern considering the lack of testing around cgo.

Patch Set 1 #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+45 lines, -5 lines) Patch
M misc/emacs/go-mode.el View 1 chunk +1 line, -1 line 2 comments Download
M src/cmd/cgo/gcc.go View 3 chunks +44 lines, -4 lines 1 comment Download

Messages

Total messages: 2
JamesAguilar
http://codereview.appspot.com/472041/diff/1/2 File misc/emacs/go-mode.el (right): http://codereview.appspot.com/472041/diff/1/2#newcode346 misc/emacs/go-mode.el:346: (when (/= (skip-chars-backward "[:word:]~") 0) I'm very unsure that ...
15 years, 9 months ago (2010-03-12 10:31:50 UTC) #1
dairon.medina
6 years, 7 months ago (2019-05-15 20:23:44 UTC) #2
https://codereview.appspot.com/472041/diff/1/misc/emacs/go-mode.el
File misc/emacs/go-mode.el (right):

https://codereview.appspot.com/472041/diff/1/misc/emacs/go-mode.el#newcode346
misc/emacs/go-mode.el:346: (when (/= (skip-chars-backward "[:word:]~") 0)
On 2010/03/12 10:31:50, JamesAguilar wrote:
> I'm very unsure that this really works. I only know that I tried a couple
> different things and this seemed to give me correct indenting behavior. I saw
a
> compile error the one time I tried to use tilde in go, so I thought it might
be
> less likely than underscore to conflict with real names.

emacs test

https://codereview.appspot.com/472041/diff/1/src/cmd/cgo/gcc.go
File src/cmd/cgo/gcc.go (right):

https://codereview.appspot.com/472041/diff/1/src/cmd/cgo/gcc.go#newcode824
src/cmd/cgo/gcc.go:824: //         struct bar { int foo; };
hej
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b