/usr/lib/gambc4/_io#.scm is in libgambc4 4.2.8-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 | ;;;============================================================================
;;; File: "_io#.scm", Time-stamp: <2008-05-22 17:52:27 feeley>
;;; Copyright (c) 1994-2008 by Marc Feeley, All Rights Reserved.
;;;============================================================================
;;; Representation of exceptions.
(define-library-type-of-exception datum-parsing-exception
id: 84660e37-9565-4abf-ac09-f9767f926d40
constructor: #f
opaque:
(kind unprintable: read-only:)
(readenv unprintable: read-only:)
(parameters unprintable: read-only:)
)
(define-library-type-of-exception unterminated-process-exception
id: b320dfbf-c714-4dc5-8bfa-cac5ee6c8421
constructor: #f
opaque:
unprintable:
read-only:
procedure
arguments
)
(define-library-type-of-exception nonempty-input-port-character-buffer-exception
id: 63b50ae7-375b-4b94-81df-3522686f5634
constructor: #f
opaque:
unprintable:
read-only:
procedure
arguments
)
;;;----------------------------------------------------------------------------
;;; Define type checking macros.
(define-check-type string-or-ip-address 'string-or-ip-address
macro-string-or-ip-address?)
(##define-macro (macro-string-or-ip-address? obj)
`(##string-or-ip-address? ,obj))
;;;----------------------------------------------------------------------------
;;; Representation of ports.
;; There are 5 kinds of ports, each providing a set of operations. All
;; port objects have the capability of being both an input port and an
;; output port. The "none-port" kind provides no operation and is
;; mainly for internal use to indicate that no input operation is
;; available or that no output operation is available.
;;
;; 1) An "object-port" (or simply a "port") provides operations to read
;; and write Scheme data (i.e. any Scheme object) to/from the port.
;; It also provides operations to get the name of the port, to force
;; output to occur, and to close the port. This kind of port need
;; not be connected to a character based device or file (it could
;; for example be a FIFO queue linking two threads that need to
;; communicate Scheme objects).
;;
;; 2) A "character-port" provides all the operations of an "object-port",
;; and also operations to read and write individual characters
;; to/from the port. When a Scheme object is written to a
;; character-port, it is converted into the sequence of characters that
;; corresponds to its "external-representation". When reading a
;; Scheme object, an inverse conversion occurs.
;;
;; 3) A "byte-port" provides all the operations of a "character-port", and
;; also operations to read and write individual bytes to/from the
;; port. When a **character** is written to a byte-port, some
;; encoding of that character into a sequence of bytes will occur
;; (for example, #\newline might be encoded as the 2 bytes CR-LF
;; when using ISO-8859-1 encoding, or a non-ASCII character will
;; generate more than 1 byte when using UTF-8 encoding). When
;; reading a character, a similar decoding occurs.
;;
;; 4) A "device-port" provides all the operations of a "byte-port", and
;; also operations to control the device (file, tty, etc) that is
;; connected to the port, such as changing the tty settings.
(define-type port
id: 2babe060-9af6-456f-a26e-40b592f690ec
type-exhibitor: macro-type-port
constructor: macro-make-port
implementer: implement-type-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-port
mutex ;; access to the port is controlled with this mutex
rkind ;; port kind for reading (none-port if can't read)
wkind ;; port kind for writing (none-port if can't write)
name ;; procedure which returns the name of the port
read-datum ;; procedure to read a datum
write-datum ;; procedure to write a datum
newline ;; procedure to write a datum separator
force-output ;; procedure to force output to occur on target device
close ;; procedure to close the port
roptions ;; options for reading (buffering type, encoding, etc)
rtimeout ;; time at which a read that would block times out
rtimeout-thunk ;; thunk called when a read timeout occurs
set-rtimeout ;; procedure to set rtimeout and rtimeout-thunk
woptions ;; options for writing (buffering type, encoding, etc)
wtimeout ;; time at which a write that would block times out
wtimeout-thunk ;; thunk called when a write timeout occurs
set-wtimeout ;; procedure to set wtimeout and wtimeout-thunk
)
(define-check-type port (macro-type-port)
macro-port?)
(##define-macro (macro-port-of-rkind? obj kind)
`(let ((obj ,obj))
(and (macro-port? obj)
(##fixnum.= (##fixnum.bitwise-and (macro-port-rkind obj) ,kind)
,kind))))
(##define-macro (macro-port-of-wkind? obj kind)
`(let ((obj ,obj))
(and (macro-port? obj)
(##fixnum.= (##fixnum.bitwise-and (macro-port-wkind obj) ,kind)
,kind))))
(##define-macro (macro-none-kind) 0) ;; allows nothing
(##define-macro (macro-object-kind) 1) ;; can read and write objects
(##define-macro (macro-character-kind) 3) ;; can also read and write chars
(##define-macro (macro-byte-kind) 7) ;; can also read and write bytes
(##define-macro (macro-device-kind) 15) ;; can also do device operations
(##define-macro (macro-file-kind) (+ 15 16))
(##define-macro (macro-process-kind) (+ 15 32))
(##define-macro (macro-tty-kind) (+ 15 64))
(##define-macro (macro-serial-kind) (+ 15 128))
(##define-macro (macro-tcp-client-kind) (+ 15 256))
(##define-macro (macro-tcp-server-kind) (+ 1 512))
(##define-macro (macro-directory-kind) (+ 1 1024))
(##define-macro (macro-event-queue-kind) (+ 1 2048))
(##define-macro (macro-timer-kind) (+ 1 4096))
(##define-macro (macro-vector-kind) (+ 1 8192))
(##define-macro (macro-string-kind) (+ 3 16384))
(##define-macro (macro-u8vector-kind) (+ 7 32768))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of object ports.
(define-check-type input-port 'input-port
macro-input-port?)
(define-check-type output-port 'output-port
macro-output-port?)
(##define-macro (macro-input-port? obj)
`(macro-port-of-rkind? ,obj (macro-object-kind)))
(##define-macro (macro-output-port? obj)
`(macro-port-of-wkind? ,obj (macro-object-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of char ports.
(define-check-type character-input-port 'character-input-port
macro-character-input-port?)
(define-check-type character-output-port 'character-output-port
macro-character-output-port?)
(define-type-of-port character-port
id: 85099702-35ec-4cb8-ae55-13c4b9b05d10
type-exhibitor: macro-type-character-port
constructor: macro-make-character-port
implementer: implement-type-character-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-character-port
rbuf ;; character read buffer (a string)
rlo ;; low pointer (start of unread characters)
rhi ;; high pointer (end of unread characters)
rchars ;; number of characters read at start of read buffer
rlines ;; number of lines read up to low pointer
rcurline ;; absolute character position where current line starts
rbuf-fill ;; procedure to read characters into the read buffer
peek-eof? ;; peeking the next character should return end-of-file?
wbuf ;; character write buffer (a string)
wlo ;; low pointer (start of unwritten characters)
whi ;; high pointer (end of unwritten characters)
wchars ;; number of characters written at start of write buffer
wlines ;; number of lines written up to high pointer
wcurline ;; absolute character position where current line starts
wbuf-drain ;; procedure to write characters from the write buffer
input-readtable ;; readtable for reading
output-readtable ;; readtable for writing
output-width ;; procedure to get the output width in characters
)
(##define-macro (macro-character-input-port? obj)
`(macro-port-of-rkind? ,obj (macro-character-kind)))
(##define-macro (macro-character-output-port? obj)
`(macro-port-of-wkind? ,obj (macro-character-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of byte ports.
(define-check-type byte-port 'byte-port
macro-byte-port?)
(define-check-type byte-input-port 'byte-input-port
macro-byte-input-port?)
(define-check-type byte-output-port 'byte-output-port
macro-byte-output-port?)
(define-type-of-character-port byte-port
id: 8a99028e-7b99-4468-b94e-728737ec1b1a
type-exhibitor: macro-type-byte-port
constructor: macro-make-byte-port
implementer: implement-type-byte-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-byte-port
rbuf ;; byte read buffer (a u8vector)
rlo ;; low pointer (start of unread bytes)
rhi ;; high pointer (end of unread bytes)
rbuf-fill ;; procedure to read bytes into the read buffer
wbuf ;; byte write buffer (a u8vector)
wlo ;; low pointer (start of unwritten bytes)
whi ;; high pointer (end of unwritten bytes)
wbuf-drain ;; procedure to write bytes from the write buffer
)
(##define-macro (macro-byte-port? obj)
`(or (macro-byte-input-port? ,obj)
(macro-byte-output-port? ,obj)))
(##define-macro (macro-byte-input-port? obj)
`(macro-port-of-rkind? ,obj (macro-byte-kind)))
(##define-macro (macro-byte-output-port? obj)
`(macro-port-of-wkind? ,obj (macro-byte-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of device ports.
(define-check-type device-input-port 'device-input-port
macro-device-input-port?)
(define-check-type device-output-port 'device-output-port
macro-device-output-port?)
(define-type-of-byte-port device-port
id: b4fa842f-5da6-43b6-b447-d0b0348ae962
type-exhibitor: macro-type-device-port
constructor: macro-make-device-port
implementer: implement-type-device-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-device-port
rdevice-condvar ;; device condvar from which bytes are read
wdevice-condvar ;; device condvar to which bytes are written
name ;; name of device
)
(##define-macro (macro-device-input-port? obj)
`(macro-port-of-rkind? ,obj (macro-device-kind)))
(##define-macro (macro-device-output-port? obj)
`(macro-port-of-wkind? ,obj (macro-device-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of vector, string and u8vector ports.
(define-type-of-port vector-port
id: 2fb9e1fc-693b-455f-94a2-70c617a304d1
type-exhibitor: macro-type-vector-port
constructor: macro-make-vector-port
implementer: implement-type-vector-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-vector-port
rbuf
rlo
rhi
rbuf-fill
wbuf
wlo
whi
wbuf-drain
peer
fifo
rcondvar
wcondvar
buffering-limit
)
(define-check-type vector-input-port 'vector-input-port
macro-vector-input-port?)
(define-check-type vector-output-port 'vector-output-port
macro-vector-output-port?)
(##define-macro (macro-vector-input-port? obj)
`(macro-port-of-rkind? ,obj (macro-vector-kind)))
(##define-macro (macro-vector-output-port? obj)
`(macro-port-of-wkind? ,obj (macro-vector-kind)))
(define-type-of-character-port string-port
id: 81e73361-b03c-4889-9d02-e340e3309934
type-exhibitor: macro-type-string-port
constructor: macro-make-string-port
implementer: implement-type-string-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-string-port
peer
fifo
rcondvar
wcondvar
width
buffering-limit
)
(define-check-type string-input-port 'string-input-port
macro-string-input-port?)
(define-check-type string-output-port 'string-output-port
macro-string-output-port?)
(##define-macro (macro-string-input-port? obj)
`(macro-port-of-rkind? ,obj (macro-string-kind)))
(##define-macro (macro-string-output-port? obj)
`(macro-port-of-wkind? ,obj (macro-string-kind)))
(define-type-of-byte-port u8vector-port
id: 04c1b0ae-b11f-4815-b206-ce01648675bd
type-exhibitor: macro-type-u8vector-port
constructor: macro-make-u8vector-port
implementer: implement-type-u8vector-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-u8vector-port
peer
fifo
rcondvar
wcondvar
width
buffering-limit
)
(define-check-type u8vector-input-port 'u8vector-input-port
macro-u8vector-input-port?)
(define-check-type u8vector-output-port 'u8vector-output-port
macro-u8vector-output-port?)
(##define-macro (macro-u8vector-input-port? obj)
`(macro-port-of-rkind? ,obj (macro-u8vector-kind)))
(##define-macro (macro-u8vector-output-port? obj)
`(macro-port-of-wkind? ,obj (macro-u8vector-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of file device ports.
(define-check-type file-port 'file-port
macro-file-port?)
(##define-macro (macro-file-port? obj)
`(##port-of-kind? ,obj (macro-file-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of tty device ports.
(define-check-type tty-port 'tty-port
macro-tty-port?)
(##define-macro (macro-tty-port? obj)
`(##port-of-kind? ,obj (macro-tty-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of process device ports.
(define-check-type process-port 'process-port
macro-process-port?)
(##define-macro (macro-process-port? obj)
`(##port-of-kind? ,obj (macro-process-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of host-info objects.
(define-library-type host-info
id: e3dc833e-a176-42c1-bdc0-76a6c4b302f8
constructor: #f
opaque:
(name printable: read-only:)
(aliases printable: read-only:)
(addresses printable: read-only:)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of service-info objects.
(define-library-type service-info
id: 177749b2-beb0-4670-9ab2-4b9c01b54c1d
constructor: #f
opaque:
(name printable: read-only:)
(aliases printable: read-only:)
(port printable: read-only:)
(protocol printable: read-only:)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of protocol-info objects.
(define-library-type protocol-info
id: ffc668b5-2146-42b7-ab11-7d91641f2124
constructor: #f
opaque:
(name printable: read-only:)
(aliases printable: read-only:)
(number printable: read-only:)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of network-info objects.
(define-library-type network-info
id: ce2e418b-96c7-4562-9cb6-419ec113704e
constructor: #f
opaque:
(name printable: read-only:)
(aliases printable: read-only:)
(net printable: read-only:)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of socket-info objects.
(define-library-type socket-info
id: 837d9768-9d27-455e-ac65-5ae59f43f79e
constructor: #f
opaque:
(family printable: read-only:)
(port-number printable: read-only:)
(address printable: read-only:)
)
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of TCP client device ports.
(define-check-type tcp-client-port 'tcp-client-port
macro-tcp-client-port?)
(##define-macro (macro-tcp-client-port? obj)
`(##port-of-kind? ,obj (macro-tcp-client-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of TCP server ports.
(define-type-of-port tcp-server-port
id: 42696abb-6729-4637-99de-cef7d3a230ae
type-exhibitor: macro-type-tcp-server-port
constructor: macro-make-tcp-server-port
implementer: implement-type-tcp-server-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-tcp-server-port
rdevice-condvar
client-psettings
)
(define-check-type tcp-server-port (macro-type-tcp-server-port)
macro-tcp-server-port?)
(##define-macro (macro-tcp-server-port? obj)
`(##port-of-kind? ,obj (macro-tcp-server-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of pipe device ports.
(define-check-type pipe-port 'pipe-port
macro-pipe-port?)
(##define-macro (macro-pipe-port? obj)
`(##port-of-kind? ,obj (macro-pipe-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of serial device ports.
(define-check-type serial-port 'serial-port
macro-serial-port?)
(##define-macro (macro-serial-port? obj)
`(##port-of-kind? ,obj (macro-serial-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of directory ports.
(define-type-of-port directory-port
id: deebf606-97e4-4d34-8fed-b9e5468851b9
type-exhibitor: macro-type-directory-port
constructor: macro-make-directory-port
implementer: implement-type-directory-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-directory-port
rdevice-condvar
path
)
(define-check-type directory-port 'directory-port
macro-directory-port?)
(##define-macro (macro-directory-port? obj)
`(##port-of-kind? ,obj (macro-directory-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of event queue ports.
(define-type-of-port event-queue-port
id: 59109ed7-6339-4c6e-8bc2-f52e9c91b9f5
type-exhibitor: macro-type-event-queue-port
constructor: macro-make-event-queue-port
implementer: implement-type-event-queue-port
macros:
prefix: macro-
opaque:
unprintable:
extender: define-type-of-event-queue-port
rdevice-condvar
index
)
(define-check-type event-queue-port 'event-queue-port
macro-event-queue-port?)
(##define-macro (macro-event-queue-port? obj)
`(##port-of-kind? ,obj (macro-event-queue-kind)))
;;; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;;; Representation of timer ports.
(define-check-type timer-port 'timer-port
macro-timer-port?)
(##define-macro (macro-timer-port? obj)
`(##port-of-kind? ,obj (macro-timer-kind)))
;;;----------------------------------------------------------------------------
;;; Representation of port mutexes.
(##define-macro (macro-make-port-mutex)
`(##make-mutex #f))
(##define-macro (macro-port-mutex-lock! port)
`(macro-mutex-lock! (macro-port-mutex ,port) #f (macro-current-thread)))
(##define-macro (macro-port-mutex-unlock! port)
`(macro-mutex-unlock! (macro-port-mutex ,port)))
(##define-macro (macro-port-mutex-unlocked-not-abandoned-and-not-multiprocessor? port)
`(macro-mutex-unlocked-not-abandoned-and-not-multiprocessor? (macro-port-mutex ,port)))
;;;----------------------------------------------------------------------------
;;; Representation of port settings.
(define-type psettings
id: 0b02934e-7c23-4f9e-a629-0eede16e6987
type-exhibitor: macro-type-psettings
constructor: macro-make-psettings
implementer: implement-type-psettings
macros:
prefix: macro-
opaque:
unprintable:
direction
roptions
woptions
path
init
arguments
environment
directory
append
create
truncate
permissions
output-width
stdin-redir
stdout-redir
stderr-redir
pseudo-term
show-console
server-address
port-number
socket-type
coalesce
keep-alive
backlog
reuse-address
broadcast
ignore-hidden
)
(define-type psettings-options
id: edb28923-9aa0-4c55-9756-f1a37136f727
type-exhibitor: macro-type-psettings-options
constructor: macro-make-psettings-options
implementer: implement-type-psettings-options
macros:
prefix: macro-
opaque:
unprintable:
readtable
char-encoding
char-encoding-errors
eol-encoding
buffering
permanent-close
)
(##define-macro (macro-default-readtable) #f)
(##define-macro (macro-char-encoding-shift) 1)
(##define-macro (macro-char-encoding-range) 16)
(##define-macro (macro-default-char-encoding) 0)
(##define-macro (macro-char-encoding-ASCII) 1)
(##define-macro (macro-char-encoding-ISO-8859-1) 2)
(##define-macro (macro-char-encoding-UTF-8) 3)
(##define-macro (macro-char-encoding-UTF-16) 4)
(##define-macro (macro-char-encoding-UTF-16LE) 5)
(##define-macro (macro-char-encoding-UTF-16BE) 6)
(##define-macro (macro-char-encoding-UTF) 7)
(##define-macro (macro-char-encoding-UCS-2) 8)
(##define-macro (macro-char-encoding-UCS-2LE) 9)
(##define-macro (macro-char-encoding-UCS-2BE) 10)
(##define-macro (macro-char-encoding-UCS-4) 11)
(##define-macro (macro-char-encoding-UCS-4LE) 12)
(##define-macro (macro-char-encoding-UCS-4BE) 13)
(##define-macro (macro-char-encoding-wchar) 14)
(##define-macro (macro-char-encoding-native) 15)
(##define-macro (macro-char-encoding-errors-shift) 16)
(##define-macro (macro-char-encoding-errors-range) 4)
(##define-macro (macro-default-char-encoding-errors) 0)
(##define-macro (macro-char-encoding-errors-on) 1)
(##define-macro (macro-char-encoding-errors-off) 2)
(##define-macro (macro-eol-encoding-shift) 64)
(##define-macro (macro-eol-encoding-range) 4)
(##define-macro (macro-default-eol-encoding) 0)
(##define-macro (macro-eol-encoding-lf) 1)
(##define-macro (macro-eol-encoding-cr) 2)
(##define-macro (macro-eol-encoding-crlf) 3)
(##define-macro (macro-buffering-shift) 256)
(##define-macro (macro-buffering-range) 4)
(##define-macro (macro-default-buffering) 0)
(##define-macro (macro-no-buffering) 1)
(##define-macro (macro-line-buffering) 2)
(##define-macro (macro-full-buffering) 3)
(##define-macro (macro-unbuffered? options)
`(##fixnum.< (##fixnum.bitwise-and ,options 1023) 512))
(##define-macro (macro-fully-buffered? options)
`(##not (##fixnum.< (##fixnum.bitwise-and ,options 1023) 768)))
(##define-macro (macro-decode-state-shift) 1024)
(##define-macro (macro-decode-state-range) 4)
(##define-macro (macro-decode-state-none) 0)
(##define-macro (macro-decode-state-lf) 1)
(##define-macro (macro-decode-state-cr) 2)
(##define-macro (macro-open-state-shift) 4096)
(##define-macro (macro-open-state-range) 2)
(##define-macro (macro-open-state-open) 0)
(##define-macro (macro-open-state-closed) 1)
(##define-macro (macro-closed? options)
`(##not (##fixnum.= (##fixnum.bitwise-and ,options 4096) 0)))
(##define-macro (macro-close! options)
`(##fixnum.bitwise-ior ,options 4096))
(##define-macro (macro-unclose! options)
`(##fixnum.bitwise-and ,options -4097))
(##define-macro (macro-permanent-close-shift) 8192)
(##define-macro (macro-permanent-close-range) 2)
(##define-macro (macro-permanent-close-no) 0)
(##define-macro (macro-permanent-close-yes) 1)
(##define-macro (macro-perm-close? options)
`(##not (##fixnum.= (##fixnum.bitwise-and ,options 8192) 0)))
(##define-macro (macro-direction-shift) 16)
(##define-macro (macro-direction-in) 1)
(##define-macro (macro-direction-out) 2)
(##define-macro (macro-direction-inout) 3)
(##define-macro (macro-default-path) #f)
(##define-macro (macro-default-init) #f)
(##define-macro (macro-default-arguments) ''())
(##define-macro (macro-default-environment) #f)
(##define-macro (macro-default-directory) #f)
(##define-macro (macro-append-shift) 8)
(##define-macro (macro-no-append) 0)
(##define-macro (macro-append) 1)
(##define-macro (macro-default-append) 2)
(##define-macro (macro-create-shift) 2)
(##define-macro (macro-no-create) 0)
(##define-macro (macro-maybe-create) 1)
(##define-macro (macro-create) 2)
(##define-macro (macro-default-create) 3)
(##define-macro (macro-truncate-shift) 1)
(##define-macro (macro-no-truncate) 0)
(##define-macro (macro-truncate) 1)
(##define-macro (macro-default-truncate) 2)
(##define-macro (macro-default-permissions) -1)
(##define-macro (macro-default-output-width) -1)
(##define-macro (macro-permanent-close) 1)
(##define-macro (macro-no-permanent-close) 0)
(##define-macro (macro-default-permanent-close) `(macro-permanent-close))
(##define-macro (macro-stdin-from-port) 1)
(##define-macro (macro-stdin-unchanged) 0)
(##define-macro (macro-default-stdin-redir) `(macro-stdin-from-port))
(##define-macro (macro-stdout-to-port) 1)
(##define-macro (macro-stdout-unchanged) 0)
(##define-macro (macro-default-stdout-redir) `(macro-stdout-to-port))
(##define-macro (macro-stderr-to-port) 1)
(##define-macro (macro-stderr-unchanged) 0)
(##define-macro (macro-default-stderr-redir) `(macro-stderr-unchanged))
(##define-macro (macro-pseudo-term) 1)
(##define-macro (macro-no-pseudo-term) 0)
(##define-macro (macro-default-pseudo-term) `(macro-no-pseudo-term))
(##define-macro (macro-show-console) 1)
(##define-macro (macro-no-show-console) 0)
(##define-macro (macro-default-show-console) `(macro-show-console))
(##define-macro (macro-default-server-address) #f)
(##define-macro (macro-default-port-number) #f)
(##define-macro (macro-socket-type-TCP) 0)
(##define-macro (macro-socket-type-UDP) 1)
(##define-macro (macro-socket-type-RAW) 2)
(##define-macro (macro-default-socket-type) `(macro-socket-type-TCP))
(##define-macro (macro-coalesce) 1)
(##define-macro (macro-no-coalesce) 0)
(##define-macro (macro-default-coalesce) `(macro-coalesce))
(##define-macro (macro-keep-alive) 1)
(##define-macro (macro-no-keep-alive) 0)
(##define-macro (macro-default-keep-alive) `(macro-no-keep-alive))
(##define-macro (macro-broadcast) 1)
(##define-macro (macro-no-broadcast) 0)
(##define-macro (macro-default-broadcast) `(macro-no-broadcast))
(##define-macro (macro-default-backlog) 128)
(##define-macro (macro-reuse-address) 1)
(##define-macro (macro-no-reuse-address) 0)
(##define-macro (macro-default-reuse-address) `(macro-reuse-address))
(##define-macro (macro-ignore-hidden) 2)
(##define-macro (macro-ignore-dot-and-dot-dot) 1)
(##define-macro (macro-ignore-nothing) 0)
(##define-macro (macro-default-ignore-hidden) `(macro-ignore-hidden))
;;;----------------------------------------------------------------------------
;;; Representation of write environments.
;; A writeenv structure maintains the "write environment" throughout
;; the writing of a Scheme datum. It includes the write style
;; (display, write, pretty-print, mark), the port on which to write,
;; the readtable, the marktable (for detecting cycles), the force flag,
;; the pretty-print width, the number of closing parentheses to follow
;; the datum, the current nesting level, and the character count limit.
(define-type writeenv
id: f5cfcf78-bba4-4140-9aa0-1a136c50d36b
type-exhibitor: macro-type-writeenv
constructor: macro-make-writeenv
implementer: implement-type-writeenv
macros:
prefix: macro-
opaque:
unprintable:
style
port
readtable
marktable
force?
width
close-parens
level
limit
)
;;;----------------------------------------------------------------------------
;;; Representation of read environments.
;; A readenv structure maintains the "read environment" throughout the
;; reading of a Scheme datum. It includes the port from which to read,
;; the readtable, the wrap and unwrap procedures, the table of labels
;; (i.e. "#n#"), and the position where the currently being read datum
;; started.
(define-type readenv
id: edd21ef2-ee48-407f-a9a9-c1c361078e55
type-exhibitor: macro-type-readenv
constructor: macro-make-readenv
implementer: implement-type-readenv
macros:
prefix: macro-
opaque:
unprintable:
port
readtable
wrapper
unwrapper
allow-script?
labels
filepos
)
(##define-macro (macro-readenv-wrap re x)
`(let ((re ,re)
(x ,x))
((macro-readenv-wrapper re) re x)))
(##define-macro (macro-readenv-unwrap re x)
`(let ((re ,re)
(x ,x))
((macro-readenv-unwrapper re) re x)))
;;;----------------------------------------------------------------------------
;;; Generic char port procedures.
(##define-macro (macro-peek-char port)
`(let ((port ,port))
(##declare (not interrupts-enabled))
;; try to get exclusive access to port and if successful perform
;; operation inline
(if (macro-port-mutex-unlocked-not-abandoned-and-not-multiprocessor? port)
(let ((char-rlo (macro-character-port-rlo port))
(char-rhi (macro-character-port-rhi port)))
(if (##fixnum.< char-rlo char-rhi)
;; the next character is in the character read buffer
(##string-ref (macro-character-port-rbuf port) char-rlo)
;; more characters are needed, do this out-of-line
(let ()
(##declare (interrupts-enabled))
(##peek-char port))))
;; couldn't easily get exclusive access to port, handle this out-of-line
(let ()
(##declare (interrupts-enabled))
(##peek-char port)))))
(##define-macro (macro-read-char port)
`(let ((port ,port))
(##declare (not interrupts-enabled))
;; try to get exclusive access to port and if successful perform
;; operation inline
(if (macro-port-mutex-unlocked-not-abandoned-and-not-multiprocessor? port)
(let ((char-rlo (macro-character-port-rlo port))
(char-rhi (macro-character-port-rhi port)))
(if (##fixnum.< char-rlo char-rhi)
;; the next character is in the character read buffer
(let ((c (##string-ref (macro-character-port-rbuf port) char-rlo)))
(if (##not (##char=? c #\newline))
;; frequent simple case, just advance rlo
(begin
(macro-character-port-rlo-set! port (##fixnum.+ char-rlo 1))
c)
;; end-of-line processing is complex, so do it out-of-line
(let ()
(##declare (interrupts-enabled))
(##read-char port))))
;; more characters are needed, do this out-of-line
(let ()
(##declare (interrupts-enabled))
(##read-char port))))
;; couldn't easily get exclusive access to port, handle this out-of-line
(let ()
(##declare (interrupts-enabled))
(##read-char port)))))
(##define-macro (macro-write-char c port)
`(let ((c ,c)
(port ,port))
(##declare (not interrupts-enabled))
;; try to get exclusive access to port and if successful perform
;; operation inline
(if (and (##not (##char=? c #\newline))
(macro-port-mutex-unlocked-not-abandoned-and-not-multiprocessor? port))
(let ((char-wbuf (macro-character-port-wbuf port))
(char-whi+1 (##fixnum.+ (macro-character-port-whi port) 1)))
(if (##fixnum.< char-whi+1 (##string-length char-wbuf))
;; adding this character would not make the character write
;; buffer full, so add character and increment whi
(begin
(##string-set! char-wbuf (##fixnum.- char-whi+1 1) c)
(macro-character-port-whi-set! port char-whi+1)
(##void))
;; the character write buffer would become full, so handle
;; this out-of-line
(let ()
(##declare (interrupts-enabled))
(##write-char c port))))
;; end-of-line processing is needed or exclusive access to port
;; cannot be obtained easily, so handle this out-of-line
(let ()
(##declare (interrupts-enabled))
(##write-char c port)))))
;;;----------------------------------------------------------------------------
;;; Representation of readtables.
(define-type readtable
id: bebee95d-0da2-401d-a33a-c1afc75b9e43
type-exhibitor: macro-type-readtable
constructor: macro-make-readtable
implementer: implement-type-readtable
macros:
prefix: macro-
opaque:
(case-conversion? unprintable: read-write:)
(keywords-allowed? unprintable: read-write:)
(escaped-char-table unprintable: read-write:)
(named-char-table unprintable: read-write:)
(sharp-bang-table unprintable: read-write:)
(char-delimiter?-table unprintable: read-write:)
(char-handler-table unprintable: read-write:)
(char-sharp-handler-table unprintable: read-write:)
(max-unescaped-char unprintable: read-write:)
(escape-ctrl-chars? unprintable: read-write:)
(sharing-allowed? unprintable: read-write:)
(eval-allowed? unprintable: read-write:)
(max-write-level unprintable: read-write:)
(max-write-length unprintable: read-write:)
(pretty-print-formats unprintable: read-write:)
(quote-keyword unprintable: read-write:)
(quasiquote-keyword unprintable: read-write:)
(unquote-keyword unprintable: read-write:)
(unquote-splicing-keyword unprintable: read-write:)
(sharp-quote-keyword unprintable: read-write:)
(sharp-quasiquote-keyword unprintable: read-write:)
(sharp-unquote-keyword unprintable: read-write:)
(sharp-unquote-splicing-keyword unprintable: read-write:)
(sharp-num-keyword unprintable: read-write:)
(sharp-seq-keyword unprintable: read-write:)
(paren-keyword unprintable: read-write:)
(bracket-keyword unprintable: read-write:)
(brace-keyword unprintable: read-write:)
(angle-keyword unprintable: read-write:)
(start-syntax unprintable: read-write:)
(six-type? unprintable: read-write:)
(r6rs-compatible-read? unprintable: read-write:)
(r6rs-compatible-write? unprintable: read-write:)
)
(define-check-type readtable (macro-type-readtable)
macro-readtable?)
;;;----------------------------------------------------------------------------
;;; Representation of language specs.
(##define-macro (macro-language-name x) `(##vector-ref ,x 0))
(##define-macro (macro-language-case-conversion? x) `(##vector-ref ,x 1))
(##define-macro (macro-language-keywords-allowed? x) `(##vector-ref ,x 2))
(##define-macro (macro-language-start-syntax x) `(##vector-ref ,x 3))
(##define-macro (macro-language-srfi-22? x) `(##vector-ref ,x 4))
;;;============================================================================
|