From c3f8e5bcc572759fc60f99546c305ba067fe800a Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 10 Feb 2023 09:37:09 +0900 Subject: [PATCH] [vkgen] Support ignored fields This allows having sections in a spec used for things like `properties` that have no corresponding fields in the actual struct: the field is ignored when parsing and no cexpr field symbol is emitted. --- .../video/renderer/vulkan/vkgen/Makemodule.am | 2 + libs/video/renderer/vulkan/vkgen/vkfielddef.r | 3 + .../renderer/vulkan/vkgen/vkfieldignore.h | 14 +++++ .../renderer/vulkan/vkgen/vkfieldignore.r | 63 +++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100644 libs/video/renderer/vulkan/vkgen/vkfieldignore.h create mode 100644 libs/video/renderer/vulkan/vkgen/vkfieldignore.r diff --git a/libs/video/renderer/vulkan/vkgen/Makemodule.am b/libs/video/renderer/vulkan/vkgen/Makemodule.am index 90d01645e..83fab1eee 100644 --- a/libs/video/renderer/vulkan/vkgen/Makemodule.am +++ b/libs/video/renderer/vulkan/vkgen/Makemodule.am @@ -11,6 +11,7 @@ vkgen_dat_src= \ libs/video/renderer/vulkan/vkgen/vkfieldcustom.r \ libs/video/renderer/vulkan/vkgen/vkfielddata.r \ libs/video/renderer/vulkan/vkgen/vkfielddef.r \ + libs/video/renderer/vulkan/vkgen/vkfieldignore.r \ libs/video/renderer/vulkan/vkgen/vkfieldreadonly.r \ libs/video/renderer/vulkan/vkgen/vkfieldsingle.r \ libs/video/renderer/vulkan/vkgen/vkfieldstring.r \ @@ -55,6 +56,7 @@ EXTRA_DIST += \ libs/video/renderer/vulkan/vkgen/vkfieldcustom.h \ libs/video/renderer/vulkan/vkgen/vkfielddata.h \ libs/video/renderer/vulkan/vkgen/vkfielddef.h \ + libs/video/renderer/vulkan/vkgen/vkfieldignore.h \ libs/video/renderer/vulkan/vkgen/vkfieldreadonly.h \ libs/video/renderer/vulkan/vkgen/vkfieldsingle.h \ libs/video/renderer/vulkan/vkgen/vkfieldstring.h \ diff --git a/libs/video/renderer/vulkan/vkgen/vkfielddef.r b/libs/video/renderer/vulkan/vkgen/vkfielddef.r index 9a7f34bd0..71e82e57f 100644 --- a/libs/video/renderer/vulkan/vkgen/vkfielddef.r +++ b/libs/video/renderer/vulkan/vkgen/vkfielddef.r @@ -6,6 +6,7 @@ #include "vkfieldcustom.h" #include "vkfielddata.h" #include "vkfielddef.h" +#include "vkfieldignore.h" #include "vkfieldreadonly.h" #include "vkfieldsingle.h" #include "vkfieldstring.h" @@ -45,6 +46,8 @@ return [[[ArrayField alloc] init:item struct:strct field:fname] autorelease]; case "readonly": return [[[ReadOnlyField alloc] init:item struct:strct field:fname] autorelease]; + case "ignore": + return [[[IgnoreField alloc] init:item struct:strct field:fname] autorelease]; } return nil; } diff --git a/libs/video/renderer/vulkan/vkgen/vkfieldignore.h b/libs/video/renderer/vulkan/vkgen/vkfieldignore.h new file mode 100644 index 000000000..fd2b34374 --- /dev/null +++ b/libs/video/renderer/vulkan/vkgen/vkfieldignore.h @@ -0,0 +1,14 @@ +#ifndef __renderer_vulkan_vkgen_vkfieldignore_h +#define __renderer_vulkan_vkgen_vkfieldignore_h + +#include "vkfielddef.h" + +@class FieldType; + +@interface IgnoreField: FieldDef +{ + FieldType *type; +} +@end + +#endif//__renderer_vulkan_vkgen_vkfieldignore_h diff --git a/libs/video/renderer/vulkan/vkgen/vkfieldignore.r b/libs/video/renderer/vulkan/vkgen/vkfieldignore.r new file mode 100644 index 000000000..dfbb71387 --- /dev/null +++ b/libs/video/renderer/vulkan/vkgen/vkfieldignore.r @@ -0,0 +1,63 @@ +#include +#include + +#include "vkfieldignore.h" +#include "vkfieldtype.h" +#include "vkstruct.h" + +@implementation IgnoreField + +-init:(PLItem *)item struct:(Struct *)strct field:(string)fname +{ + self = [super init]; + if (!self) { + return self; + } + + line = [item line]; + struct_name = str_hold ([strct outname]); + field_name = str_hold (fname); + return self; +} + +-fromField:(qfot_var_t *)field struct:(Struct *)strct +{ + return self; +} + +-(void)dealloc +{ + str_free (struct_name); + str_free (field_name); + [super dealloc]; +} + +-writeParseData +{ + return self; +} + +-writeField +{ + string parse_type = [FieldType anyType]; + fprintf (output_file, "\t{\"%s\", 0, %s, parse_%s, 0},\n", + field_name, parse_type, "ignore"); + return self; +} + +-writeSymbol +{ + return self; +} + +-(string) name +{ + return field_name; +} + +-(int) searchType +{ + return 1; +} + +@end