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

asys #8817

Closed
Closed

asys #8817

Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
bec9818
libuv stubs, most fs functions
Aurel300 Jul 18, 2019
d68cb64
stat
Aurel300 Jul 18, 2019
b5ab085
fix linking
Aurel300 Jul 18, 2019
7929a23
initial eval code (FileSystem.exists)
Aurel300 Jul 18, 2019
0d81028
first async function, callbacks into Haxe
Aurel300 Jul 19, 2019
05aae0e
improve error handling, more fs work
Aurel300 Jul 22, 2019
eb2d506
report positions in errors
Aurel300 Jul 23, 2019
9af1f9e
less segfaulting, fs watchers, some cleanup and docs
Aurel300 Jul 24, 2019
b4d94d5
more cleanup and docs
Aurel300 Jul 24, 2019
61741df
move uv constants out, simplify stat
Aurel300 Jul 24, 2019
03018ce
close handles properly
Aurel300 Jul 25, 2019
f779f6f
tcp work
Aurel300 Jul 26, 2019
c0f2eb2
TCP, DNS, timers
Aurel300 Aug 6, 2019
3786432
socket options, fix connect
Aurel300 Aug 6, 2019
8ab1bc8
return DNS and scandir results in correct order
Aurel300 Aug 7, 2019
141c67f
unref timers
Aurel300 Aug 7, 2019
cb66ce2
async file operations
Aurel300 Aug 8, 2019
d1f08dc
TCP get(sock|peer)name
Aurel300 Aug 9, 2019
150d11c
read/write -> readBuffer/writeBuffer
Aurel300 Aug 12, 2019
7b379ec
udp stubs
Aurel300 Aug 12, 2019
b211f6b
UDP
Aurel300 Aug 13, 2019
3fded3b
allow run with any mode
Aurel300 Aug 15, 2019
3a0bbea
process stubs
Aurel300 Aug 15, 2019
4e1d1fd
process stdlib
Aurel300 Aug 15, 2019
ede92a0
ref, unref, less code that just casts handles
Aurel300 Aug 16, 2019
4dc047c
pipes
Aurel300 Aug 19, 2019
b7591e7
process close
Aurel300 Aug 19, 2019
2c26275
better pipes and streams
Aurel300 Aug 20, 2019
25e842b
get IPC name
Aurel300 Aug 20, 2019
66beabc
ref/unref UDP sockets
Aurel300 Aug 20, 2019
211e6ee
pass handles via pipes
Aurel300 Aug 21, 2019
4782ace
move to asys package
Aurel300 Sep 9, 2019
0d8bf4a
minor fixes
Aurel300 Sep 16, 2019
6a24d1b
fix dune
Aurel300 Sep 16, 2019
16306c1
macros for allocating/freeing requests
Aurel300 Sep 16, 2019
4da20b8
Merge branch 'development' into feature/eval-libuv
Simn Sep 18, 2019
842dc16
[ci] setup Windows
Simn Sep 19, 2019
61b33de
Merge branch 'development' into feature/eval-libuv
Simn Sep 19, 2019
9f9e810
bring back Sys inclusion hack
Simn Sep 19, 2019
db0d9a0
womp womp
Simn Sep 19, 2019
831123c
fix Std.hx
Simn Sep 19, 2019
6678277
[ci] setup Linux and OS X
Simn Sep 19, 2019
6809c38
[std] add missing get_message
Simn Sep 19, 2019
de2b204
add asys Haxe APIs, asys test suite
Aurel300 Sep 19, 2019
0051e49
minor stubs changes
Aurel300 Sep 19, 2019
6b8a04a
Merge branch 'feature/eval-libuv' of github.com:Aurel300/haxe into fe…
Aurel300 Sep 19, 2019
d33b27c
some test setup fixes
Aurel300 Sep 19, 2019
a229959
fix xmldoc
Aurel300 Sep 19, 2019
a392e9e
skip some tests on Windows
Aurel300 Sep 19, 2019
c4ee323
(revert later) skip docgen
Aurel300 Sep 19, 2019
df401d8
[ci] enable win32 macro tests again
Simn Sep 19, 2019
ef3cdc7
(revert later) ughh
Aurel300 Sep 19, 2019
51b5ecf
don't leave access.txt in read-only so we can clean up
Simn Sep 20, 2019
94755ee
Merge branch 'development' into feature/eval-libuv
Simn Sep 20, 2019
c1e5290
start on dealing with flag values
Simn Sep 20, 2019
3cdbcdf
disable test that's probably invalid on Windows
Simn Sep 20, 2019
ba637ea
adjust tests to windows limitations
Simn Sep 20, 2019
7408547
[ci] install libuv manually on Linux
Aurel300 Sep 20, 2019
d065543
maybe fix Linux ci
Aurel300 Sep 20, 2019
bd97e56
sudo make ci work
Aurel300 Sep 20, 2019
27db9e6
disable watcher test on Linux
Aurel300 Sep 20, 2019
2d54ddc
error code docstrings
Aurel300 Sep 20, 2019
7a8ab7d
(eval) add lchown and copyfile
Aurel300 Sep 20, 2019
4d0270f
no callback on process_kill
Aurel300 Sep 20, 2019
3e5919d
use 32-bit ints for IPv4
Aurel300 Sep 20, 2019
5dbfef6
[libuv] prepare libuv integration
Simn Sep 20, 2019
56ad076
[ci] bring back docgen
Simn Sep 20, 2019
c047d43
...
Simn Sep 20, 2019
4f6d9a5
avoid dll problem
Simn Sep 20, 2019
d3ede31
no target is asys yet
Simn Sep 20, 2019
7b39cf4
cleanup
Simn Sep 20, 2019
3a3ce68
fix pointer warnings
Simn Sep 21, 2019
18f98b5
check for libuv >= 1.31
Simn Sep 21, 2019
1a17c34
close file in FileSystem.writeFile
Simn Sep 21, 2019
1dfb708
add asys define, forbid asys package on all targets for now
Aurel300 Sep 20, 2019
5b1acbc
eval is asys here
Simn Sep 22, 2019
3fa47f5
merge asys.Timer into haxe.Timer
Simn Sep 22, 2019
ba4aae7
run Uv.init/close just once in the asys tests
Simn Sep 22, 2019
0fdd3e8
hijack haxe.EntryPoint to deal with UV initialization
Simn Sep 22, 2019
f03ff69
fix FileWatcherEvent and adjust test
Simn Sep 22, 2019
7cfbb83
use distinct directory per-test
Simn Sep 22, 2019
c67ed00
fix tests
Simn Sep 22, 2019
552e238
don't unlink
Simn Sep 22, 2019
896eba7
remove more random cleanup code
Simn Sep 22, 2019
bd0c345
simplify alloc_data
Aurel300 Sep 23, 2019
2e2f16c
Merge branch 'development' into feature/libuv-prepare
Simn Sep 23, 2019
1a10736
Merge branch 'feature/libuv-prepare' into feature/eval-libuv
Simn Sep 23, 2019
9e53d3c
port server tests to asys
Simn Sep 23, 2019
e8989ae
disable wonky watcher test for now
Simn Sep 23, 2019
f52b2d7
fix haxeserver branch
Simn Sep 23, 2019
5ea451c
check something
Simn Sep 23, 2019
715f8ef
disable unused include
Simn Sep 24, 2019
99a6663
move UV.init to asys.uv.Uv.__init__
Simn Sep 24, 2019
49a40f0
remove imports
Simn Sep 24, 2019
fa74d66
add mutex and TLS externs
Simn Sep 24, 2019
7cd7425
don't allocate so much
Simn Sep 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src-json/define.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
"define": "as3",
"doc": "Defined when outputting flash9 as3 source code."
},
{
"name": "Asys",
"define": "asys",
"doc": "Defined for all platforms that support the libuv-based asys package."
},
{
"name": "CheckXmlProxy",
"define": "check_xml_proxy",
Expand Down
9 changes: 9 additions & 0 deletions src/context/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ type platform_config = {
pf_static : bool;
(** has access to the "sys" package *)
pf_sys : bool;
(** has access to the "asys" package *)
pf_asys : bool;
(** captured variables handling (see before) *)
pf_capture_policy : capture_policy;
(** when calling a method with optional args, do we replace the missing args with "null" constants *)
Expand Down Expand Up @@ -312,6 +314,7 @@ let default_config =
{
pf_static = true;
pf_sys = true;
pf_asys = false;
pf_capture_policy = CPNone;
pf_pad_nulls = false;
pf_add_final_return = false;
Expand Down Expand Up @@ -421,6 +424,7 @@ let get_config com =
{
default_config with
pf_static = false;
pf_asys = true;
pf_pad_nulls = true;
pf_uses_utf16 = false;
pf_supports_threads = true;
Expand Down Expand Up @@ -588,6 +592,11 @@ let init_platform com pf =
define com Define.Sys
end else
com.package_rules <- PMap.add "sys" Forbidden com.package_rules;
if com.config.pf_asys then begin
raw_define_value com.defines "target.asys" "true";
define com Define.Asys
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have both target.asys and asys? I thought the defines not prefixed by target. are just for backwards compatibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have sys we should also have asys, otherwise this is just one giant trap.

end else
com.package_rules <- PMap.add "asys" Forbidden com.package_rules;
if com.config.pf_uses_utf16 then begin
raw_define_value com.defines "target.utf16" "true";
define com Define.Utf16;
Expand Down
57 changes: 0 additions & 57 deletions std/asys/Timer.hx

This file was deleted.

2 changes: 1 addition & 1 deletion std/asys/net/Server.hx
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,5 @@ class Server {
var native:NativeStream;
var nativeSocket:NativeSocket;
var nativePipe:NativePipe;
var listenDefer:asys.Timer;
var listenDefer:haxe.Timer;
}
6 changes: 3 additions & 3 deletions std/asys/net/Socket.hx
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class Socket extends Duplex {
native.unref();
}

var connectDefer:asys.Timer;
var connectDefer:haxe.Timer;
var native:NativeStream;
var nativeSocket:NativeSocket;
var nativePipe:NativePipe;
Expand All @@ -376,7 +376,7 @@ class Socket extends Duplex {
var connectStarted = false;
var serverSpawn:Bool = false;
var timeoutTime:Int = 0;
var timeoutTimer:asys.Timer;
var timeoutTimer:haxe.Timer;

function new() {
super();
Expand Down Expand Up @@ -443,7 +443,7 @@ class Socket extends Duplex {
timeoutTimer.stop();
timeoutTimer = null;
if (timeoutTime != 0) {
timeoutTimer = asys.Timer.delay(timeoutTrigger, timeoutTime);
timeoutTimer = haxe.Timer.delay(timeoutTrigger, timeoutTime);
timeoutTimer.unref();
}
}
Expand Down
29 changes: 28 additions & 1 deletion std/haxe/Timer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@

package haxe;

#if (target.asys)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's no longer necessary to put dot-defines in parens?

private typedef Native =
#if eval
eval.uv.Timer;
#else
#error "Missing asys implementation"
#end
#end

/**
The `Timer` class allows you to create asynchronous timers on platforms that
support events.
Expand All @@ -42,6 +51,8 @@ class Timer {
#elseif java
private var timer:java.util.Timer;
private var task:java.util.TimerTask;
#elseif (target.asys)
private var native:Native;
#else
private var event:MainLoop.MainEvent;
#end
Expand Down Expand Up @@ -69,6 +80,8 @@ class Timer {
#elseif java
timer = new java.util.Timer();
timer.scheduleAtFixedRate(task = new TimerTask(this), haxe.Int64.ofInt(time_ms), haxe.Int64.ofInt(time_ms));
#elseif (target.asys)
native = new Native(time_ms, () -> run());
#else
var dt = time_ms / 1000;
event = MainLoop.add(function() {
Expand Down Expand Up @@ -103,6 +116,8 @@ class Timer {
timer = null;
}
task = null;
#elseif (target.asys)
native.close((err) -> {});
#else
if (event != null) {
event.stop();
Expand All @@ -121,12 +136,24 @@ class Timer {
var timer = new haxe.Timer(1000); // 1000ms delay
timer.run = function() { ... }
```

Once bound, it can still be rebound to different functions until `this`
Timer is stopped through a call to `this.stop`.
**/
public dynamic function run() {}

public function ref() {
#if (target.asys)
native.ref();
#end
}

public function unref() {
#if (target.asys)
native.unref();
#end
}

/**
Invokes `f` after `time_ms` milliseconds.

Expand Down
4 changes: 2 additions & 2 deletions std/haxe/async/Defer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Defer {
Schedules the given function to run during the next processing tick.
Convenience shortcut for `Timer.delay(f, 0)`.
**/
public static inline function nextTick(f:() -> Void):asys.Timer {
return asys.Timer.delay(f, 0);
public static inline function nextTick(f:() -> Void):haxe.Timer {
return haxe.Timer.delay(f, 0);
}
}
2 changes: 1 addition & 1 deletion std/haxe/io/Readable.hx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Readable implements IReadable {
public var done(default, null) = false;

var buffer = new List<Bytes>();
var deferred:asys.Timer;
var deferred:haxe.Timer;
var willEof = false;

@:dox(show)
Expand Down
2 changes: 1 addition & 1 deletion std/haxe/io/Writable.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Writable implements IWritable {

var willDrain = false;
var willFinish = false;
var deferred:asys.Timer;
var deferred:haxe.Timer;
var buffer = new List<Bytes>();

// for use by implementing classes
Expand Down
11 changes: 11 additions & 0 deletions tests/asys/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@ import utest.ui.Report;

import sys.FileSystem;

#if hl
import hl.Uv;
#elseif eval
import eval.Uv;
#elseif neko
import neko.Uv;
#end

class Main {
public static function main():Void {
Uv.init();
if (FileSystem.exists("resources-rw")) {
function walk(path:String):Void {
for (f in FileSystem.readDirectory(path)) {
Expand All @@ -25,5 +34,7 @@ class Main {
runner.onTestStart.add(test -> trace("running", Type.getClassName(Type.getClass(test.fixture.target)), test.fixture.method));
Report.create(runner);
runner.run();
Uv.run(RunDefault);
Uv.close();
}
}
8 changes: 1 addition & 7 deletions tests/asys/TestBase.hx
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,11 @@ class TestBase {
static var helpers:Map<Process, {?exit:ProcessExit}> = [];

public static function uvSetup():Void {
Uv.init();

}

public static function uvTeardown():Void {
helperTeardown();
Uv.run(RunDefault);
Uv.close();
}

public static function uvRun(?mode:asys.uv.UVRunMode = asys.uv.UVRunMode.RunDefault):Bool {
return Uv.run(mode);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/asys/impl/SlowSource.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SlowSource extends Readable {
if (data.length > 0) {
var nextChunk = data.shift();
var nextEof = data.length == 0;
asys.Timer.delay(() -> asyncRead([nextChunk], nextEof), 10);
haxe.Timer.delay(() -> asyncRead([nextChunk], nextEof), 10);
}
return None;
}
Expand Down
2 changes: 0 additions & 2 deletions tests/asys/test/TestAsyncFile.hx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class TestAsyncFile extends Test {
});

eq(asyncDone, 0);
TestBase.uvRun();
}

/**
Expand Down Expand Up @@ -128,6 +127,5 @@ class TestAsyncFile extends Test {
});

eq(asyncDone, 0);
TestBase.uvRun();
}
}
5 changes: 0 additions & 5 deletions tests/asys/test/TestAsyncFileSystem.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class TestAsyncFileSystem extends Test {
}));

eq(asyncDone, 0);
TestBase.uvRun();
}

function testStat(async:Async) {
Expand Down Expand Up @@ -72,7 +71,6 @@ class TestAsyncFileSystem extends Test {
});

eq(asyncDone, 0);
TestBase.uvRun();
}

@:timeout(3000)
Expand All @@ -97,7 +95,6 @@ class TestAsyncFileSystem extends Test {

NewFS.mkdir('$dir/foo');

TestBase.uvRun(RunOnce);
t(events.length == 1 && events[0].match(Rename("foo")));
events.resize(0);

Expand All @@ -108,12 +105,10 @@ class TestAsyncFileSystem extends Test {

NewFS.rmdir('$dir/foo');

TestBase.uvRun(RunOnce);
t(events.length == 2 && events[0].match(Rename("foo/hello.txt")));
t(events.length == 2 && events[1].match(Rename("foo")));
events.resize(0);

watcher.close();
TestBase.uvRun(RunOnce);
}
}
6 changes: 0 additions & 6 deletions tests/asys/test/TestDns.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class TestDns extends Test {
t(res[0].match(Ipv4(0x7F000001)));
done();
}));

TestBase.uvRun();
}

function testIpv4(async:Async) {
Expand All @@ -30,8 +28,6 @@ class TestDns extends Test {
t(res[0].match(Ipv4(0xFFFFFFFF)));
done();
}));

TestBase.uvRun();
}

function testIpv6(async:Async) {
Expand All @@ -50,7 +46,5 @@ class TestDns extends Test {
t(res[0].match(Ipv6(beq(_, Bytes.ofHex("4861786520697320617765736F6D6521")) => _)));
done();
}));

TestBase.uvRun();
}
}
4 changes: 0 additions & 4 deletions tests/asys/test/TestIpc.hx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ class TestIpc extends Test {
});
});
});

TestBase.uvRun();
}

/*
Expand All @@ -72,8 +70,6 @@ class TestIpc extends Test {
});
});
proc.send({message: {a: [1, 2], b: "c", d: true}});

TestBase.uvRun();
}
*/
}
Loading