Skip to content

Commit

Permalink
add a base class for jdwp structs
Browse files Browse the repository at this point in the history
  • Loading branch information
michalgr committed Dec 4, 2023
1 parent 669f917 commit df7db48
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions projects/jdwp/runtime/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ python_library(
srcs = [
":type-aliases",
"async_streams.py",
"jdwpstruct.py",
],
visibility = ["PUBLIC", ],
deps = [],
Expand Down
20 changes: 20 additions & 0 deletions projects/jdwp/runtime/jdwpstruct.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.

from __future__ import annotations

import abc
from projects.jdwp.runtime.async_streams import (
JDWPInputStreamBase,
JDWPOutputStreamBase,
)


class JDWPStruct(abc.ABC):
@abc.abstractmethod
async def serialize(self, output: JDWPOutputStreamBase):
pass

@staticmethod
@abc.abstractmethod
async def parse(input: JDWPInputStreamBase) -> JDWPStruct:
pass
1 change: 1 addition & 0 deletions projects/jdwp/tests/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python_test(
deps = [
"//projects/jdwp/defs:defs",
"//projects/jdwp/codegen:codegen",
"//projects/jdwp/runtime:runtime",
],
srcs = glob(["**/*.py"]),
)
8 changes: 8 additions & 0 deletions projects/jdwp/tests/runtime/jdwpstruct.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.

import unittest


class JDWPStructTest(unittest.TestCase):
def test_jdwpstruct_can_be_imported(self):
from projects.jdwp.runtime.jdwpstruct import JDWPStruct

0 comments on commit df7db48

Please sign in to comment.