Skip to content

Commit f12c97d

Browse files
committed
* HTML dump with CSS for nicer default output
1 parent 28cc239 commit f12c97d

File tree

3 files changed

+162
-50
lines changed

3 files changed

+162
-50
lines changed

src/mulle-objc-html.c

Lines changed: 44 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -566,15 +566,15 @@ char *mulle_objc_descriptor_describe_html( struct _mulle_objc_descriptor *desc
566566
"</TABLE>";
567567

568568
mulle_asprintf( &tmp[ 1],
569-
format,
570-
th, th,
571-
html_escape( desc->name),
572-
th, th,
573-
html_escape( desc->signature),
574-
th, th,
575-
desc->methodid,
576-
th, th,
577-
desc->bits);
569+
format,
570+
th, th,
571+
html_escape( desc->name),
572+
th, th,
573+
html_escape( desc->signature),
574+
th, th,
575+
desc->methodid,
576+
th, th,
577+
desc->bits);
578578

579579
return( final_concat_auto_tmp( tmp, 2));
580580
}
@@ -621,12 +621,12 @@ char *mulle_objc_descriptor_describe_row_html( intptr_t methodid,
621621
"<TD>%s</TD>"
622622
"</TR>\n";
623623
else
624-
format = "<TR>"
625-
"<TD>%s</TD>"
626-
"<TD>%s</TD>"
627-
"<TD>%08x</TD>"
628-
"<TD>0x%x</TD>"
629-
"</TR>\n";
624+
format = "<TR>"
625+
"<TD>%s</TD>"
626+
"<TD>%s</TD>"
627+
"<TD>%08x</TD>"
628+
"<TD>0x%x</TD>"
629+
"</TR>\n";
630630

631631
mulle_asprintf( &s,
632632
format,
@@ -794,20 +794,20 @@ char *mulle_objc_cache_describe_html( struct _mulle_objc_cache *cache,
794794
tmp = mulle_calloc( n, sizeof( char *));
795795

796796
i = 0;
797-
asprintf_table_header_colspan( &tmp[ i], styling, 5);
797+
asprintf_table_header_colspan( &tmp[ i], styling, colspan);
798798
len = strlen( tmp[ i]);
799799
++i;
800800

801801
mulle_asprintf( &tmp[ i],
802-
"<TR><TD>n</TD><TD COLSPAN=\"%d\">%lu</TD></TR>\n",
803-
colspan,
804-
(long) _mulle_atomic_pointer_nonatomic_read( &cache->n));
802+
"<TR><TD>n</TD><TD COLSPAN=\"%d\">%lu</TD></TR>\n",
803+
colspan,
804+
(long) _mulle_atomic_pointer_nonatomic_read( &cache->n));
805805
len += strlen( tmp[ i]);
806806
++i;
807807
mulle_asprintf( &tmp[ i],
808-
"<TR><TD>mask</TD><TD COLSPAN=\"%d\">0x%lx</TD></TR>\n",
809-
colspan,
810-
(long) cache->mask);
808+
"<TR><TD>mask</TD><TD COLSPAN=\"%d\">0x%lx</TD></TR>\n",
809+
colspan,
810+
(long) cache->mask);
811811
len += strlen( tmp[ i]);
812812
++i;
813813

@@ -822,16 +822,15 @@ char *mulle_objc_cache_describe_html( struct _mulle_objc_cache *cache,
822822
#ifdef MULLE_OBJC_CACHEENTRY_REMEMBERS_THREAD
823823
mulle_asprintf( &s, "<TD>%p</TD>", cache->entries[ j].thread);
824824
#endif
825-
mulle_asprintf( &tmp[ i],
826-
"<TR><TD>#%ld</TD><TD>%08x</TD><TD>%s</TD>"
827-
"<TD>%p</TD><TD>%d (%x)</TD>%s</TR>\n",
828-
j,
829-
sel,
830-
_mulle_objc_universe_describe_methodid( universe, sel),
831-
cache->entries[ j].value.functionpointer,
832-
index,
833-
sel & cache->mask,
834-
s);
825+
mulle_asprintf( &tmp[ i], "<TR><TD>#%ld</TD><TD>%08x</TD><TD>%s</TD>"
826+
"<TD>%p</TD><TD>%d (%x)</TD>%s</TR>\n",
827+
j,
828+
sel,
829+
_mulle_objc_universe_describe_methodid( universe, sel),
830+
cache->entries[ j].value.functionpointer,
831+
index,
832+
sel & cache->mask,
833+
s);
835834
#ifdef MULLE_OBJC_CACHEENTRY_REMEMBERS_THREAD
836835
mulle_free( s);
837836
#endif
@@ -957,11 +956,11 @@ char *mulle_objc_methodlist_describe_hor_html( struct _mulle_objc_methodlist *
957956
if( styling->classprefix)
958957
format = "<TR>"
959958
"<TH>name</TH>"
960-
"</TR>\n";
959+
"</TR>\n";
961960
else
962-
format = "<TR>"
961+
format = "<TR>"
963962
"<TD>name</TD>"
964-
"</TR>\n";
963+
"</TR>\n";
965964
}
966965
else
967966
{
@@ -972,7 +971,7 @@ char *mulle_objc_methodlist_describe_hor_html( struct _mulle_objc_methodlist *
972971
"<TH>methodid</TH>"
973972
"<TH>bits</TH>"
974973
"<TH>implementation</TH>"
975-
"</TR>\n";
974+
"</TR>\n";
976975
else
977976
format = "<TR>"
978977
"<TD>name</TD>"
@@ -1009,12 +1008,12 @@ char *mulle_objc_methodlist_describe_hor_html( struct _mulle_objc_methodlist *
10091008
_mulle_atomic_functionpointer_nonatomic_read( &list->methods[ j].implementation));
10101009

10111010
mulle_asprintf( &tmp[ i],
1012-
format,
1013-
html_escape( list->methods[ j].descriptor.name),
1014-
html_escape( list->methods[ j].descriptor.signature),
1015-
list->methods[ j].descriptor.methodid,
1016-
list->methods[ j].descriptor.bits,
1017-
buf);
1011+
format,
1012+
html_escape( list->methods[ j].descriptor.name),
1013+
html_escape( list->methods[ j].descriptor.signature),
1014+
list->methods[ j].descriptor.methodid,
1015+
list->methods[ j].descriptor.bits,
1016+
buf);
10181017
len += strlen( tmp[ i]);
10191018
++i;
10201019
}
@@ -1055,9 +1054,9 @@ char *mulle_objc_loadcategory_describe_row_html( void *value,
10551054
char *s;
10561055

10571056
mulle_asprintf( &s, "<TR><TD>%s( %s)</TD><TD>%08x</TD></TR>\n",
1058-
loadcat->classname,
1059-
loadcat->categoryname,
1060-
loadcat->categoryid);
1057+
loadcat->classname,
1058+
loadcat->categoryname,
1059+
loadcat->categoryid);
10611060
return( s);
10621061
}
10631062

src/mulle-objc-htmldump.c

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static char *html_escape( char *s)
170170
}
171171

