Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libuv Asys Implementation #1022

Draft
wants to merge 164 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
1a1f012
Initial libuv asys integration
Aidan63 Dec 10, 2022
a840f08
Split into separate files
Aidan63 Dec 10, 2022
ec2236a
File open, read, write, and close
Aidan63 Dec 22, 2022
d0767b4
Simplify request structs with a shared base
Aidan63 Dec 22, 2022
917e587
Implement file info
Aidan63 Dec 22, 2022
4c8b663
Implement file flush
Aidan63 Dec 22, 2022
ab7ad59
Implement file resize
Aidan63 Dec 22, 2022
d368599
Implement ownership and times functions
Aidan63 Dec 22, 2022
bed3679
Return an "anonymous" enum for file errors
Aidan63 Dec 23, 2022
790ef9d
Utils header for shared functions
Aidan63 Dec 24, 2022
4486cb5
Directory opening, reading, and closing
Aidan63 Dec 24, 2022
4147483
Temp file
Aidan63 Dec 25, 2022
2b6d090
chunked writes
Aidan63 Dec 26, 2022
b4cf5c6
Don't use fixed fields for stat object
Aidan63 Dec 27, 2022
a3f4a2e
chunked reads
Aidan63 Dec 27, 2022
c4cd35e
Fix bad chunked read logic
Aidan63 Dec 27, 2022
8d02df1
try and make gcc and clang happy
Aidan63 Jan 1, 2023
324400e
Add missing template type
Aidan63 Jan 1, 2023
451a926
Implement directory creation
Aidan63 Jan 1, 2023
6a3847a
access check
Aidan63 Jan 10, 2023
36e1e7a
delete file and directory
Aidan63 Jan 12, 2023
2776c06
File and directory checks
Aidan63 Jan 12, 2023
a78d308
Reduce duplicated callbacks
Aidan63 Jan 12, 2023
1f9b831
Link functions
Aidan63 Jan 13, 2023
a955bbc
Fixed fields for info anon object
Aidan63 Jan 13, 2023
5b2b943
Try make gcc happy
Aidan63 Jan 14, 2023
76d86e3
Implement link info and reading
Aidan63 Jan 14, 2023
6da8835
Copy file
Aidan63 Jan 14, 2023
4f8834f
Implement real path
Aidan63 Jan 14, 2023
435072f
Dns resolution and Ip address printing
Aidan63 Jan 15, 2023
cc34e7a
Dns reverse
Aidan63 Jan 15, 2023
79bc76f
Namespace re-shuffle
Aidan63 Jan 15, 2023
74f0acc
more code re-use
Aidan63 Jan 15, 2023
0184d6d
Initial socket connect and write function
Aidan63 Jan 17, 2023
f101666
Socket read queue
Aidan63 Jan 21, 2023
4b5aa4b
Typedef raw ip address representations
Aidan63 Jan 21, 2023
7a352f4
ipv4 and v6 socket connect
Aidan63 Jan 21, 2023
0453bb3
Move socket out of tcp namespace
Aidan63 Jan 21, 2023
f001632
Named socket connection
Aidan63 Jan 21, 2023
b4c1aa4
get the local and remote address for sockets
Aidan63 Jan 22, 2023
4f87569
Initial work on tcp server
Aidan63 Apr 9, 2023
53cc1bb
name and peer as member fields, not functions
Aidan63 Apr 9, 2023
0f98e8e
break out stream reading and writing for future re-use
Aidan63 Apr 9, 2023
fd7b1ec
unique_ptr some more for auto memory cleanup
Aidan63 Apr 9, 2023
af7f5e0
ipv6 and ipc server impl
Aidan63 Apr 9, 2023
212b779
Made socket read a bit more reasonable
Aidan63 Apr 10, 2023
7069715
local address of server
Aidan63 Apr 10, 2023
c512704
Add virtual destructor to base request
Aidan63 Apr 10, 2023
cb5947c
Update file writing to be stored in namespace like networking code
Aidan63 Apr 10, 2023
daaa08b
socket get and set options
Aidan63 Apr 10, 2023
0fc73b3
Apply options to socket on connection
Aidan63 Apr 11, 2023
fefb156
Implement initial options for server
Aidan63 Apr 11, 2023
cffc1c6
get and set option for server
Aidan63 Apr 11, 2023
957240d
Go back to using non fixed fields for file stat
Aidan63 Apr 11, 2023
3ad136d
Chunked stream writer
Aidan63 Apr 11, 2023
6c2188e
stream writer flushing
Aidan63 Apr 11, 2023
94acbcd
Merge branch 'master' into asys
Aidan63 Apr 12, 2023
0bd5fe2
Initial process opening
Aidan63 Oct 1, 2023
d77cf68
pid and exit code checking
Aidan63 Oct 1, 2023
e114bbf
Implement child process closing
Aidan63 Oct 3, 2023
2e36a59
Inherit and ignore stdio
Aidan63 Oct 4, 2023
5f8155b
Merge branch 'master' into asys
Aidan63 Oct 21, 2023
c248a07
Go back to having process objects be hx::Objects
Aidan63 Oct 22, 2023
4ae2406
Use class declaration macros for readable, writable, and duplex abstr…
Aidan63 Oct 22, 2023
cb97ba9
Initial child process stdout reading
Aidan63 Oct 22, 2023
31ae9df
stderr and stdin
Aidan63 Oct 22, 2023
2156510
pipe to file
Aidan63 Oct 23, 2023
7b0a64f
Initial signal sending
Aidan63 Nov 1, 2023
6917b05
posix send codes
Aidan63 Nov 1, 2023
ce8e2cc
Current process pid
Aidan63 Nov 1, 2023
fa144b8
Current process class
Aidan63 Nov 2, 2023
ee26d8a
current process send signal
Aidan63 Nov 3, 2023
012bd2f
current process stdio reading and writing
Aidan63 Nov 5, 2023
cabbd8b
GC lifetime management
Aidan63 Nov 5, 2023
4edd09b
set signal handler
Aidan63 Nov 25, 2023
24e3855
simplify action request
Aidan63 Nov 26, 2023
f4db1ab
Implement default signal action
Aidan63 Nov 26, 2023
6808338
Implement ignoring
Aidan63 Nov 26, 2023
bd6ab3f
Fix missing IsDirectory error mapping
Aidan63 Nov 27, 2023
9dd75bd
Fix crash due to not converting libuv error code to error enum
Aidan63 Dec 6, 2023
23a3fe2
Set path for directory object
Aidan63 Dec 6, 2023
980c37f
Better implementation of directory creation
Aidan63 Dec 9, 2023
7d59b48
change "move" to "rename" to better reflect what it actually does
Aidan63 Dec 16, 2023
89c1bce
Use lstat for isLink
Aidan63 Dec 18, 2023
145f430
Various fixes for different compilers and a quick c++17 bodge
Aidan63 Dec 21, 2023
df27d14
static cast the fd to a uv_file
Aidan63 Dec 21, 2023
29070f1
Remove now unneeded c++ write batching
Aidan63 Dec 23, 2023
d1f37c8
new FsRequest
Aidan63 Dec 23, 2023
509da2f
All file ops use new FsRequest
Aidan63 Dec 23, 2023
8affe02
Directory uses new FsRequest
Aidan63 Dec 24, 2023
a6743e8
Pre-allocate entries array
Aidan63 Dec 24, 2023
1c94434
libuv version bump
Aidan63 Dec 24, 2023
dbeba7e
expose MemType enum and check function in the hx namespace
Aidan63 Jan 3, 2024
6aa7313
Revert "expose MemType enum and check function in the hx namespace"
Aidan63 Jan 5, 2024
c1b1bf0
Change to a pin set
Aidan63 Jan 6, 2024
ec93703
Merge branch 'public_memtype' into asys
Aidan63 Jan 6, 2024
90e674f
new TcpServer class
Aidan63 Jan 27, 2024
2df7704
Mark and visit local address
Aidan63 Jan 27, 2024
6c7d39a
No more duplex inheritance (for now)
Aidan63 Jan 27, 2024
ca664b2
tcp socket reader
Aidan63 Jan 27, 2024
73de086
working socket writes
Aidan63 Jan 27, 2024
3f29803
implement socket getter and setter
Aidan63 Jan 27, 2024
6ecf5e5
move address anon making into the net utils file
Aidan63 Jan 27, 2024
b4164fc
Restore socket connection
Aidan63 Jan 28, 2024
9738335
Merge branch 'new_sockets' into asys
Aidan63 Jan 28, 2024
4457dd4
Split up mega LibuvTcp.cpp file
Aidan63 Feb 4, 2024
c28b78e
default backlog of 0
Aidan63 Feb 4, 2024
f90e353
re-save files as utf8
Aidan63 Feb 4, 2024
75ccc18
Fix linux compilation
Aidan63 Feb 14, 2024
7bf4fb5
Default backlog of 1, not 0
Aidan63 Feb 14, 2024
925a707
Add basic coroutine class
Aidan63 Feb 14, 2024
6623f2f
Fix backlog assignment not working
Aidan63 Feb 23, 2024
ade05b7
initial schannel handshake
Aidan63 Feb 24, 2024
fa8e0a8
Use SCH_CREDENTIALS
Aidan63 Feb 25, 2024
c124641
Encoding data
Aidan63 Feb 25, 2024
ee662b2
Handshake callback method
Aidan63 Feb 25, 2024
f469814
startHandshake callback method
Aidan63 Feb 25, 2024
40fa171
Decoding data
Aidan63 Feb 25, 2024
c37780e
Ignore EALREADY error when starting reading
Aidan63 Feb 25, 2024
ddbb5b6
closing session
Aidan63 Feb 25, 2024
c7af55e
abstract schannel behind secure channel class
Aidan63 Feb 26, 2024
1519b84
support toggling certificate verification
Aidan63 Feb 26, 2024
57840ac
GC WB
Aidan63 Feb 26, 2024
099952a
tty reshuffle
Aidan63 Mar 2, 2024
711416b
maybe more sane signal handling?
Aidan63 Mar 20, 2024
b2847c9
Non virtual inheritance for streams
Aidan63 Mar 22, 2024
f076ffb
stream readers revamp
Aidan63 Mar 23, 2024
2da338c
Fix stderr pipe replacing stdout pipe
Aidan63 Mar 25, 2024
e9e10f6
Move alloc and read lambdas into static functions
Aidan63 Mar 25, 2024
88ef7cb
Fix process environment variables not applying
Aidan63 Mar 26, 2024
bc779ba
bring back some lost ipc stuff
Aidan63 Mar 28, 2024
af82499
Fix broken server connection accept
Aidan63 Mar 28, 2024
5ffbdc2
maybe this is how server options are supposed to be used???
Aidan63 Mar 28, 2024
d3f012b
greatly reduce complexity of the asys context
Aidan63 Mar 29, 2024
9723c9e
Apply socket options when connecting
Aidan63 Mar 30, 2024
179ce1c
Use standard pointers for now
Aidan63 Mar 30, 2024
0362f2d
Revert "Use standard pointers for now"
Aidan63 Mar 30, 2024
ef4a87e
"better" management of native process objects
Aidan63 Mar 30, 2024
98b9889
std::array with at?
Aidan63 Mar 30, 2024
78bf9e8
Correctly cleanup child process context
Aidan63 Mar 30, 2024
1773d6d
Correctly get the address of the stream context
Aidan63 Mar 30, 2024
80a54b9
schannel compiles in /permissive- mode
Aidan63 Mar 31, 2024
32294da
don't release any memory (for now)
Aidan63 Mar 31, 2024
45838a3
Revert previously thought mistake
Aidan63 Mar 31, 2024
edd87e6
return if starting to read fails
Aidan63 Mar 31, 2024
2238766
Call success callback in stream reader close
Aidan63 Mar 31, 2024
efea4f7
emplace back for stream reader alloc
Aidan63 Mar 31, 2024
55c76ad
leak process memory (for now)
Aidan63 Mar 31, 2024
f62639f
Ensure tcp connect request is cleaned up in the failure case
Aidan63 Mar 31, 2024
23f2437
Ensure tcp server is cleaned up in failure cases
Aidan63 Mar 31, 2024
6fbf7bf
Add forgotten gc zone to server failure cleanup function
Aidan63 Mar 31, 2024
5d154ec
Re-work memory management of tcp server and sockets
Aidan63 Apr 1, 2024
7a61f2b
Merge branch 'master' into asys
Aidan63 Jun 21, 2024
d0749b9
use new recommended process flag on windows
Aidan63 Jun 23, 2024
84fc3d6
not sure why I commented this out
Aidan63 Jun 23, 2024
d8d9335
Update libuv
Aidan63 Jun 23, 2024
9be8202
Merge branch 'master' into asys
Aidan63 Jun 25, 2024
75fbe74
avoid multiple inheritance in stream reader context
Aidan63 Jul 20, 2024
a9dca32
Merge branch 'master' into asys
Aidan63 Jul 27, 2024
f90043b
static file info, less utf8_str, and simpler directory create
Aidan63 Aug 24, 2024
c00a22d
custom requests for dns functions
Aidan63 Aug 24, 2024
7b1b04d
Don't inherit from duplex for sockets
Aidan63 Aug 25, 2024
a0bb7f2
tty and process stdio
Aidan63 Aug 26, 2024
0dffc2a
custom deleter to avoid uv_close repetition in tcp socket
Aidan63 Aug 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
419 changes: 419 additions & 0 deletions .gitignore

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions include/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ class ArrayKeyValueIterator : public cpp::FastIterator_obj<Dynamic>

