Skip to content

Commit

Permalink
rename defcenum to def-foreign-enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianyu Gu committed Dec 26, 2022
1 parent 4c56a49 commit 00797f3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions bin/uv_sniffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main(int argc, char** argv) {
fputs(";;; Error constants\n", output);
fputs(";;; http://docs.libuv.org/en/v1.x/errors.html#error-constants\n", output);
#define XX(name, _) fprintf(output, "\n (:UV_%s %d)", #name, UV_##name);
fputs("(defcenum uv_error_t", output);
fputs("(def-foreign-enum uv_error_t", output);
UV_ERRNO_MAP(XX);
fputs(")\n", output);
#undef XX
Expand All @@ -63,7 +63,7 @@ int main(int argc, char** argv) {
fputs(";;; Handle types\n", output);
fputs(";;; http://docs.libuv.org/en/v1.x/handle.html#c.uv_handle_type\n", output);
#define XX(name, _) fprintf(output, "\n (:UV_%s %d)", #name, UV_##name);
fputs("(defcenum uv_handle_type", output);
fputs("(def-foreign-enum uv_handle_type", output);
fprintf(output, "\n (:UV_UNKNOWN_HANDLE %d)", UV_UNKNOWN_HANDLE);
UV_HANDLE_TYPE_MAP(XX);
fprintf(output, "\n (:UV_HANDLE_TYPE_MAX %d)", UV_HANDLE_TYPE_MAX);
Expand All @@ -77,7 +77,7 @@ int main(int argc, char** argv) {
fputs(";;; Req types\n", output);
fputs(";;; http://docs.libuv.org/en/v1.x/request.html#c.uv_req_t.type\n", output);
#define XX(name, _) fprintf(output, "\n (:UV_%s %d)", #name, UV_##name);
fputs("(defcenum uv_req_type", output);
fputs("(def-foreign-enum uv_req_type", output);
fprintf(output, "\n (:UV_UNKNOWN_REQ %d)", UV_UNKNOWN_REQ);
UV_REQ_TYPE_MAP(XX);
fprintf(output, "\n (:UV_REQ_TYPE_MAX %d)", UV_REQ_TYPE_MAX);
Expand Down
2 changes: 1 addition & 1 deletion libuv/ctype.cl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
(eval-when (:compile-toplevel :load-toplevel :execute)
(defparameter .cenum-table. (make-hash-table :test 'eq)))

(defmacro defcenum (name &body enum-list)
(defmacro def-foreign-enum (name &body enum-list)
(let* ((table (gensym))
(items (loop for (k v) in enum-list
collect `(setf (gethash ,k ,table) ,v))))
Expand Down
4 changes: 2 additions & 2 deletions libuv/event-loop.cl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
;;;; event-loop.cl
(in-package #:libuv)

(defcenum uv_loop_option
(def-foreign-enum uv_loop_option
(:UV_LOOP_BLOCK_SIGNAL 0)
(:UV_METRICS_IDLE_TIME 1))

(defcenum uv_run_mode
(def-foreign-enum uv_run_mode
(:UV_RUN_DEFAULT 0)
(:UV_RUN_ONCE 1)
(:UV_RUN_NOWAIT 2))
Expand Down
14 changes: 9 additions & 5 deletions libuv/handle.cl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
:returning :int)

;;; Poll handle
(defcenum uv_poll_event
(def-foreign-enum uv_poll_event
(:UV_READABLE 1)
(:UV_WRITABLE 2)
(:UV_DISCONNECT 4)
Expand Down Expand Up @@ -144,7 +144,7 @@
:returning :int)

;;; Process handle
(defcenum uv_process_flags
(def-foreign-enum uv_process_flags
(:UV_PROCESS_SETUID #.(ash 1 0))
(:UV_PROCESS_SETGID #.(ash 1 1))
(:UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS #.(ash 1 2))
Expand All @@ -153,7 +153,7 @@
(:UV_PROCESS_WINDOWS_HIDE_CONSOLE #.(ash 1 5))
(:UV_PROCESS_WINDOWS_HIDE_GUI #.(ash 1 6)))

(defcenum uv_stdio_flags
(def-foreign-enum uv_stdio_flags
(:UV_IGNORE #x00)
(:UV_CREATE_PIPE #x01)
(:UV_INHERIT_FD #x02)
Expand Down Expand Up @@ -250,12 +250,16 @@
(def-foreign-call uv_stream_get_write_queue_size ((stream (* uv_stream_t)))
:returning size_t)

;;; TCP handle
(def-foreign-call uv_tcp_init ((event-loop (* uv_loop_t)) (handle (* uv_tcp_t)))
:returning :int)

;;; FS Event handle
(defcenum uv_fs_event
(def-foreign-enum uv_fs_event
(:UV_RENAME 1)
(:UV_CHANGE 2))

(defcenum uv_fs_event_flags
(def-foreign-enum uv_fs_event_flags
(:UV_FS_EVENT_WATCH_ENTRY 1)
(:UV_FS_EVENT_STAT 2)
(:UV_FS_EVENT_RECURSIVE 4))
Expand Down
6 changes: 3 additions & 3 deletions libuv/uv-constants.cl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

;;; Error constants
;;; http://docs.libuv.org/en/v1.x/errors.html#error-constants
(defcenum uv_error_t
(def-foreign-enum uv_error_t
(:UV_E2BIG -7)
(:UV_EACCES -13)
(:UV_EADDRINUSE -98)
Expand Down Expand Up @@ -103,7 +103,7 @@

;;; Handle types
;;; http://docs.libuv.org/en/v1.x/handle.html#c.uv_handle_type
(defcenum uv_handle_type
(def-foreign-enum uv_handle_type
(:UV_UNKNOWN_HANDLE 0)
(:UV_ASYNC 1)
(:UV_CHECK 2)
Expand Down Expand Up @@ -142,7 +142,7 @@

;;; Req types
;;; http://docs.libuv.org/en/v1.x/request.html#c.uv_req_t.type
(defcenum uv_req_type
(def-foreign-enum uv_req_type
(:UV_UNKNOWN_REQ 0)
(:UV_REQ 1)
(:UV_CONNECT 2)
Expand Down

0 comments on commit 00797f3

Please sign in to comment.