Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Several fixes and cleanups to the Dumper library. Add it to the build…

… since it compiles and runs now
  • Loading branch information...
commit 6191b536161d5c9e96f27c5755136d13d9ec6b0f 1 parent a56c631
@Whiteknight authored
View
7 setup.winxed
@@ -291,6 +291,13 @@ function setup_experimental_libraries(var rosella)
"reflect/class/Attribute",
"reflect/class/Method"
);
+
+ setup_unstable_lib(rosella, "dumper", ["Core"],
+ "dumper/Dumper",
+ "dumper/DumpHandler",
+ "dumper/dumphandler/Array",
+ "dumper/dumphandler/Hash"
+ );
}
function setup_utilities(var rosella)
View
8 src/unstable/dumper/DumpHandler.winxed
@@ -2,6 +2,8 @@ namespace Rosella { namespace Dumper
{
class DumpHandler
{
+ function DumpHandler() { }
+
function can_dump(var obj)
{
return 1;
@@ -11,10 +13,10 @@ namespace Rosella { namespace Dumper
{
try {
string txt = string(obj);
- push(sb, Winxed_Builtins.sprintf("'%s'", [txt]));
- } catch {
+ push(sb, Winxed_Builtins.sprintf("'%s'\n", [txt]));
+ } catch() {
int addr;
- push(sb, Winxed_Builtins.sprintf("PMC (%s)", [typeof(obj)]);
+ push(sb, Winxed_Builtins.sprintf("PMC (%s)\n", [typeof(obj)]));
}
}
}
View
12 src/unstable/dumper/Dumper.winxed
@@ -5,6 +5,7 @@ namespace Rosella
var role_dumpers;
var type_dumpers;
var fallback_dumper;
+ var indent;
function Dumper()
{
@@ -14,12 +15,13 @@ namespace Rosella
};
self.type_dumpers = {};
self.fallback_dumper = new Rosella.Dumper.DumpHandler();
+ self.indent = "\t";
}
function dump(var obj)
{
var sb = new "StringBuilder";
- self.__dump_recursive(obj, sb, "");
+ self.__dump_recurse(obj, sb, "");
return string(sb);
}
@@ -29,7 +31,7 @@ namespace Rosella
for (string key in self.type_dumpers)
{
if (type == key) {
- self.type_dumpers[key].dump(self, obj, prefix, prefix + "\t", sb);
+ self.type_dumpers[key].dump(self, obj, prefix, prefix + string(self.indent), sb);
return;
}
}
@@ -37,12 +39,12 @@ namespace Rosella
{
int does_it = 0;
${ does does_it, obj, role };
- if (does_it) {
- self.role_dumpers[role].dump(self, obj, prefix, prefix + "\t", sb);
+ if (does_it && self.role_dumpers[role].can_dump(obj)) {
+ self.role_dumpers[role].dump(self, obj, prefix, prefix + string(self.indent), sb);
return;
}
}
- self.fallback_dumper.dump(self, obj, prefix, prefix + "\t", sb);
+ self.fallback_dumper.dump(self, obj, prefix, prefix + string(self.indent), sb);
}
}
}
View
8 src/unstable/dumper/dumphandler/Array.winxed
@@ -2,6 +2,8 @@ namespace Rosella { namespace Dumper { namespace DumpHandler
{
class Array : Rosella.Dumper.DumpHandler
{
+ function Array() { }
+
function can_handle(var obj)
{
int can_do = 0;
@@ -11,14 +13,14 @@ namespace Rosella { namespace Dumper { namespace DumpHandler
function dump(var dump, var obj, string pprefix, string prefix, var sb)
{
- push(sb, "[");
+ push(sb, "[\n");
for (int i = 0; i < elements(obj); i++) {
push(sb, Winxed_Builtins.sprintf("%s%d => ", [prefix, i]));
- dump.__dump_recursive(obj[i], sb);
+ dump.__dump_recurse(obj[i], sb, prefix);
}
push(sb, pprefix);
- push(sb, "]");
+ push(sb, "]\n");
}
}
}}}
View
8 src/unstable/dumper/dumphandler/Hash.winxed
@@ -2,6 +2,8 @@ namespace Rosella { namespace Dumper { namespace DumpHandler
{
class Hash : Rosella.Dumper.DumpHandler
{
+ function Hash() { }
+
function can_handle(var obj)
{
int can_do = 0;
@@ -11,14 +13,14 @@ namespace Rosella { namespace Dumper { namespace DumpHandler
function dump(var dump, var obj, string pprefix, string prefix, var sb)
{
- push(sb, "{");
+ push(sb, "{\n");
for (string key in obj) {
push(sb, Winxed_Builtins.sprintf("%s%s => ", [prefix, key]));
- dump.__dump_recursive(obj[key], sb);
+ dump.__dump_recurse(obj[key], sb, prefix);
}
push(sb, pprefix);
- push(sb, "}");
+ push(sb, "}\n");
}
}
}}}
Please sign in to comment.
Something went wrong with that request. Please try again.