-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Lib passes a SmlFrameSnippet to the builder
- Loading branch information
-
committed
Oct 20, 2021
1 parent
3d42c10
commit 149f11a
Showing
15 changed files
with
338 additions
and
218 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 |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.8' | ||
__version__ = '0.9' |
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
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
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,17 @@ | ||
from typing import Optional, Union | ||
|
||
|
||
class SmlFrameSnippet: | ||
__slots__ = ('pos', 'value', 'msg') | ||
|
||
def __init__(self, value: Union[None, bool, int, str, float, list], start: int, | ||
stop: Optional[int] = None, buf: Optional[memoryview] = None): | ||
self.value = value | ||
|
||
self.pos = start | ||
self.msg: Optional[memoryview] = None if stop is None else buf[start: stop] | ||
|
||
def stop_pos(self, pos: int, buf: memoryview) -> 'SmlFrameSnippet': | ||
assert self.msg is None | ||
self.msg = buf[self.pos: pos] | ||
return self |
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
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,13 @@ | ||
from smllib.sml_frame import SmlFrameSnippet | ||
|
||
|
||
def in_snip(obj, pack_top = True) -> SmlFrameSnippet: | ||
if not isinstance(obj, (list, tuple)): | ||
return SmlFrameSnippet(obj, 'from in_snip') | ||
|
||
for i, k in enumerate(obj): | ||
obj[i] = in_snip(k) | ||
|
||
if pack_top: | ||
return SmlFrameSnippet(obj, 'from in_snip') | ||
return obj |
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
Oops, something went wrong.