Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xavie_
Cef
提交
027eef0e
C
Cef
项目概览
Xavie_
/
Cef
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cef
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
027eef0e
编写于
11月 30, 2018
作者:
R
Richard Wilkes
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Cleanup
上级
a36031ce
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
19 addition
and
25 deletion
+19
-25
gen/structdef.go
gen/structdef.go
+15
-21
gen/variable.go
gen/variable.go
+4
-4
未找到文件。
gen/structdef.go
浏览文件 @
027eef0e
package
main
import
(
"regexp"
"sort"
"strings"
"text/template"
...
...
@@ -9,6 +10,11 @@ import (
"github.com/richardwilkes/toolbox/txt"
)
var
(
defRegex
=
regexp
.
MustCompile
(
` struct\s+_(cef_\S+)\s+definition$`
)
fieldRegex
=
regexp
.
MustCompile
(
`-FieldDecl .*>\s+\S+\s+(\S+)\s+'([^']+)'`
)
)
type
structDef
struct
{
Name
string
GoName
string
...
...
@@ -75,29 +81,17 @@ func translateStructTypeName(name string) string {
}
func
processRecordDecl
(
block
[]
lineInfo
)
{
line
:=
block
[
0
]
.
Line
if
strings
.
HasSuffix
(
line
,
" definition"
)
{
if
i
:=
strings
.
Index
(
line
,
" struct _cef_"
);
i
!=
-
1
{
name
:=
line
[
i
+
9
:
len
(
line
)
-
11
]
if
_
,
exclude
:=
excludeMap
[
name
];
!
exclude
{
if
_
,
exists
:=
sdefsMap
[
name
];
!
exists
{
sdef
:=
newStructDef
(
name
,
block
[
0
]
.
Position
)
for
i
:=
1
;
i
<
len
(
block
);
i
++
{
line
=
block
[
i
]
.
Line
if
len
(
line
)
>
3
&&
strings
.
HasPrefix
(
line
[
3
:
],
"-FieldDecl "
)
{
if
start
:=
strings
.
Index
(
line
,
"> "
);
start
!=
-
1
{
line
=
line
[
start
+
2
:
]
if
space
:=
strings
.
Index
(
line
,
" "
);
space
!=
-
1
{
line
=
line
[
space
+
1
:
]
if
start
=
strings
.
Index
(
line
,
" "
);
space
!=
-
1
{
sdef
.
Fields
=
append
(
sdef
.
Fields
,
newField
(
sdef
,
line
[
:
start
],
strings
.
Trim
(
line
[
start
+
1
:
],
"'"
),
block
[
i
]
.
Position
))
}
}
}
}
if
result
:=
defRegex
.
FindAllStringSubmatch
(
block
[
0
]
.
Line
,
-
1
);
result
!=
nil
{
name
:=
result
[
0
][
1
]
if
_
,
exclude
:=
excludeMap
[
name
];
!
exclude
{
if
_
,
exists
:=
sdefsMap
[
name
];
!
exists
{
sdef
:=
newStructDef
(
name
,
block
[
0
]
.
Position
)
for
i
:=
1
;
i
<
len
(
block
);
i
++
{
if
result
=
fieldRegex
.
FindAllStringSubmatch
(
block
[
i
]
.
Line
,
-
1
);
result
!=
nil
{
sdef
.
Fields
=
append
(
sdef
.
Fields
,
newField
(
sdef
,
result
[
0
][
1
],
result
[
0
][
2
],
block
[
i
]
.
Position
))
}
sdefsMap
[
name
]
=
sdef
}
sdefsMap
[
name
]
=
sdef
}
}
}
...
...
gen/variable.go
浏览文件 @
027eef0e
...
...
@@ -29,10 +29,10 @@ type variable struct {
func
newCVar
(
name
,
typeInfo
string
,
pos
position
)
*
variable
{
name
=
strings
.
TrimSpace
(
name
)
typeInfo
=
strings
.
Replace
(
strings
.
TrimPrefix
(
strings
.
Trim
(
strings
.
TrimSpace
(
strings
.
Replace
(
typeInfo
,
"const "
,
""
,
-
1
)),
"'"
),
"struct _"
),
"long long"
,
"int64_t
"
,
-
1
)
if
i
:=
strings
.
Index
(
typeInfo
,
"':'"
);
i
!=
-
1
{
typeInfo
=
typeInfo
[
:
i
]
}
typeInfo
=
strings
.
Replace
(
typeInfo
,
"const "
,
"
"
,
-
1
)
typeInfo
=
strings
.
TrimSpace
(
typeInfo
)
typeInfo
=
strings
.
TrimPrefix
(
typeInfo
,
"struct _"
)
typeInfo
=
strings
.
Replace
(
typeInfo
,
"long long"
,
"int64_t"
,
-
1
)
v
:=
&
variable
{
Name
:
name
,
GoName
:
txt
.
ToCamelCase
(
name
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录