172172

173-
static char *html_filename_for_name( char *name, char *directory)
173+
static char *filename_for_name_ext( char *name, char *ext, char *directory)
174174
{
175175
char *buf;
176176
size_t len;
@@ -182,28 +182,63 @@ static char *html_filename_for_name( char *name, char *directory)
182182
separator = '/';
183183
#endif
184184

185-
len = strlen( name) + strlen( directory) + 16;
185+
len = strlen( directory) + 1 + strlen( name) + strlen( ext) + 1;
186186
buf = mulle_malloc( len);
187-
sprintf( buf, "%s%c%s.html", directory, separator, html_escape( name));
187+
sprintf( buf, "%s%c%s%s", directory, separator, name, ext);
188188
return( buf);
189189
}
190190

191191

192+
static char *html_filename_for_name( char *name, char *directory)
193+
{
194+
char *escaped;
195+
196+
escaped = html_escape( name);
197+
return( filename_for_name_ext( escaped, ".html", directory));
198+
}
199+
200+
192201
static char *filename_for_universe( struct _mulle_objc_universe *universe,
193202
char *directory)
194203
{
195204
char *buf;
196205
size_t len;
206+
char separator;
197207

208+
#ifdef _WIN32
209+
separator = '\\';
210+
#else
211+
separator = '/';
212+
#endif
198213
assert( directory);
199214

200-
len = strlen( directory) + 16;
215+
len = strlen( directory) + 12;
201216
buf = mulle_malloc( len);
202-
sprintf( buf, "%s/index.html", directory);
217+
sprintf( buf, "%s%cindex.html", directory, separator);
203218
return( buf);
204219
}
205220

206221

