working on external file resources
This commit is contained in:
parent
8f7400b602
commit
2d695d700a
BIN
examples/images/humpback.jpg
Normal file
BIN
examples/images/humpback.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
4
examples/using-resources.rkt
Normal file
4
examples/using-resources.rkt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#lang planet dyoo/whalesong
|
||||||
|
|
||||||
|
(require (planet dyoo/whalesong/resource))
|
||||||
|
(file-resource "images/humpback.jpg")
|
|
@ -72,6 +72,7 @@
|
||||||
let-values
|
let-values
|
||||||
let*-values
|
let*-values
|
||||||
define-struct
|
define-struct
|
||||||
|
struct
|
||||||
if
|
if
|
||||||
cond
|
cond
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#lang s-exp "lang/kernel.rkt"
|
#lang s-exp "lang/kernel.rkt"
|
||||||
|
|
||||||
(provide (all-defined-out))
|
(require "resource/main.rkt")
|
||||||
|
(provide (all-from-out "resource/main.rkt"))
|
||||||
(define-struct bytes-resource (name type bytes))
|
|
||||||
|
|
22
resource/compile-time.rkt
Normal file
22
resource/compile-time.rkt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#lang s-exp "../lang/kernel.rkt"
|
||||||
|
|
||||||
|
(provide file-resource)
|
||||||
|
|
||||||
|
|
||||||
|
(require "structs.rkt")
|
||||||
|
|
||||||
|
;; Macros for recording the definition of resources in a program.
|
||||||
|
(require (for-syntax racket/base))
|
||||||
|
|
||||||
|
|
||||||
|
;; file-resource:
|
||||||
|
;;
|
||||||
|
(define-for-syntax (file-resource stx)
|
||||||
|
(syntax-case stx ()
|
||||||
|
[(_ path)
|
||||||
|
(syntax/loc stx
|
||||||
|
(let-syntax ([compile-time-code
|
||||||
|
(lambda (stx)
|
||||||
|
(displayln "at compile time")
|
||||||
|
#'(void))])
|
||||||
|
(resource path)))]))
|
4
resource/main.rkt
Normal file
4
resource/main.rkt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#lang s-exp "../lang/kernel.rkt"
|
||||||
|
|
||||||
|
(require "compile-time.rkt")
|
||||||
|
(provide (all-from-out "compile-time.rkt"))
|
6
resource/structs.rkt
Normal file
6
resource/structs.rkt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#lang s-exp "../lang/kernel.rkt"
|
||||||
|
|
||||||
|
(provide (all-defined-out))
|
||||||
|
|
||||||
|
|
||||||
|
(struct resource (path))
|
Loading…
Reference in New Issue
Block a user