namespace hx
{
#if (HXCPP_API_LEVEL>=430)
class HXCPP_EXTERN_CLASS_ATTRIBUTES ArrayPin
{
char* ptr;
public:
ArrayPin(char* inPtr);

~ArrayPin();

char* GetBase();
};
#endif

// Also used by cpp::VirtualArray
class HXCPP_EXTERN_CLASS_ATTRIBUTES ArrayCommon : public hx::Object
Expand Down Expand Up @@ -190,6 +202,9 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES ArrayBase : public ArrayCommon
mAlloc = -1;
}

#if (HXCPP_API_LEVEL>=430)
ArrayPin* Pin();
#endif

int __GetType() const { return vtArray; }

Expand Down
52 changes: 52 additions & 0 deletions include/hx/Coroutine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once

#include <hxcpp.h>

namespace hx
{
struct Coroutine
{
static Dynamic suspend(Dynamic f, Dynamic cont)
{
struct SuspendCaller final : public hx::Object
{
Dynamic f;
Dynamic cont;

SuspendCaller(Dynamic inF, Dynamic inCont) : f(inF), cont(inCont)
{
HX_OBJ_WB_NEW_MARKED_OBJECT(this);
}

Dynamic HX_LOCAL_RUN()
{
return f(cont);
}

Dynamic __run(const Dynamic&, const Dynamic&) override
{
return HX_LOCAL_RUN();
}

Dynamic __Run(const Array<Dynamic>& args) override
{
return HX_LOCAL_RUN();
}

void __Mark(hx::MarkContext* __inCtx) override
{
HX_MARK_MEMBER(__inCtx);
}

#ifdef HXCPP_VISIT_ALLOCS
void __Visit(hx::VisitContext* __inCtx) override
{
HX_VISIT_MEMBER(__inCtx);
}
#endif
};

return new SuspendCaller(f, cont);
}
};
}
33 changes: 33 additions & 0 deletions include/hx/GC.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ void MarkConservative(int *inBottom, int *inTop,hx::MarkContext *__inCtx);
void GCAddRoot(hx::Object **inRoot);
void GCRemoveRoot(hx::Object **inRoot);

