Mercurial > games > semicongine
comparison svk/generate.nim @ 1482:bca8f65ed4ed
did: continue on generator
| author | sam <sam@basx.dev> |
|---|---|
| date | Mon, 28 Apr 2025 01:22:07 +0700 |
| parents | a99f3227130c |
| children | 55911f736a5a |
comparison
equal
deleted
inserted
replaced
| 1481:a99f3227130c | 1482:bca8f65ed4ed |
|---|---|
| 32 "uint64_t": "uint64", | 32 "uint64_t": "uint64", |
| 33 "int64_t": "int64", | 33 "int64_t": "int64", |
| 34 "size_t": "csize_t", | 34 "size_t": "csize_t", |
| 35 "int": "cint", | 35 "int": "cint", |
| 36 }.toTable | 36 }.toTable |
| 37 | |
| 38 # load xml | 37 # load xml |
| 39 let xml = (system.currentSourcePath.parentDir() / "vk.xml").loadXml() | 38 let xml = (system.currentSourcePath.parentDir() / "vk.xml").loadXml() |
| 40 let platforms = xml.findAll("platforms")[0] | 39 let platforms = xml.findAll("platforms")[0] |
| 41 let types = xml.findAll("types")[0] | 40 let types = xml.findAll("types")[0] |
| 42 let xmlenums = xml.findAll("enums") | 41 let xmlenums = xml.findAll("enums") |
| 66 var enums: Table[string, EnumDef] | 65 var enums: Table[string, EnumDef] |
| 67 | 66 |
| 68 func addValue(edef: var EnumDef, n: XmlNode) = | 67 func addValue(edef: var EnumDef, n: XmlNode) = |
| 69 if n.attr("deprecated") != "aliased" and n.attr("alias") == "": | 68 if n.attr("deprecated") != "aliased" and n.attr("alias") == "": |
| 70 if n.attr("name") in edef.values.mapIt(it.name): | 69 if n.attr("name") in edef.values.mapIt(it.name): |
| 71 return | |
| 72 if n.attr("name").endsWith("_EXT") and | |
| 73 n.attr("name")[0 ..< ^4] in edef.values.mapIt(it.name): | |
| 74 return | 70 return |
| 75 | 71 |
| 76 var value = "" | 72 var value = "" |
| 77 if n.attr("value") != "": | 73 if n.attr("value") != "": |
| 78 value = n.attr("value") | 74 value = n.attr("value") |
| 85 var v = smartParseInt(n.attr("offset")) + enumBase | 81 var v = smartParseInt(n.attr("offset")) + enumBase |
| 86 if n.attr("dir") == "-": | 82 if n.attr("dir") == "-": |
| 87 v = -v | 83 v = -v |
| 88 value = $(v) | 84 value = $(v) |
| 89 | 85 |
| 90 edef.values.add EnumEntry(name: n.attr("name"), value: value) | 86 if value notin edef.values.mapIt(it.value): |
| 87 edef.values.add EnumEntry(name: n.attr("name"), value: value) | |
| 91 | 88 |
| 92 func doTypename(typename: string, isPointer: bool): string = | 89 func doTypename(typename: string, isPointer: bool): string = |
| 93 result = TYPEMAP.getOrDefault(typename.strip(), typename.strip()).strip(chars = {'_'}) | 90 result = TYPEMAP.getOrDefault(typename.strip(), typename.strip()).strip(chars = {'_'}) |
| 94 | 91 |
| 95 if typename == "void": | 92 if typename == "void": |
| 307 "VK_PIPELINE_CACHE_HEADER_VERSION_ONE", | 304 "VK_PIPELINE_CACHE_HEADER_VERSION_ONE", |
| 308 "VK_PIPELINE_CACHE_HEADER_VERSION_SAFETY_CRITICAL_ONE", | 305 "VK_PIPELINE_CACHE_HEADER_VERSION_SAFETY_CRITICAL_ONE", |
| 309 "VK_DEVICE_FAULT_VENDOR_BINARY_HEADER_VERSION_ONE_EXT", | 306 "VK_DEVICE_FAULT_VENDOR_BINARY_HEADER_VERSION_ONE_EXT", |
| 310 ] | 307 ] |
| 311 outFile.writeLine "type" | 308 outFile.writeLine "type" |
| 309 | |
| 310 echo "#########################" | |
| 312 for edef in enums.values(): | 311 for edef in enums.values(): |
| 312 echo edef.values | |
| 313 if edef.values.len > 0: | 313 if edef.values.len > 0: |
| 314 outFile.writeLine &" {edef.name}* {{.size: 4.}} = enum" | 314 outFile.writeLine &" {edef.name}* {{.size: 4.}} = enum" |
| 315 for ee in edef.values: | 315 for ee in edef.values: |
| 316 # due to the nim identifier-system, there might be collisions between typenames and enum-member names | 316 # due to the nim identifier-system, there might be collisions between typenames and enum-member names |
| 317 if ee.name in nameCollisions: | 317 if ee.name in nameCollisions: |
