This repository has been archived by the owner on Mar 1, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: WebFreak001 <[email protected]> Conflicts: source/com/dub.d
- Loading branch information
Showing
8 changed files
with
901 additions
and
677 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module workspaced.api; | ||
|
||
import std.conv; | ||
import std.json; | ||
import painlessjson; | ||
|
||
/// | ||
alias AsyncCallback = void delegate(Throwable, JSONValue); | ||
|
||
/// Will get called asynchronously (Must prepend AsyncCallback as argument) | ||
enum async = 2603248026; | ||
|
||
/// Will get called for loading components | ||
enum load = 2603248027; | ||
|
||
/// Will get called for unloading components | ||
enum unload = 2603248028; | ||
|
||
/// Will call this function in any case (cmd: component) | ||
enum any = 2603248029; | ||
|
||
/// Component call | ||
struct component | ||
{ | ||
/// Name of the component | ||
string name; | ||
} | ||
|
||
/// Will get called when some argument matches | ||
struct Arguments | ||
{ | ||
/// Arguments to match | ||
Argument[] arguments; | ||
} | ||
|
||
private struct Argument | ||
{ | ||
/// Key in JSON object node at root level to match | ||
string key; | ||
/// Value in JSON object node at root level to match | ||
JSONValue value; | ||
} | ||
|
||
private template ArgumentPair(size_t i) | ||
{ | ||
static if (i > 0) | ||
enum ArgumentPair = "ret.arguments[" ~ (i / 2 - 1).to!string ~ "] = Argument(args[" ~ (i - 2).to!string ~ "], args[" ~ (i - 1).to!string ~ "].toJSON);" ~ ArgumentPair!( | ||
i - 2); | ||
else | ||
enum ArgumentPair = ""; | ||
} | ||
|
||
Arguments arguments(T...)(T args) | ||
{ | ||
if (args.length < 2) | ||
return Arguments.init; | ||
Arguments ret; | ||
ret.arguments.length = args.length / 2; | ||
mixin(ArgumentPair!(args.length)); | ||
return ret; | ||
} | ||
|
||
unittest | ||
{ | ||
Arguments args = arguments("foo", 5, "bar", "str"); | ||
assert(args.arguments[0].key == "foo"); | ||
assert(args.arguments[0].value.integer == 5); | ||
assert(args.arguments[1].key == "bar"); | ||
assert(args.arguments[1].value.str == "str"); | ||
} | ||
|
||
alias ImportPathProvider = string[]function(); | ||
|
||
ImportPathProvider importPathProvider, stringImportPathProvider; |
Oops, something went wrong.