client socket works
parent
73a4e3e6c5
commit
9d2af6d349
|
@ -1,11 +1,11 @@
|
|||
- lineno/file for native
|
||||
- native client socket
|
||||
- non-blocking client socket
|
||||
- input style after clicking link
|
||||
- fedit broken with listener
|
||||
- maple-like: press enter at old commands to evaluate there
|
||||
- sending ^C on socket
|
||||
- read#
|
||||
- enforce bottom-up in native bootstrap
|
||||
- fix up native file/line info
|
||||
- standalone listener input style
|
||||
- add a socket timeout
|
||||
- drop test in http server
|
||||
|
|
|
@ -42,17 +42,17 @@ USE: unparser
|
|||
|
||||
: parse-dump ( error -- )
|
||||
<%
|
||||
"error-parse-name" get [ "<interactive>" ] unless* % ":" %
|
||||
"error-file" get [ "<interactive>" ] unless* % ":" %
|
||||
"error-line-number" get [ 1 ] unless* unparse % ": " %
|
||||
%> write
|
||||
error.
|
||||
|
||||
"error-line" get print
|
||||
|
||||
<% "error-pos" get " " fill % "^" % %> print ;
|
||||
<% "error-col" get " " fill % "^" % %> print ;
|
||||
|
||||
: in-parser? ( -- ? )
|
||||
"error-line" get "error-pos" get and ;
|
||||
"error-line" get "error-col" get and ;
|
||||
|
||||
: error-handler-hook
|
||||
#! The game overrides this.
|
||||
|
|
|
@ -43,15 +43,15 @@ USE: vectors
|
|||
#! Save the stacks and parser state for post-mortem
|
||||
#! inspection after an error.
|
||||
namespace [
|
||||
"pos" get
|
||||
"col" get
|
||||
"line" get
|
||||
"line-number" get
|
||||
"parse-name" get
|
||||
"file" get
|
||||
global [
|
||||
"error-parse-name" set
|
||||
"error-file" set
|
||||
"error-line-number" set
|
||||
"error-line" set
|
||||
"error-pos" set
|
||||
"error-col" set
|
||||
"error" set
|
||||
datastack >pop> "error-datastack" set
|
||||
callstack >pop> >pop> "error-callstack" set
|
||||
|
|
|
@ -274,8 +274,9 @@ IN: cross-compiler
|
|||
|
||||
dup word-name "name" swons ,
|
||||
dup word-vocabulary "vocabulary" swons ,
|
||||
"parsing" swap word-property >boolean "parsing" swons ,
|
||||
"parsing" over word-property [ t "parsing" swons , ] when
|
||||
|
||||
drop
|
||||
,] ' ;
|
||||
|
||||
: (worddef,) ( word primitive parameter -- )
|
||||
|
|
|
@ -63,7 +63,8 @@ USE: unparser
|
|||
"restore" get bool% "," %
|
||||
"newView" get bool% "," %
|
||||
"newPlainView" get bool% "," %
|
||||
unparse % "," %
|
||||
( If the dir is not set, we don't want to send f )
|
||||
dup [ unparse ] [ drop "null" ] ifte % "," %
|
||||
list>bsh-array% ");\n" % %>
|
||||
] bind ;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
IN: jedit
|
||||
USE: arithmetic
|
||||
USE: combinators
|
||||
USE: errors
|
||||
USE: kernel
|
||||
USE: namespaces
|
||||
USE: stack
|
||||
|
@ -35,7 +36,7 @@ USE: strings
|
|||
USE: words
|
||||
|
||||
! Doesn't exist in native Factor.
|
||||
DEFER: local-jedit-line/file
|
||||
: local-jedit-line/file "Not supported" throw ;
|
||||
|
||||
: jedit-local? ( -- ? )
|
||||
java? [ global [ "jedit" get ] bind ] [ f ] ifte ;
|
||||
|
@ -59,7 +60,8 @@ DEFER: local-jedit-line/file
|
|||
|
||||
: word-line/file ( word -- line dir file )
|
||||
#! Note that line numbers here start from 1
|
||||
[ "line" get "file" get word-file ] bind ;
|
||||
"line" over word-property swap
|
||||
"file" swap word-property word-file ;
|
||||
|
||||
: jedit ( word -- )
|
||||
intern word-line/file jedit-line/file ;
|
||||
|
|
|
@ -37,6 +37,11 @@ USE: stdio
|
|||
USE: streams
|
||||
USE: strings
|
||||
|
||||
! Stream parsing uses a number of variables:
|
||||
! file
|
||||
! line-number
|
||||
! parse-stream
|
||||
|
||||
: next-line ( -- str )
|
||||
"parse-stream" get freadln
|
||||
"line-number" succ@ ;
|
||||
|
@ -63,9 +68,9 @@ USE: strings
|
|||
|
||||
: parse-stream ( name stream -- code )
|
||||
#! Uses the current namespace for temporary variables.
|
||||
>r "parse-name" set f r>
|
||||
>r "file" set f r>
|
||||
[ (parse) ] read-lines nreverse
|
||||
"parse-name" off
|
||||
"file" off
|
||||
"line-number" off ;
|
||||
|
||||
: parse-file ( file -- code )
|
||||
|
|
|
@ -67,9 +67,15 @@ USE: unparser
|
|||
! Colon defs
|
||||
: CREATE scan "in" get create ;
|
||||
|
||||
: remember-where ( word -- )
|
||||
"line-number" get "line" pick set-word-property
|
||||
"col" get "col" pick set-word-property
|
||||
"file" get "file" pick set-word-property
|
||||
drop ;
|
||||
|
||||
: :
|
||||
#! Begin a word definition. Word name follows.
|
||||
CREATE [ ] ; parsing
|
||||
CREATE dup remember-where [ ] ; parsing
|
||||
|
||||
: ;
|
||||
#! End a word definition.
|
||||
|
@ -128,7 +134,7 @@ USE: unparser
|
|||
: "
|
||||
#! Note the ugly hack to carry the new value of 'pos' from
|
||||
#! the <% %> scope up to the original scope.
|
||||
<% parse-string "pos" get %> swap "pos" set parsed ; parsing
|
||||
<% parse-string "col" get %> swap "col" set parsed ; parsing
|
||||
|
||||
! Char literal
|
||||
: CHAR: ( -- ) next-word-ch parse-ch parsed ; parsing
|
||||
|
|
|
@ -60,11 +60,11 @@ USE: unparser
|
|||
t "parsing" word set-word-property
|
||||
] unless ; parsing
|
||||
|
||||
: <parsing "line" set 0 "pos" set ;
|
||||
: parsing> "line" off "pos" off ;
|
||||
: end? ( -- ? ) "pos" get "line" get str-length >= ;
|
||||
: ch ( -- ch ) "pos" get "line" get str-nth ;
|
||||
: advance ( -- ) "pos" succ@ ;
|
||||
: <parsing "line" set 0 "col" set ;
|
||||
: parsing> "line" off "col" off ;
|
||||
: end? ( -- ? ) "col" get "line" get str-length >= ;
|
||||
: ch ( -- ch ) "col" get "line" get str-nth ;
|
||||
: advance ( -- ) "col" succ@ ;
|
||||
|
||||
: skip ( n line quot -- n )
|
||||
#! Find the next character that satisfies the quotation,
|
||||
|
@ -108,7 +108,7 @@ USE: unparser
|
|||
] ifte ;
|
||||
|
||||
: scan ( -- token )
|
||||
"pos" get "line" get dup >r (scan) dup "pos" set
|
||||
"col" get "line" get dup >r (scan) dup "col" set
|
||||
2dup = [
|
||||
r> 3drop f
|
||||
] [
|
||||
|
@ -155,10 +155,10 @@ USE: unparser
|
|||
|
||||
! Used by parsing words
|
||||
: ch-search ( ch -- index )
|
||||
"pos" get "line" get rot index-of* ;
|
||||
"col" get "line" get rot index-of* ;
|
||||
|
||||
: (until) ( index -- str )
|
||||
"pos" get swap dup succ "pos" set "line" get substring ;
|
||||
"col" get swap dup succ "col" set "line" get substring ;
|
||||
|
||||
: until ( ch -- str )
|
||||
ch-search (until) ;
|
||||
|
@ -170,4 +170,4 @@ USE: unparser
|
|||
end? [ "Unexpected EOF" throw ] [ ch advance ] ifte ;
|
||||
|
||||
: next-word-ch ( -- ch )
|
||||
"pos" get "line" get skip-blank "pos" set next-ch ;
|
||||
"col" get "line" get skip-blank "col" set next-ch ;
|
||||
|
|
|
@ -11,6 +11,8 @@ void init_sockaddr(struct sockaddr_in* name,
|
|||
|
||||
if(hostinfo == NULL)
|
||||
io_error(__FUNCTION__);
|
||||
|
||||
name->sin_addr = *((struct in_addr *)hostinfo->h_addr);
|
||||
}
|
||||
|
||||
int make_client_socket(const char* hostname, uint16_t port)
|
||||
|
@ -23,15 +25,18 @@ int make_client_socket(const char* hostname, uint16_t port)
|
|||
if(sock < 0)
|
||||
io_error(__FUNCTION__);
|
||||
|
||||
if(fcntl(sock,F_SETFL,O_NONBLOCK,1) == -1)
|
||||
io_error(__FUNCTION__);
|
||||
/* if(fcntl(sock,F_SETFL,O_NONBLOCK,1) == -1)
|
||||
io_error(__FUNCTION__); */
|
||||
|
||||
/* Connect to the server. */
|
||||
init_sockaddr(&servername,hostname,port);
|
||||
if(connect(sock,(struct sockaddr *)&servername,sizeof(servername)) < 0)
|
||||
{
|
||||
if(errno != EINPROGRESS)
|
||||
{
|
||||
close(sock);
|
||||
io_error(__FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
return sock;
|
||||
|
|
Loading…
Reference in New Issue