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 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
#!/usr/bin/env ruby
all = [
"BackwardChar() bool",
"BackwardChars(int) bool",
"BackwardCursorPosition() bool",
"BackwardCursorPositions(int) bool",
"BackwardLine() bool",
"BackwardLines(int) bool",
"BackwardToTagToggle(TextTag) bool",
"BackwardVisibleCursorPosition() bool",
"BackwardVisibleCursorPositions(int) bool",
"BackwardVisibleLine() bool",
"BackwardVisibleLines(int) bool",
"BeginsTag(TextTag) bool",
"CanInsert(bool) bool",
"Compare(TextIter) int",
"Editable(bool) bool",
"EndsLine() bool",
"EndsSentence() bool",
"EndsTag(TextTag) bool",
"EndsWord() bool",
"Equal(TextIter) bool",
"ForwardChar() bool",
"ForwardChars(int) bool",
"ForwardCursorPosition() bool",
"ForwardCursorPositions(int) bool",
"ForwardLine() bool",
"ForwardLines(int) bool",
"ForwardSentenceEnd() bool",
"ForwardSentenceEnds(int) bool",
"ForwardToEnd()",
"ForwardToLineEnd() bool",
"ForwardToTagToggle(TextTag) bool",
"ForwardVisibleCursorPosition() bool",
"ForwardVisibleCursorPositions(int) bool",
"ForwardVisibleLine() bool",
"ForwardVisibleLines(int) bool",
"ForwardVisibleWordEnd() bool",
"ForwardVisibleWordEnds(int) bool",
"ForwardWordEnd() bool",
"ForwardWordEnds(int) bool",
"GetBuffer() TextBuffer",
"GetBytesInLine() int",
"GetChar() rune",
"GetCharsInLine() int",
"GetLine() int",
"GetLineIndex() int",
"GetLineOffset() int",
"GetOffset() int",
"GetSlice(TextIter) string",
"GetText(TextIter) string",
"GetVisibleLineIndex() int",
"GetVisibleLineOffset() int",
"GetVisibleSlice(TextIter) string",
"GetVisibleText(TextIter) string",
"HasTag(TextTag) bool",
"InRange(TextIter, TextIter) bool",
"InsideSentence() bool",
"InsideWord() bool",
"IsCursorPosition() bool",
"IsEnd() bool",
"IsStart() bool",
"SetLine(int)",
"SetLineIndex(int)",
"SetLineOffset(int)",
"SetOffset(int)",
"SetVisibleLineIndex(int)",
"SetVisibleLineOffset(int)",
"StartsLine() bool",
"StartsSentence() bool",
"StartsWord() bool",
"TogglesTag(TextTag) bool"
]
$PRIMITIVES = {
"bool" => "false",
"int" => "0",
"string" => "\"\"",
"rune" => "0",
}
def parse(s)
name, args, rets = /^(.*?)\((.*?)\)(?: ?(.*?))$/.match(s).captures
{
name: name,
args: args.split(", "),
rets: rets
}
end
def mapType(tt)
if $PRIMITIVES[tt]
tt
else
"gtki.#{tt}"
end
end
def argList(args)
args.map{ |x|
"#{mapType(x)}"
}.join(", ")
end
def returnList(rets)
if rets == ""
""
else
" #{mapType(rets)}"
end
end
def potentialReturn(rets)
if rets == ""
""
else
if $PRIMITIVES[rets]
"return #{$PRIMITIVES[rets]}"
else
"return nil"
end
end
end
all.each do |xx|
res = parse(xx)
puts <<END
func (*MockTextIter) #{res[:name]}(#{argList(res[:args])})#{returnList(res[:rets])} {
#{potentialReturn(res[:rets])}
}
END
end
|