equal
deleted
inserted
replaced
195 |
195 |
196 trait Protocol |
196 trait Protocol |
197 { |
197 { |
198 /* protocol commands */ |
198 /* protocol commands */ |
199 |
199 |
200 def protocol_command_bytes(name: String, args: Bytes*): Unit |
200 def protocol_command_raw(name: String, args: List[Bytes]): Unit |
|
201 def protocol_command_args(name: String, args: List[String]) |
201 def protocol_command(name: String, args: String*): Unit |
202 def protocol_command(name: String, args: String*): Unit |
202 |
203 |
203 |
204 |
204 /* options */ |
205 /* options */ |
205 |
206 |
240 |
241 |
241 |
242 |
242 /* interned items */ |
243 /* interned items */ |
243 |
244 |
244 def define_blob(digest: SHA1.Digest, bytes: Bytes): Unit = |
245 def define_blob(digest: SHA1.Digest, bytes: Bytes): Unit = |
245 protocol_command_bytes("Document.define_blob", Bytes(digest.toString), bytes) |
246 protocol_command_raw("Document.define_blob", List(Bytes(digest.toString), bytes)) |
246 |
247 |
247 def define_command(command: Command) |
248 def define_command(command: Command) |
248 { |
249 { |
249 val blobs_yxml = |
250 val blobs_yxml = |
250 { |
251 { |
264 import XML.Encode._ |
265 import XML.Encode._ |
265 val encode_tok: T[Token] = (tok => pair(int, int)((tok.kind.id, Symbol.length(tok.source)))) |
266 val encode_tok: T[Token] = (tok => pair(int, int)((tok.kind.id, Symbol.length(tok.source)))) |
266 Symbol.encode_yxml(list(encode_tok)(toks)) |
267 Symbol.encode_yxml(list(encode_tok)(toks)) |
267 } |
268 } |
268 |
269 |
269 protocol_command("Document.define_command", |
270 protocol_command_args("Document.define_command", |
270 (Document_ID(command.id) :: Symbol.encode(command.span.name) :: blobs_yxml :: toks_yxml :: |
271 Document_ID(command.id) :: Symbol.encode(command.span.name) :: blobs_yxml :: toks_yxml :: |
271 toks.map(tok => Symbol.encode(tok.source))): _*) |
272 toks.map(tok => Symbol.encode(tok.source))) |
272 } |
273 } |
273 |
274 |
274 |
275 |
275 /* execution */ |
276 /* execution */ |
276 |
277 |
312 (bool_atom(a) :: b.commands.map(cmd => long_atom(cmd.id)), |
313 (bool_atom(a) :: b.commands.map(cmd => long_atom(cmd.id)), |
313 list(pair(id, pair(string, list(string))))(c.dest)) })) |
314 list(pair(id, pair(string, list(string))))(c.dest)) })) |
314 edits.map({ case (name, edit) => |
315 edits.map({ case (name, edit) => |
315 Symbol.encode_yxml(pair(string, encode_edit(name))(name.node, edit)) }) |
316 Symbol.encode_yxml(pair(string, encode_edit(name))(name.node, edit)) }) |
316 } |
317 } |
317 protocol_command("Document.update", |
318 protocol_command_args("Document.update", |
318 (Document_ID(old_id) :: Document_ID(new_id) :: consolidate_yxml :: edits_yxml): _*) |
319 Document_ID(old_id) :: Document_ID(new_id) :: consolidate_yxml :: edits_yxml) |
319 } |
320 } |
320 |
321 |
321 def remove_versions(versions: List[Document.Version]) |
322 def remove_versions(versions: List[Document.Version]) |
322 { |
323 { |
323 val versions_yxml = |
324 val versions_yxml = |