222+
static void write_css_if_needed( char *directory)
223+
{
224+
FILE *fp;
225+
char *filename;
226+
static char css[] = ""
227+
#include "mulle-objc.css.inc"
228+
;
229+
230+
if( getenv( "MULLE_OBJC_CSS_URL"))
231+
return;
232+
233+
filename = filename_for_name_ext( "mulle-objc", ".css", directory);
234+
fp = fopen( filename, "w");
235+
fwrite( css, sizeof( css) - 1, 1, fp);
236+
fclose( fp);
237+
mulle_free( filename);
238+
}
239+
240+
241+
207242
static FILE *open_and_print_start( char *name, char *title)
208243
{
209244
FILE *fp;
@@ -539,6 +574,7 @@ static void _print_infraclass( struct _mulle_objc_infraclass *infra, FILE *fp)
539574
{
540575
style = methodlisttable_style;
541576
style.title = _mulle_objc_methodlist_get_categoryname( methodlist);
577+
style.title = style.title ? style.title : "class";
542578
label = mulle_objc_methodlist_describe_hor_html( methodlist, &style);
543579
fprintf( fp, "%s\n", label);
544580
mulle_free( label);
@@ -559,6 +595,7 @@ static void _print_infraclass( struct _mulle_objc_infraclass *infra, FILE *fp)
559595
{
560596
style = methodlisttable_style;
561597
style.title = _mulle_objc_methodlist_get_categoryname( methodlist);
598+
style.title = style.title ? style.title : "class";
562599
label = mulle_objc_methodlist_describe_hor_html( methodlist, &style);
563600
fprintf( fp, "%s\n", label);
564601
mulle_free( label);
@@ -700,6 +737,7 @@ void
700737
fprintf( stderr, "Dumped HTML to \"%s\"\n", directory);
701738

702739
c_set_done( &info.set);
740+
write_css_if_needed( directory);
703741
}
704742

705743

@@ -739,6 +777,7 @@ void mulle_objc_class_htmldump_to_directory( struct _mulle_objc_class *cls,
739777
}
740778
while( cls = _mulle_objc_class_get_superclass( cls));
741779

780+
write_css_if_needed( directory);
742781
fprintf( stderr, "Dumped HTML to \"/%s\"\n", directory);
743782
}
744783

src/mulle-objc.css.inc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
"/*!\n"
2+
"Pure v0.6.2\n"
3+
"Copyright 2013 Yahoo!\n"
4+
"Licensed under the BSD License.\n"
5+
"https://github.com/yahoo/pure/blob/master/LICENSE.md\n"
6+
"*/\n"
7+
"table {\n"
8+
" /* Remove spacing between table cells (from Normalize.css) */\n"
9+
" border-collapse: collapse;\n"
10+
" border-spacing: 0;\n"
11+
" empty-cells: show;\n"
12+
" border: 1px solid #cbcbcb;\n"
13+
"}\n"
14+
"\n"
15+
"table td,\n"
16+
"table th {\n"
17+
" border-left: 1px solid #cbcbcb;/* inner column border */\n"
18+
" font-size: inherit;\n"
19+
" margin: 0;\n"
20+
" overflow: visible; /*to make ths where the title is really long work*/\n"
21+
" padding: 0.5em 1em; /* cell padding */\n"
22+
" border-width: 0 0 1px 0;\n"
23+
" border-bottom: 1px solid #cbcbcb;\n"
24+
"}\n"
25+
"\n"
26+
"/*\n"
27+
"striping:\n"
28+
" even - #fff (white)\n"
29+
" odd - #f2f2f2 (light gray)\n"
30+
"*/\n"
31+
"table td {\n"
32+
" background-color: transparent;\n"
33+
"}\n"
34+
"\n"
35+
"tr:nth-child(odd) td {\n"
36+
" background-color: #f2f2f2;\n"
37+
"}\n"
38+
"\n"
39+
"\n"
40+
"table tbody > tr:last-child > td {\n"
41+
" border-bottom-width: 0;\n"
42+
"}\n"
43+
"\n"
44+
"\n"
45+
"\n"
46+
".cache_table {}\n"
47+
".cache_table_header {}\n"
48+
".class_cache {}\n"
49+
".class_categories {}\n"
50+
".class_infra_link {}\n"
51+
".class_ivars {}\n"
52+
".class_links {}\n"
53+
".class_meta_link {}\n"
54+
".class_methods {}\n"
55+
".class_properties {}\n"
56+
".class_protocolclasses {}\n"
57+
".class_protocols {}\n"
58+
".class_runtime_link {}\n"
59+
".class_table {}\n"
60+
".class_table_header {}\n"
61+
".class_values {}\n"
62+
".infra_table {}\n"
63+
".infra_table_header {}\n"
64+
".method_table {}\n"
65+
".method_table_header {}\n"
66+
".runtime_classes {}\n"
67+
".runtime_fastclasses {}\n"
68+
".runtime_selectors {}\n"
69+
".runtime_strings {}\n"
70+
".runtime_table {}\n"
71+
".runtime_table_header {}\n"
72+
".runtime_values {}\n"
73+
".selector_table {}\n"
74+
".selector_table_header {}\n"

0 commit comments

Comments
 (0)