#if (HXCPP_API_LEVEL>=430)
void GCPinPtr(void* inPtr);
void GCUnpinPtr(void* inPtr);
#endif

// This is used internally in hxcpp
// It calls InternalNew, and takes care of null-terminating the result
Expand Down Expand Up @@ -232,6 +236,35 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES AutoGCFreeZone
bool locked;
};

class HXCPP_EXTERN_CLASS_ATTRIBUTES AutoGCZone
{
private:
bool open;

public:
AutoGCZone() : open(true) { ExitGCFreeZone(); }
~AutoGCZone() { if(open) { EnterGCFreeZone(); } }
};

template<class THxObject = hx::Object>
class HXCPP_EXTERN_CLASS_ATTRIBUTES RootedObject
{
public:
THxObject* rooted;

RootedObject(THxObject* object) : rooted(object) { GCAddRoot(reinterpret_cast<hx::Object**>(&rooted)); }
~RootedObject() { GCRemoveRoot(reinterpret_cast<hx::Object**>(&rooted)); }
};

template<>
class HXCPP_EXTERN_CLASS_ATTRIBUTES RootedObject<hx::Object>
{
public:
hx::Object* rooted;

RootedObject(hx::Object* object) : rooted(object) { GCAddRoot(&rooted); }
~RootedObject() { GCRemoveRoot(&rooted); }
};

