IN: help.tips
USING: help.markup help.syntax debugger prettyprint see help help.vocabs
-help.apropos tools.time stack-checker editors ;
+help.apropos tools.time stack-checker editors memory ;
TIP: "To look at the most recent error, run " { $link :error } ". To look at the most recent error's callstack, run " { $link :c } "." ;
TIP: "Tips of the day implement the " { $link "definition-protocol" } " and new tips of the day can be defined using the " { $link POSTPONE: TIP: } " parsing word." ;
-TIP: "Try some simple demo applications, then look at the source code in " { $snippet "extra/" } ": " { $code "\"demos\" run" } ;
+TIP: "Try some simple demo applications, then look at the source code in " { $snippet "extra/" } ": " { $snippet "\"demos\" run" } ;
+
+TIP: "To save time on reloading big libraries such as the " { $vocab-link "furnace" } " web framework, save the image after loading them using the " { $link save } " word." ;
HELP: TIP:
{ $syntax "TIP: content ;" }
! See http://factorcode.org/license.txt for BSD license.
USING: alien alien.c-types arrays assocs byte-arrays io
io.binary io.streams.string kernel math math.parser namespaces
-make parser prettyprint quotations sequences strings vectors
+make parser quotations sequences strings vectors
words macros math.functions math.bitwise fry generalizations
combinators.smart io.streams.byte-array io.encodings.binary
math.vectors combinators multiline endian ;
\ fflush { alien } { } define-primitive
+\ fseek { alien integer integer } { } define-primitive
+
\ fclose { alien } { } define-primitive
\ <wrapper> { object } { wrapper } define-primitive
: create-app-dir ( vocab bundle-name -- vm )
[
- nip
- [ copy-dll ]
- [ copy-nib ]
- [ "Contents/Resources" append-path make-directories ]
- tri
+ nip {
+ [ copy-dll ]
+ [ copy-nib ]
+ [ "Contents/Resources" append-path make-directories ]
+ [ "Contents/Resources" copy-theme ]
+ } cleave
]
[ create-app-plist ]
[ "Contents/MacOS/" append-path copy-vm ] 2tri
lexer-factory
print-use-hook
root-cache
- vocab-roots
vocabs:dictionary
vocabs:load-vocab-hook
word
{ "fputc" "io.streams.c" (( ch alien -- )) }
{ "fwrite" "io.streams.c" (( string alien -- )) }
{ "fflush" "io.streams.c" (( alien -- )) }
+ { "fseek" "io.streams.c" (( alien offset whence -- )) }
{ "fclose" "io.streams.c" (( alien -- )) }
{ "<wrapper>" "kernel" (( obj -- wrapper )) }
{ "(clone)" "kernel" (( obj -- newobj )) }
-! Copyright (C) 2004, 2008 Slava Pestov.
+! Copyright (C) 2004, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel kernel.private namespaces make io io.encodings
sequences math generic threads.private classes io.backend
-io.files continuations destructors byte-arrays accessors ;
+io.files continuations destructors byte-arrays accessors
+combinators ;
IN: io.streams.c
-TUPLE: c-writer handle disposed ;
+TUPLE: c-stream handle disposed ;
+
+M: c-stream dispose* handle>> fclose ;
+
+M: c-stream stream-seek
+ handle>> swap {
+ { seek-absolute [ 0 ] }
+ { seek-relative [ 1 ] }
+ { seek-end [ 2 ] }
+ [ bad-seek-type ]
+ } case fseek ;
+
+TUPLE: c-writer < c-stream ;
: <c-writer> ( handle -- stream ) f c-writer boa ;
M: c-writer stream-flush dup check-disposed handle>> fflush ;
-M: c-writer dispose* handle>> fclose ;
-
-TUPLE: c-reader handle disposed ;
+TUPLE: c-reader < c-stream ;
: <c-reader> ( handle -- stream ) f c-reader boa ;
[ swap read-until-loop ] B{ } make swap
over empty? over not and [ 2drop f f ] when ;
-M: c-reader dispose*
- handle>> fclose ;
-
M: c-io-backend init-io ;
: stdin-handle ( -- alien ) 11 getenv ;
USING: tools.deploy.config ;
-V{
- { deploy-ui? t }
- { deploy-io 1 }
- { deploy-reflection 1 }
- { deploy-compiler? t }
- { deploy-math? t }
+H{
+ { deploy-name "Color Picker" }
{ deploy-word-props? f }
+ { deploy-ui? t }
+ { deploy-threads? t }
+ { deploy-unicode? f }
{ deploy-c-types? f }
+ { deploy-word-defs? f }
+ { deploy-compiler? t }
+ { deploy-io 2 }
+ { deploy-reflection 1 }
{ "stop-after-last-window?" t }
- { deploy-name "Color Picker" }
+ { deploy-math? t }
}
userenv[CPU_ENV] = tag_object(from_char_string(FACTOR_CPU_STRING));
userenv[OS_ENV] = tag_object(from_char_string(FACTOR_OS_STRING));
userenv[CELL_SIZE_ENV] = tag_fixnum(sizeof(CELL));
- userenv[STACK_TRACES_ENV] = tag_boolean(p->stack_traces);
- userenv[EXECUTABLE_ENV] = (p->executable_path ?
- tag_object(from_native_string(p->executable_path)) : F);
+ userenv[EXECUTABLE_ENV] = (p->executable_path ? tag_object(from_native_string(p->executable_path)) : F);
userenv[ARGS_ENV] = F;
userenv[EMBEDDED_ENV] = F;
gc_off = false;
if(!stage2)
+ {
+ userenv[STACK_TRACES_ENV] = tag_boolean(p->stack_traces);
do_stage1_init();
+ }
}
/* May allocate memory */
}
}
+void primitive_fseek(void)
+{
+ int whence = to_fixnum(dpop());
+ FILE *file = unbox_alien();
+ off_t offset = to_signed_8(dpop());
+
+ switch(whence)
+ {
+ case 0: whence = SEEK_SET; break;
+ case 1: whence = SEEK_CUR; break;
+ case 2: whence = SEEK_END; break;
+ default:
+ critical_error("Bad value for whence",whence);
+ break;
+ }
+
+ if(fseeko(file,offset,whence) == -1)
+ {
+ io_error();
+
+ /* Still here? EINTR */
+ critical_error("Don't know what to do; EINTR from fseek()?",0);
+ }
+}
+
void primitive_fflush(void)
{
FILE *file = unbox_alien();
void primitive_fputc(void);
void primitive_fwrite(void);
void primitive_fflush(void);
+void primitive_fseek(void);
void primitive_fclose(void);
/* Platform specific primitives */
primitive_fputc,
primitive_fwrite,
primitive_fflush,
+ primitive_fseek,
primitive_fclose,
primitive_wrapper,
primitive_clone,