mpw/bin/template.h

89 lines
1.6 KiB
C
Raw Normal View History

2014-12-29 05:12:47 +00:00
#ifndef __debug_template_h__
#define __debug_template_h__
#include <unordered_map>
2014-12-29 21:58:01 +00:00
#include <string>
2014-12-29 05:12:47 +00:00
namespace Debug {
2014-12-29 20:15:34 +00:00
enum {
// 0x8000 = pointer
// 0x1000 = unsigned
// 0x0f00 = size
// 0-255 - type
kSInt64 = 0x0800,
kUInt64 = 0x1800,
kSInt32 = 0x0400,
kUInt32 = 0x1400,
kSInt16 = 0x0200,
kUInt16 = 0x1200,
kSInt8 = 0x0100,
kUInt8 = 0x1100,
kStruct = 0x0000,
kStructPtr = 0x8000,
// ptrs are a special case where size = 0
//kVoid = 0x0001,
kVoidPtr = 0x8001,
// these exist for display purposes.
kCStringPtr = 0x8002,
kPStringPtr = 0x8003,
kOSType = 0x00404,
kBoolean = 0x0105,
kOSErr = 0x0206,
kHandle = 0x04007,
};
inline unsigned MakePtr(unsigned type) { return type | 0x8000; }
inline unsigned MakeType(unsigned size, bool sign, bool ptr) {
unsigned rv = size << 8;
if (!sign) rv |= 0x0100;
if (ptr) rv |= 0x8000;
return rv;
}
2014-12-29 05:12:47 +00:00
2014-12-29 20:15:34 +00:00
2014-12-29 05:12:47 +00:00
struct FieldEntry;
2014-12-29 20:15:34 +00:00
typedef FieldEntry *Template;
2014-12-29 05:12:47 +00:00
struct FieldEntry {
std::string *name;
unsigned type;
unsigned count;
2014-12-29 20:15:34 +00:00
Template tmpl;
2014-12-29 05:12:47 +00:00
FieldEntry *next;
2014-12-29 20:15:34 +00:00
unsigned struct_size; // only populated for head entry.
2014-12-29 05:12:47 +00:00
};
2014-12-29 20:15:34 +00:00
struct TemplateParseInfo {
std::unordered_map<std::string, Template> *templates;
std::unordered_map<std::string, unsigned> *types;
int LineNumber;
2014-12-29 05:12:47 +00:00
};
2014-12-29 20:15:34 +00:00
void CreateTypedef(const std::string *name, int type, TemplateParseInfo *);
void CreateTemplate(const std::string *name, FieldEntry *firstField, TemplateParseInfo *);
bool LoadTemplateFile(const std::string &filename, std::unordered_map<std::string, Template> &);
2014-12-29 05:12:47 +00:00
2014-12-29 21:58:01 +00:00
void ApplyTemplate(uint32_t address, FieldEntry *e, unsigned indent = 0);
2014-12-29 05:12:47 +00:00
}
#endif