Skip to content

Commit

Permalink
bind sdk fix decode bit start index
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkwork committed Jun 20, 2024
1 parent e3a2bd2 commit ef87334
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 53 deletions.
99 changes: 48 additions & 51 deletions gengo/bind/sdkMerge/bug/tmp/bug.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions gengo/clang/layout_parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,23 @@ type RecordLayout struct {

func (r *RecordLayout) UnmarshalString(data string) error {
// mylog.Check(errors.New("improperly terminated layout"))

switch {
case strings.Contains(data, "unnamed at"):
//return nil
//mylog.Warning("skip unmarshal RecordLayout", data)
case strings.Contains(data, "__NSConstantString_tag"):
mylog.Warning("skip unmarshal RecordLayout", data)
return nil
}

first := true
offset := 0

for _, line := range strings.Split(data, "\n") {
if line == "" {
continue
}
before, after, found := strings.Cut(line, "|")
if !found {
continue
Expand Down Expand Up @@ -99,8 +112,13 @@ func (r *RecordLayout) UnmarshalString(data string) error {
after = strings.TrimSpace(after)

// Parse name and type
name := ""
name := "" //todo test

typen := after
//save strut type todo test
if strings.HasPrefix(typen, "struct ") {
typen = "struct "
}
if lastSpace := strings.LastIndex(after, " "); lastSpace != -1 {
// If the last space is followed by a closing parenthesis, then it is part of the type.
if !strings.Contains(after[lastSpace+1:], ")") {
Expand All @@ -112,6 +130,10 @@ func (r *RecordLayout) UnmarshalString(data string) error {
}
}

if name == "" {
continue
}

// Create node
if first {
r.Offset = offset
Expand All @@ -128,7 +150,7 @@ func (r *RecordLayout) UnmarshalString(data string) error {
})
}
}

mylog.Json("layout", r.layout.Fields)
// Group fields
r.regroup()
return nil
Expand Down

0 comments on commit ef87334

Please sign in to comment.