-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
395 additions
and
108 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,4 @@ | ||
|
||
|
||
# | ||
# |
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
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,42 @@ | ||
from dataclasses import dataclass | ||
from typing import Any, Optional | ||
from enum import Enum | ||
|
||
|
||
class ErrorCode(Enum): | ||
# -32768 to -32000 are reserved for pre-defined errors | ||
ParseError = -32700 | ||
InvalidRequest = -32600 | ||
MethodNotFound = -32601 | ||
InvalidParams = -32602 | ||
InternalError = -32603 | ||
# -32000 to -32099 | ||
|
||
|
||
@dataclass | ||
class Request: | ||
id: Optional[int | str] # if it is not included it is assumed to be a notification | ||
method: str # "rpc.(.*)" names a reserved | ||
params: Optional[Any] | ||
jsonrpc: str = "2.0" | ||
|
||
|
||
@dataclass | ||
class Error: | ||
code: int | ||
message: str | ||
data: Optional[Any] | ||
|
||
|
||
@dataclass | ||
class Response: | ||
id: int | ||
result: Optional[Any] | ||
error: Optional[Error] | ||
jsonrpc: str = "2.0" | ||
|
||
|
||
|
||
# protobuf | ||
# json | ||
# msgpack |
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
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 |
---|---|---|
@@ -1,13 +1,44 @@ | ||
#include "dtypes.h" | ||
#include "ast/nodes.h" | ||
#include "utilities/names.h" | ||
|
||
namespace lython { | ||
template <> | ||
struct meta::ReflectionTrait<MyStruct1> { | ||
static int register_members() { | ||
meta::register_property<&MyStruct1::b>("b"); | ||
return 1; | ||
} | ||
}; | ||
} | ||
#include "ast/nodes.h" | ||
#include "dtypes.h" | ||
#include "utilities/names.h" | ||
|
||
#if KMETA_PROCESSING | ||
#define KMETA(...) __attribute__((annotate(#__VA_ARGS__))) | ||
#else | ||
#define KMETA(...) | ||
#endif | ||
|
||
#define KCLASS(...) KMETA(class, __VA_ARGS__) | ||
#define KSTRUCT(...) KMETA(struct, __VA_ARGS__) | ||
#define KPROPERTY(...) KMETA(proprety, __VA_ARGS__) | ||
#define KFUNCTION(...) KMETA(function, __VA_ARGS__) | ||
#define KIGNORE(...) KMETA(__VA_ARGS__, reflected = 0) | ||
|
||
struct KSTRUCT(a, b, c) MyStruct1 { | ||
|
||
int a; | ||
|
||
KPROPERTY(FirstFlag, SomeValue = Elaborate, SecondFlag) | ||
int b; | ||
|
||
KPROPERTY(reflected = 0, SomeValue = Elaborate, SecondFlag) | ||
int d; | ||
|
||
int c; | ||
|
||
KFUNCTION() | ||
void fun() {} | ||
}; | ||
|
||
namespace lython { | ||
template <> | ||
struct meta::ReflectionTrait<MyStruct1> { | ||
static int register_members() { | ||
meta::register_member<&MyStruct1::a>("a"); | ||
meta::register_member<&MyStruct1::b>("b"); | ||
meta::register_member<&MyStruct1::c>("c"); | ||
meta::register_member<&MyStruct1::fun>("fun"); | ||
return 1; | ||
} | ||
}; | ||
} // namespace lython |
Oops, something went wrong.