Skip to content

Commit

Permalink
Use class declaration macros for readable, writable, and duplex abstr…
Browse files Browse the repository at this point in the history
…acts
  • Loading branch information
Aidan63 committed Oct 22, 2023
1 parent c248a07 commit 4ae2406
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions include/hx/asys/Asys.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <cstdint>

HX_DECLARE_CLASS2(hx, asys, Context)
HX_DECLARE_CLASS2(hx, asys, Writable)
HX_DECLARE_CLASS2(hx, asys, Readable)
HX_DECLARE_CLASS2(hx, asys, Duplex)
HX_DECLARE_CLASS3(hx, asys, filesystem, File)
HX_DECLARE_CLASS3(hx, asys, filesystem, Directory)
HX_DECLARE_CLASS3(hx, asys, net, Socket)
Expand Down Expand Up @@ -30,19 +33,19 @@ namespace hx
virtual void loop() = 0;
};

struct Writable : virtual public Object
class Writable_obj : virtual public Object
{
virtual void write(Array<uint8_t> data, int offset, int length, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;
};

struct Readable : virtual public Object
class Readable_obj : virtual public Object
{
virtual void read(Array<uint8_t> output, int offset, int length, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;
};

struct Duplex : virtual public Writable, virtual public Readable
class Duplex_obj : virtual public Writable_obj, virtual public Readable_obj
{
//
};
Expand Down Expand Up @@ -118,7 +121,7 @@ namespace hx
String name(const Ipv6Address ip);
}

class Socket_obj : public Duplex
class Socket_obj : public Duplex_obj
{
protected:
Socket_obj(hx::EnumBase _name, hx::EnumBase _peer) : name(_name) , peer(_peer) {}
Expand Down Expand Up @@ -198,9 +201,9 @@ namespace hx
class ChildProcess_obj : public Process_obj
{
public:
hx::ObjectPtr<Readable> stdio_in;
hx::ObjectPtr<Writable> stdio_out;
hx::ObjectPtr<Writable> stdio_err;
Readable stdio_in;
Writable stdio_out;
Writable stdio_err;

virtual void exitCode(Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;
Expand Down

0 comments on commit 4ae2406

Please sign in to comment.