From 2d695d700a55df57a9ee60788f59d11f5cb12e12 Mon Sep 17 00:00:00 2001 From: Danny Yoo Date: Tue, 9 Aug 2011 18:03:15 -0400 Subject: [PATCH] working on external file resources --- examples/images/humpback.jpg | Bin 0 -> 2923 bytes examples/using-resources.rkt | 4 ++++ lang/kernel.rkt | 1 + resource.rkt | 5 ++--- resource/compile-time.rkt | 22 ++++++++++++++++++++++ resource/main.rkt | 4 ++++ resource/structs.rkt | 6 ++++++ 7 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 examples/images/humpback.jpg create mode 100644 examples/using-resources.rkt create mode 100644 resource/compile-time.rkt create mode 100644 resource/main.rkt create mode 100644 resource/structs.rkt diff --git a/examples/images/humpback.jpg b/examples/images/humpback.jpg new file mode 100644 index 0000000000000000000000000000000000000000..aab9368a7fb7334b0e33228ccd02f1a46248c117 GIT binary patch literal 2923 zcmb7Ac{tRK7XHm*iNr8XnnCuhv5cLNb<7|lsYuy1%-DUCrO1|D_N7VJHg;J@l!c4J0&vFxFna zIKU^!-^EQ!_)cJ;ua<&>iw}w9;~gMRCU_A@Zmt9;c^`idg+G<+#3QC+qqQnFc2w}9an52}9tjyVSa*A@&iW1T?(tn14*x1-O*g5z(IQXQI2&DA? z4Q2-bV+V|YyATiz0K-5K7>L;o2mk;G3IPHC1qc8`j*n$yKW0^V05Av)g+f?aK`j54 zfWQza3}E3EVdcZ@ z!EHeF!wz0ggU7qtP9lybTwhvO=u8K9hOtEMgIIfn*MBXbMUGoj>oJI~D&E9D2`8eO zC1IZvBEYVy?+lK_ZzSl~_Y1TgSQ|^mV(1UKN*}%^{-yhn6H*T-M6hfFbZOvV0TO-_ zSn%WEB|U&Hl+3jp*&+13W3CfT=E8c#-AjYE3B55ix%3zs!W4m!t{K@KY81mgR;x*Q zLUpXi;@*kq8V*iwBn^1#sPk(g&+z*VOA@-8RTT9mCx1+?AmhKX>s3kgX3kgas?~`v z4XmbHGs=H6fsD6>&{tBZJ=Lv)mSzsE`zRm3LD4kXsw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9iZScGihe|O=`a7|5dP>XI z1YJ{QxI*;A{-{ho{?aKk%6Pq1+ts-XKJ<03AN8oM31|r_UXI0wyFExHtH$1vJuq0j zI=;k4@X!=_gtlNT_V>#bDIk8?hZ>9!xH(rQDN;6Bt=W!x*&&2i%KF=J+0$ymY5qiz z&PJ-LP@?v#eaFqKCJt|EKmFSO?C4-%Sgy8w*L3dOQe6jZ%-4hWU7z}=L!BqnvX3ux z>C4deE_~VYvVXh4ZRk7CDt`@cmScS2&7&-(YP+c?7t}u7g4*i~k~m$Qkx1+xSv#qi z>nVA+DKWCKuN?Jp)~DsSb46PB)YoE?$A_h+>*C;c;-K9-7^aCb<;6wjj%F5 zm;x6i;(55F(CXbT(~QGDF9y3K9F`kL6k@zsFDe|~?hkwIWfD|s&vtWOTX2beFK2K;8& z(w~-Yq*~5)>>dsEmp33yft`uGU?VhDouvPGXztchc&*}gueSOR*P+yV)sba6mN%~O zmPSm7Fae6dok}~2VdaGE5^6##VHYZ`clvVGEaOzf&0iEgLR!gN;o{;*TAoW$Da^(c zwg>|vglG`drTs=Z1#zO`!?lWr{wkP$)&pNntMXgZNE_16ZimxFbSpCf`0AX@+(3sz z;)e@!cV8ZEVrWK9)|78W0*ll~`na)PJ(f==yVIsu%XXZ;BxL0g`wN3F@|m|%b0;up XHq3)7@4R5EANPlzCL>KpneYDv8&VV5 literal 0 HcmV?d00001 diff --git a/examples/using-resources.rkt b/examples/using-resources.rkt new file mode 100644 index 0000000..cd9d44b --- /dev/null +++ b/examples/using-resources.rkt @@ -0,0 +1,4 @@ +#lang planet dyoo/whalesong + +(require (planet dyoo/whalesong/resource)) +(file-resource "images/humpback.jpg") \ No newline at end of file diff --git a/lang/kernel.rkt b/lang/kernel.rkt index 6526f4f..96d1186 100644 --- a/lang/kernel.rkt +++ b/lang/kernel.rkt @@ -72,6 +72,7 @@ let-values let*-values define-struct + struct if cond else diff --git a/resource.rkt b/resource.rkt index be04a18..87c96f9 100644 --- a/resource.rkt +++ b/resource.rkt @@ -1,5 +1,4 @@ #lang s-exp "lang/kernel.rkt" -(provide (all-defined-out)) - -(define-struct bytes-resource (name type bytes)) +(require "resource/main.rkt") +(provide (all-from-out "resource/main.rkt")) diff --git a/resource/compile-time.rkt b/resource/compile-time.rkt new file mode 100644 index 0000000..c0956a9 --- /dev/null +++ b/resource/compile-time.rkt @@ -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)))])) diff --git a/resource/main.rkt b/resource/main.rkt new file mode 100644 index 0000000..8c5c54f --- /dev/null +++ b/resource/main.rkt @@ -0,0 +1,4 @@ +#lang s-exp "../lang/kernel.rkt" + +(require "compile-time.rkt") +(provide (all-from-out "compile-time.rkt")) diff --git a/resource/structs.rkt b/resource/structs.rkt new file mode 100644 index 0000000..6432f1b --- /dev/null +++ b/resource/structs.rkt @@ -0,0 +1,6 @@ +#lang s-exp "../lang/kernel.rkt" + +(provide (all-defined-out)) + + +(struct resource (path))