mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-21 09:30:55 +00:00
fix printing for template within a template
This commit is contained in:
parent
8e434d39f8
commit
f7bee265cc
@ -135,6 +135,7 @@ namespace Debug {
|
||||
return;
|
||||
|
||||
case kBoolean:
|
||||
fputc(' ', stdout);
|
||||
fputs(value ? "true" : "false", stdout);
|
||||
return;
|
||||
|
||||
@ -153,21 +154,19 @@ namespace Debug {
|
||||
{
|
||||
unsigned offset = 0;
|
||||
|
||||
if (!e) return;
|
||||
|
||||
for( ; e ; e = e->next)
|
||||
{
|
||||
|
||||
bool nonl = false;
|
||||
unsigned count = e->count;
|
||||
unsigned type = e->type;
|
||||
unsigned s = (type & 0x0f00) >> 8;
|
||||
|
||||
if (!s) {
|
||||
// struct or pointer...
|
||||
if (e->type & 0x8000) s = 4;
|
||||
else if (e->tmpl) s = e->tmpl->struct_size;
|
||||
}
|
||||
|
||||
|
||||
printf("%-20s", e->name->c_str());
|
||||
for (unsigned i = 0; i < indent; ++i) fputc('>',stdout);
|
||||
fputs(e->name->c_str(),stdout);
|
||||
for(unsigned i = indent + e->name->length(); i < 40; ++i) fputc(' ',stdout);
|
||||
|
||||
// todo -- support arrays
|
||||
// todo -- pretty print values (boolean, oserr, ostype, etc.)
|
||||
@ -208,12 +207,14 @@ namespace Debug {
|
||||
}
|
||||
if (type == 0) {
|
||||
// struct ... recurse.
|
||||
|
||||
fputc('\n', stdout);
|
||||
nonl = true;
|
||||
ApplyTemplate(address + offset, e->tmpl, indent + 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
if (!nonl) fputc('\n', stdout);
|
||||
offset += CalcOneSize(e);
|
||||
|
||||
}
|
||||
|
@ -52,57 +52,8 @@ namespace Debug {
|
||||
return rv;
|
||||
}
|
||||
|
||||
enum {
|
||||
kDisplayNative = 0,
|
||||
kDisplayStringPtr, // p-string
|
||||
kDisplayCStringPtr, // c-string
|
||||
kDisplayOSType, // four-cc
|
||||
kDisplayBoolean, // unsigned char, display true/false
|
||||
kDisplayOSErr,
|
||||
};
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
struct Type {
|
||||
enum {
|
||||
kSimpleType,
|
||||
kStructType,
|
||||
kPointerType,
|
||||
};
|
||||
uint16_t tag;
|
||||
uint16_t size;
|
||||
};
|
||||
|
||||
// handles [signed/unsigned] type, type[], *type, and *type[]
|
||||
struct SimpleType : public Type {
|
||||
unsigned rank:16; // int == int[1]
|
||||
unsigned display:14; //
|
||||
|
||||
unsigned sign:1;
|
||||
unsigned pointer:1;
|
||||
|
||||
SimpleType() {
|
||||
tag = kSimpleType;
|
||||
size = 0;
|
||||
rank = 0;
|
||||
display = 0;
|
||||
sign = 0;
|
||||
pointer = 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct PointerType: public Type {
|
||||
Type *type;
|
||||
};
|
||||
|
||||
struct StructType : public Type {
|
||||
unsigned total_size;
|
||||
FieldEntry *firstField;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
struct FieldEntry;
|
||||
typedef FieldEntry *Template;
|
||||
|
||||
|
@ -139,7 +139,7 @@ void TemplateParse(void *yyp, int yymajor, const std::string *yyminor, Debug::Te
|
||||
};
|
||||
|
||||
# identifier ... but also need to check if it's a type.
|
||||
[A-Za-z_][A-Za-z0-9_]+ {
|
||||
[A-Za-z_][A-Za-z0-9_]* {
|
||||
|
||||
// intern the string.
|
||||
|
||||
@ -236,7 +236,7 @@ bool LoadTemplateFile(const std::string &filename, std::unordered_map<std::strin
|
||||
|
||||
if (cs == lexer_error)
|
||||
{
|
||||
fprintf(stderr, "illegal character: `%c'\n", *p);
|
||||
fprintf(stderr, "Template error: line %d - illegal character: `%c'\n", info.LineNumber, *p);
|
||||
TemplateParseFree(parser, free);
|
||||
munmap(buffer, st.st_size);
|
||||
return false;
|
||||
|
@ -57,7 +57,7 @@ struct_field(rhs) ::= opt_volatile TEMPLATE(a) opt_star(star) IDENTIFIER(b) arra
|
||||
FieldEntry *e = (FieldEntry *)calloc(sizeof(FieldEntry), 1);
|
||||
|
||||
e->name = (std::string *)b;
|
||||
e->type = star ? kStruct : kStructPtr;
|
||||
e->type = star ? kStructPtr : kStruct;
|
||||
e->tmpl = (Template)a;
|
||||
e->count = c;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user