[vkgen] Use typedef name for structs

Using the typedef name makes using structs declared as

    typedef struct foo_s { ... } foo_t;

easier and cleaner. Sure, I could have written the "struct foo_s" for
the output name, but I'm much more likely to look for foo_t than foo_s
when checking the generated code.
This commit is contained in:
Bill Currie 2023-02-08 17:32:20 +09:00
parent 7c1aff6736
commit d5cd4f6ede
4 changed files with 21 additions and 0 deletions

View file

@ -6,6 +6,15 @@
#include "vkstruct.h"
@implementation Alias
-initWithType: (qfot_type_t *) type
{
if (!(self = [super initWithType: type])) {
return nil;
}
[[self resolveType] setAlias: self];
return self;
}
-(string) name
{
return type.alias.name;

View file

@ -245,6 +245,9 @@
if (outname) {
return outname;
}
if (alias) {
return [alias name];
}
return [self name];
}

View file

@ -7,6 +7,7 @@
@interface Type: Object
{
qfot_type_t *type;
Type *alias;
}
+fromType: (qfot_type_t *) type;
/** \warning returned string is ephemeral
@ -15,6 +16,7 @@
/** \warning returned string is ephemeral
*/
-(string) name;
-(void) setAlias: (Type *) alias;
-(void) addToQueue;
-(Type *) resolveType;
+(Type *) findType: (qfot_type_t *) type;

View file

@ -86,6 +86,13 @@ static string get_type_key (void *type, void *unused)
return type.encoding;
}
-(void) setAlias: (Type *) alias
{
if (!self.alias) {
self.alias = alias;
}
}
-(void) addToQueue
{
string name = [self name];