mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-11 15:51:36 +00:00
bd7212a411
Needed for any views that have to fetch additional data (strings, fields, etc).
65 lines
1.2 KiB
R
65 lines
1.2 KiB
R
#include <string.h>
|
|
#include "debugger/defview.h"
|
|
#include "debugger/nameview.h"
|
|
|
|
static string meta_views[] = {
|
|
"BasicView",
|
|
"StructView",
|
|
"UnionView",
|
|
"EnumView",
|
|
"ArrayView",
|
|
"ClassView",
|
|
"AliasView", // shouldn't happen, but...
|
|
};
|
|
|
|
@implementation DefView
|
|
|
|
-init
|
|
{
|
|
if (!(self = [super init])) {
|
|
return nil;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-initWithType:(qfot_type_t *)type
|
|
{
|
|
if (!(self = [super init])) {
|
|
return nil;
|
|
}
|
|
self.type = type;
|
|
return self;
|
|
}
|
|
|
|
-setTarget:(qdb_target_t)target
|
|
{
|
|
self.target = target;
|
|
return self;
|
|
}
|
|
|
|
+(DefView *)withType:(qfot_type_t *)type at:(unsigned)offset in:(void *)data
|
|
{
|
|
return [self withType:type at:offset in:data target:nil];
|
|
}
|
|
|
|
+(DefView *)withType:(qfot_type_t *)type
|
|
at:(unsigned)offset
|
|
in:(void *)data
|
|
target:(qdb_target_t)target
|
|
{
|
|
string metaname = nil;
|
|
if (type.meta == ty_alias) {
|
|
type = type.alias.aux_type;
|
|
}
|
|
if (type.meta >= 0
|
|
&& type.meta < sizeof(meta_views) / sizeof (meta_views[0])) {
|
|
metaname = meta_views[type.meta];
|
|
}
|
|
id class = obj_lookup_class (metaname);
|
|
if (class) {
|
|
return [[class withType:type at:offset in:data] setTarget:target];
|
|
}
|
|
return [NameView withName:"Invalid Meta"];
|
|
}
|
|
|
|
@end
|