forked from paulfitz/daff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimpleView.hx
78 lines (64 loc) · 1.82 KB
/
SimpleView.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// -*- mode:java; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-
#if !TOPLEVEL
package coopy;
#end
/**
*
* A basic view implementation, for interpreting the content of cells.
* Each supported language may have an optimized native implementation.
* See the `View` interface for documentation.
*
*/
@:expose
class SimpleView implements View {
public function new() : Void {
}
public function toString(d: Dynamic) : String {
if (d==null) return "";
return "" + d;
}
public function equals(d1: Dynamic, d2: Dynamic) : Bool {
if (d1==null && d2==null) return true;
if (d1==null || d2==null) return false;
return ("" + d1) == ("" + d2);
}
public function toDatum(x: Dynamic) : Dynamic {
#if cpp
return new SimpleCell(x);
#else
return x;
#end
}
public function makeHash() : Dynamic {
return new Map<String,Dynamic>();
}
public function hashSet(h: Dynamic, str: String, d: Dynamic) : Void {
var hh : Map<String,Dynamic> = cast h;
hh.set(str,d);
}
public function hashExists(h: Dynamic, str: String) : Bool {
var hh : Map<String,Dynamic> = cast h;
return hh.exists(str);
}
public function hashGet(h: Dynamic, str: String) : Dynamic {
var hh : Map<String,Dynamic> = cast h;
return hh.get(str);
}
public function isHash(h: Dynamic) : Bool {
#if rb
// work around limitation of ruby target
return untyped __rb__("h.respond_to? :keys");
#else
return Std.is(h,haxe.ds.StringMap);
#end
}
public function isTable(t : Dynamic) : Bool {
return Std.is(t,Table);
}
public function getTable(t : Dynamic) : Table {
return cast t;
}
public function wrapTable(t : Table) : Dynamic {
return t;
}
}