Skip to content

Commit

Permalink
TestBindMacros
Browse files Browse the repository at this point in the history
  • Loading branch information
ddkwork committed Jun 21, 2024
1 parent ddfb860 commit 51abd1b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
7 changes: 7 additions & 0 deletions gengo/bind/demo/cpp/msvc/sys/b.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
v -cc msvc -kernel -o driver.sys driver.v \
-DUNICODE -D_UNICODE \
-DWINVER=0x0600 -D_WIN32_WINNT=0x0600 -DNTDDI_VERSION=0x06000000 \
-I"C:\WinDDK\7600.16385.1\inc\ddk" \
-Wl,/entry:DriverEntry -Wl,/subsystem:native -Wl,/nodefaultlib \
-lntoskrnl.lib -lhal.lib \
pause
4 changes: 4 additions & 0 deletions gengo/bind/demo/cpp/msvc/sys/driver.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module sys
fn main() {
println('hello,world')
}
24 changes: 20 additions & 4 deletions gengo/bind/sdkMerge/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,34 @@ func ContainsLetter(s string) bool {
func MacrosInHeader() (m *maps.SafeMap[string, bool]) {
m = new(maps.SafeMap[string, bool])
for _, s := range stream.NewBuffer("macros.log").ToLines() {
for _, s2 := range stream.NewBuffer("combined_headers.h").ToLines() {
if strings.HasPrefix(s, s2) {
m.Set(s, true)
}
m.Set(s, true)
}

m2 := new(maps.SafeMap[string, bool])
for _, s := range stream.NewBuffer("combined_headers.h").ToLines() {
if strings.HasPrefix(s, "#define ") {
m2.Set(s, true)
}
}
println(m.Len())
println(m2.Len())

for _, s := range m.Keys() {
if !m2.HasPrefix(s) { //todo bug
m.Delete(s)
mylog.Trace("delete macro", s)
}
}
println(m.Len())
println(m2.Len())

return
}

func TestBindMacros(t *testing.T) {
mylog.Todo("handle macros func like CTL_CODE(DeviceType,Function,Method,Access) ( ((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method)) ")
mustPrefixs := MacrosInHeader()
return
mylog.Trace("number of macros", mustPrefixs.Len())

g := stream.NewGeneratedFile()
Expand Down

0 comments on commit 51abd1b

Please sign in to comment.