// Defined in Class.cpp, these function is called from the Gc to start the marking/visiting
void MarkClassStatics(hx::MarkContext *__inCtx);
Expand Down
257 changes: 257 additions & 0 deletions include/hx/asys/Asys.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
#pragma once

#include <cstdint>

HX_DECLARE_CLASS2(hx, asys, Context)
HX_DECLARE_CLASS2(hx, asys, Writable)
HX_DECLARE_CLASS2(hx, asys, Readable)
HX_DECLARE_CLASS3(hx, asys, filesystem, File)
HX_DECLARE_CLASS3(hx, asys, filesystem, Directory)
HX_DECLARE_CLASS3(hx, asys, net, TcpServer)
HX_DECLARE_CLASS3(hx, asys, net, TcpSocket)
HX_DECLARE_CLASS3(hx, asys, net, SecureSession)
HX_DECLARE_CLASS3(hx, asys, net, IpcSocket)
HX_DECLARE_CLASS3(hx, asys, system, Process)
HX_DECLARE_CLASS3(hx, asys, system, CurrentProcess)
HX_DECLARE_CLASS3(hx, asys, system, ChildProcess)

namespace hx
{
namespace asys
{
using Ipv4Address = int;
using Ipv6Address = Array<uint8_t>;
using Pid = int;

class Context_obj : public Object
{
protected:
Context_obj(system::CurrentProcess _process) : process(_process) {}

public:
static Context create();

const system::CurrentProcess process;

virtual bool loop() = 0;
virtual void close() = 0;
};

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

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

namespace filesystem
{
enum class FileAccessMode : std::uint8_t
{
exists = 0b0001,
executable = 0b0010,
writable = 0b0100,
readable = 0b1000
};

class File_obj : public Object
{
public:
static void open(Context ctx, String path, int flags, Dynamic cbSuccess, Dynamic cbFailure);
static void temp(Context ctx, Dynamic cbSuccess, Dynamic cbFailure);
static void info(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);

const String path;

File_obj(String _path) : path(_path) {}

virtual void write(::cpp::Int64 pos, Array<uint8_t> data, int offset, int length, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void read(::cpp::Int64 pos, Array<uint8_t> output, int offset, int length, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void info(Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void resize(int size, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void setPermissions(int permissions, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void setOwner(int user, int group, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void setTimes(int accessTime, int modificationTime, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void flush(Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;
};

class Directory_obj : public Object
{
public:
const String path;

Directory_obj(String _path) : path(_path) {}

static void open(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);
static void create(Context ctx, String path, int permissions, Dynamic cbSuccess, Dynamic cbFailure);
static void rename(Context ctx, String oldPath, String newPath, Dynamic cbSuccess, Dynamic cbFailure);
static void check(Context ctx, String path, FileAccessMode accessMode, Dynamic cbSuccess, Dynamic cbFailure);
static void deleteFile(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);
static void deleteDirectory(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);
static void isDirectory(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);
static void isFile(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);
static void isLink(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);
static void setLinkOwner(Context ctx, String path, int user, int group, Dynamic cbSuccess, Dynamic cbFailure);
static void link(Context ctx, String target, String path, int type, Dynamic cbSuccess, Dynamic cbFailure);
static void linkInfo(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);
static void readLink(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);
static void copyFile(Context ctx, String source, String destination, bool overwrite, Dynamic cbSuccess, Dynamic cbFailure);
static void realPath(Context ctx, String path, Dynamic cbSuccess, Dynamic cbFailure);

virtual void next(int batch, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;
};
}

namespace net
{
namespace dns
{
void resolve(Context ctx, const String host, Dynamic cbSuccess, Dynamic cbFailure);
void reverse(Context ctx, const Ipv4Address ip, Dynamic cbSuccess, Dynamic cbFailure);
void reverse(Context ctx, const Ipv6Address ip, Dynamic cbSuccess, Dynamic cbFailure);
}

namespace ip
{
hx::EnumBase parse(const String ip);
String name(const Ipv4Address ip);
String name(const Ipv6Address ip);
}

class TcpServer_obj : public Object
{
public:
hx::Anon localAddress;

static void open_ipv4(Context ctx, const String host, int port, Dynamic options, Dynamic cbSuccess, Dynamic cbFailure);
static void open_ipv6(Context ctx, const String host, int port, Dynamic options, Dynamic cbSuccess, Dynamic cbFailure);

virtual void accept(Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;

virtual void getKeepAlive(Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void getSendBufferSize(Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void getRecvBufferSize(Dynamic cbSuccess, Dynamic cbFailure) = 0;

virtual void setKeepAlive(bool keepAlive, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void setSendBufferSize(int size, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void setRecvBufferSize(int size, Dynamic cbSuccess, Dynamic cbFailure) = 0;
};

class TcpSocket_obj : public Object
{
public:
hx::Anon localAddress;
hx::Anon remoteAddress;

Writable writer;
Readable reader;

static void connect_ipv4(Context ctx, const String host, int port, Dynamic options, Dynamic cbSuccess, Dynamic cbFailure);
static void connect_ipv6(Context ctx, const String host, int port, Dynamic options, Dynamic cbSuccess, Dynamic cbFailure);

virtual void getKeepAlive(Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void getSendBufferSize(Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void getRecvBufferSize(Dynamic cbSuccess, Dynamic cbFailure) = 0;

virtual void setKeepAlive(bool keepAlive, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void setSendBufferSize(int size, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void setRecvBufferSize(int size, Dynamic cbSuccess, Dynamic cbFailure) = 0;

virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;
};

class SecureSession_obj : public Object
{
public:
virtual void encode(Array<uint8_t> input, int offset, int length, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void decode(Array<uint8_t> input, int offset, int length, Dynamic cbSuccess, Dynamic cbFailure) = 0;
virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;

static void authenticateAsClient(TcpSocket socket, String host, Dynamic options, Dynamic cbSuccess, Dynamic cbFailure);
};

class IpcSocket_obj : public Object
{
public:
String socketName;
String peerName;

Writable writer;
Readable reader;

static void bind(Context ctx, String name, Dynamic cbSuccess, Dynamic cbFailure);
static void connect(Context ctx, String name, Dynamic cbSuccess, Dynamic cbFailure);

virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;
};

// class UdpSocket_obj : public Object
// {
// public:
// const hx::Anon localAddress;
// const hx::Anon remoteAddress;

// static void open(Context ctx, const String& host, int port, Dynamic options, Dynamic cbSuccess, Dynamic cbFailure);

// virtual void bind(const String& host, int port, Dynamic cbSuccess, Dynamic cbFailure) = 0;
// virtual void unbind(Dynamic cbSuccess, Dynamic cbFailure) = 0;
// virtual void write(Array<uint8_t> data, int offset, int length, const String& host, int port, Dynamic cbSuccess, Dynamic cbFailure) = 0;
// virtual void read(Array<uint8_t> output, int offset, int length, Dynamic cbSuccess, Dynamic cbFailure) = 0;
// virtual void close(Dynamic cbSuccess, Dynamic cbFailure) = 0;
// };
}

namespace system
{
class Process_obj : public Object
{
public:
static void open(Context ctx, String command, hx::Anon options, Dynamic cbSuccess, Dynamic cbFailure);

virtual Pid pid() = 0;

virtual void sendSignal(hx::EnumBase signal, Dynamic cbSuccess, Dynamic cbFailure) = 0;
};

class ChildProcess_obj : public Process_obj
{
public:
ChildProcess_obj(Writable _stdio_in, Readable _stdio_out, Readable _stdio_err)
: stdio_in(_stdio_in)
, stdio_out(_stdio_out)
, stdio_err(_stdio_err) {}

Writable stdio_in;
Readable stdio_out;
Readable stdio_err;

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

class CurrentProcess_obj : public Process_obj
{
public:
CurrentProcess_obj(Readable _stdio_in, Writable _stdio_out, Writable _stdio_err)
: stdio_in(_stdio_in)
, stdio_out(_stdio_out)
, stdio_err(_stdio_err) {}

virtual void setSignalAction(hx::EnumBase signal, hx::EnumBase action) = 0;

Readable stdio_in;
Writable stdio_out;
Writable stdio_err;
};
}
}
}
Loading