-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a92c860
commit 2ce72af
Showing
7 changed files
with
77 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ build/ | |
lib/ | ||
support/idris2-uv.o | ||
support/libuv-idris | ||
codegen/error_gen |
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,3 @@ | ||
#!/bin/bash | ||
|
||
git restore src/System/UV/Data/Error.idr |
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,9 @@ | ||
LDFLAGS = -luv | ||
CPPFLAGS = | ||
|
||
CC_VERSION = $(shell $(CC) --version) | ||
|
||
|
||
.PHONY: error_gen | ||
error_gen: | ||
$(CC) $(LDFLAGS) -o error_gen error_gen.c |
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,39 @@ | ||
#include <stdio.h> | ||
#include <uv.h> | ||
|
||
int main(void) { | ||
printf("module System.UV.Data.Error\n\n"); | ||
|
||
printf("import Derive.Prelude\n\n"); | ||
|
||
printf("%%language ElabReflection\n"); | ||
printf("%%default total\n\n"); | ||
|
||
printf("public export\n"); | ||
printf("data UVError : Type where\n"); | ||
#define XX(code, _) printf(" %s : UVError\n", uv_err_name(UV_ ## code)); | ||
UV_ERRNO_MAP(XX) | ||
#undef XX | ||
|
||
printf("\n%%runElab derive \"UVError\" [Show,Eq]\n"); | ||
|
||
printf("\nexport\n"); | ||
printf("toCode : UVError -> Int32\n"); | ||
#define XX(code, _) printf("toCode %s = (%d)\n", uv_err_name(UV_ ## code), UV_ ## code); | ||
UV_ERRNO_MAP(XX) | ||
#undef XX | ||
|
||
printf("\nexport\n"); | ||
printf("fromCode : Int32 -> UVError\n"); | ||
#define XX(code, _) printf("fromCode (%d) = %s\n", UV_ ## code, uv_err_name(UV_ ## code)); | ||
UV_ERRNO_MAP(XX) | ||
#undef XX | ||
printf("fromCode _ = UNKNOWN\n"); | ||
|
||
printf("\n%%foreign \"C:uv_strerror,libuv-idris\"\n"); | ||
printf("uv_strerror : Int32 -> String\n"); | ||
|
||
printf("\nexport %%inline\n"); | ||
printf("errorMsg : UVError -> String\n"); | ||
printf("errorMsg = uv_strerror . toCode\n"); | ||
} |
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,4 @@ | ||
#!/bin/bash | ||
|
||
make -C codegen error_gen | ||
codegen/error_gen > src/System/UV/Data/Error.idr |
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,18 @@ | ||
module System.UV.Data.Error | ||
|
||
import Derive.Prelude | ||
|
||
%language ElabReflection | ||
%default total | ||
|
||
public export | ||
data UVError : Type where | ||
EOF : UVError | ||
|
||
%runElab derive "UVError" [Show,Eq] | ||
|
||
export | ||
toCode : UVError -> Int32 | ||
|
||
export | ||
fromCode : Int32 -> UVError |
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