Skip to content

Commit

Permalink
make config.c way more readable, jnthn++
Browse files Browse the repository at this point in the history
  • Loading branch information
FROGGS committed Oct 23, 2013
1 parent 35e64be commit f27a098
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
14 changes: 2 additions & 12 deletions Configure.pl
Expand Up @@ -504,12 +504,7 @@ sub write_backend_config {
if (ref($v) eq 'ARRAY') {
my $i = 0;
for (@$v) {
$config{backendconfig} .= <<END;
MVM_repr_bind_key_boxed(tc, config,
MVM_string_ascii_decode_nt(tc, tc->instance->VMString, \"$k\[$i]\"),
MVM_repr_box_str(tc, MVM_hll_current(tc)->str_box_type,
MVM_string_ascii_decode_nt(tc, tc->instance->VMString, \"$_\")));
END
$config{backendconfig} .= qq/ add_entry(tc, config, "$k\[$i]", "$_");\n/;
$i++;
}
}
Expand All @@ -520,12 +515,7 @@ END
$v //= '';
$v =~ s/"/\\"/g;
$v =~ s/\n/\\\n/g;
$config{backendconfig} .= <<END;
MVM_repr_bind_key_boxed(tc, config,
MVM_string_ascii_decode_nt(tc, tc->instance->VMString, \"$k\"),
MVM_repr_box_str(tc, MVM_hll_current(tc)->str_box_type,
MVM_string_ascii_decode_nt(tc, tc->instance->VMString, \"$v\")));
END
$config{backendconfig} .= qq/ add_entry(tc, config, "$k", "$v");\n/;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions build/config.c.in
Expand Up @@ -9,6 +9,12 @@
#include "moar.h"
#include "gen/config.h"

#define add_entry(tc, hash, name, value) \
MVM_repr_bind_key_boxed(tc, hash, \
MVM_string_ascii_decode_nt(tc, tc->instance->VMString, name), \
MVM_repr_box_str(tc, MVM_hll_current(tc)->str_box_type, \
MVM_string_ascii_decode_nt(tc, tc->instance->VMString, value)))

MVMObject *MVM_backend_config(MVMThreadContext *tc) {
MVMObject *config = MVM_repr_alloc_init(tc, tc->instance->boot_types.BOOTHash);
MVMROOT(tc, config, {
Expand Down

0 comments on commit f27a098

Please sign in to comment.