improve and module-ize mxdemo, change executable creator to prefer exetsnions (such as mxmain)
svn: r6012
This commit is contained in:
parent
6102d0a6a6
commit
a2cbc68378
|
@ -364,7 +364,9 @@
|
|||
(error 'create-embedding-executable
|
||||
"cannot use a _loader extension: ~e"
|
||||
file)
|
||||
(make-extension file)))))]
|
||||
(make-extension file))))
|
||||
;; Prefer extensions if we're handling them:
|
||||
(not on-extension))]
|
||||
[name (let-values ([(base name dir?) (split-path filename)])
|
||||
(path->string (path-replace-suffix name #"")))]
|
||||
[prefix (let ([a (assoc filename prefixes)])
|
||||
|
@ -373,6 +375,8 @@
|
|||
(generate-prefix)))])
|
||||
(cond
|
||||
[(extension? code)
|
||||
(when verbose?
|
||||
(fprintf (current-error-port) " using extension: ~s~n" (extension-path code)))
|
||||
(set-box! codes
|
||||
(cons (make-mod filename module-path code
|
||||
name prefix (string->symbol
|
||||
|
|
|
@ -20,7 +20,7 @@ _MysterX_
|
|||
Installation
|
||||
------------
|
||||
|
||||
Two Windows .DLL's support low-level operations in MysterX:
|
||||
Two Windows DLLs support low-level operations in MysterX:
|
||||
"myspage.dll" and "myssink.dll". Both are installed in the registry
|
||||
(using `REGSVR32 <name-of-DLL>') when Setup PLT runs the the MysterX
|
||||
post-installer. If you move the location of your PLT installation,
|
||||
|
@ -30,6 +30,37 @@ _MysterX_
|
|||
to version 369.4, myssink.dll was version-specific; its GUID was
|
||||
changed when it was made version-independent.)
|
||||
|
||||
If you build a stand-alone executable that uses MysterX, you need to
|
||||
specifically include "myspage.dll" and "myssink.dll" with your
|
||||
distribution, and the DLLs will need to be registered on the end
|
||||
user's machine. One way to do that is to include the following little
|
||||
setup program (as an executable) in your distribution:
|
||||
|
||||
(module setup mzscheme
|
||||
(require (lib "runtime-path.ss")
|
||||
(lib "process.ss"))
|
||||
|
||||
;; Ensure that DLLs are included with the distibution:
|
||||
(define-runtime-path myspage-dll '(so "myspage"))
|
||||
(define-runtime-path myssink-dll '(so "myssink"))
|
||||
|
||||
;; Register the DLLs:
|
||||
(define regsvr32
|
||||
(path->string (find-executable-path "regsvr32.exe" #f)))
|
||||
(system* regsvr32 (path->string myspage-dll))
|
||||
(system* regsvr32 (path->string myssink-dll)))
|
||||
|
||||
Running a Demo
|
||||
--------------
|
||||
|
||||
Try
|
||||
|
||||
(require (lib "mxdemo.ss" "mysterx"))
|
||||
|
||||
The demo requires the MSCal Calendar control. The calendar control
|
||||
is normally installed with Microsoft Office, but it can also be
|
||||
downloaded from elsewhere; look for "mscal.ocx".
|
||||
|
||||
Loading
|
||||
-------
|
||||
|
||||
|
|
|
@ -1,10 +1,24 @@
|
|||
;;; mxdemo.ss -- demo program for MysterX
|
||||
|
||||
;;; requires Office 97/2000/XP to be installed for Calendar Control to work
|
||||
;;; Requires the MSCal Calendar control.
|
||||
;;; The calendar control is normally installed with
|
||||
;;; MS Office, but it can also be downloaded from
|
||||
;;; elsewhere. Look for "mscal.ocx".
|
||||
|
||||
(module mxdemo mzscheme
|
||||
|
||||
(require (lib "class.ss"))
|
||||
(require (lib "mysterx.ss" "mysterx"))
|
||||
|
||||
(require (lib "runtime-path.ss")
|
||||
(lib "system.ss"))
|
||||
;; Ensure that DLLs are included with the distibution:
|
||||
(define-runtime-path myspage-dll (so "myspage"))
|
||||
(define-runtime-path myssink-dll (so "myssink"))
|
||||
;; Register them every time we start:
|
||||
(system* "regsvr32.exe" "/s" myspage-dll)
|
||||
(system* "regsvr32.exe" "/s" myssink-dll)
|
||||
|
||||
; the browser with the calendar
|
||||
|
||||
(define calwb (instantiate mx-browser%
|
||||
|
@ -82,15 +96,15 @@
|
|||
"</table>"
|
||||
|
||||
"<table align=center>"
|
||||
|
||||
"<td><BUTTON id=\"Rub-me\">Rub me!</BUTTON></td>"
|
||||
|
||||
"</table>"
|
||||
|
||||
"<table align=center>"
|
||||
|
||||
"<td><BUTTON id=\"About\">About</BUTTON></td>"
|
||||
"</table>"
|
||||
|
||||
"<table align=center>"
|
||||
"<td><BUTTON id=\"Quit\">Quit</BUTTON></td>"
|
||||
"</table>"
|
||||
|
||||
"<p>"
|
||||
|
@ -114,6 +128,10 @@
|
|||
(send reflector set-color! 'black)
|
||||
(send reflector set-background-color! 'white)))))
|
||||
|
||||
(define (quit-handler ev)
|
||||
(when (send ev click?)
|
||||
(exit)))
|
||||
|
||||
(define (about-handler ev)
|
||||
(when (send ev click?)
|
||||
(com-invoke cal "AboutBox")))
|
||||
|
@ -162,7 +180,8 @@
|
|||
(com-invoke cal "NextYear")))
|
||||
|
||||
(define button-handlers
|
||||
`(("About" ,about-handler)
|
||||
`(("Quit" ,quit-handler)
|
||||
("About" ,about-handler)
|
||||
("Hide" ,hide-handler)
|
||||
("Show" ,show-handler)
|
||||
("Rub-me" ,rub-me-handler)
|
||||
|
@ -191,4 +210,5 @@
|
|||
|
||||
(send ctrlwb handle-events)
|
||||
|
||||
|
||||
;; Wait
|
||||
(sync never-evt))
|
||||
|
|
|
@ -323,7 +323,7 @@ _modread.ss_: reading module source code
|
|||
_modcode.ss_: getting module compiled code
|
||||
======================================================================
|
||||
|
||||
> (get-module-code path [compiled-subdir compile-proc ext-proc]) -
|
||||
> (get-module-code path [compiled-subdir compile-proc ext-proc prefer-ext?]) -
|
||||
returns a compiled expression for the declaration of the module
|
||||
specified by `module-path-v'. The `module-path-v' argument is a
|
||||
quoted module path, as for MzScheme's `dynamic-require' using the
|
||||
|
@ -347,10 +347,11 @@ _modcode.ss_: getting module compiled code
|
|||
(in one of the directories specified by `compiled-subdir'), then it
|
||||
is used instead of the source. Native-code versions of `path' are
|
||||
ignored --- unless only a native-code version exists (i.e., `path'
|
||||
itself does not exist). If only a native-code version exists, it is
|
||||
supplied to `ext-proc' when `ext-proc' is #f, or an exception is
|
||||
raised (to report that an extension file cannot be used) when
|
||||
`ext-proc' is #f.
|
||||
itself does not exist), or `prefer-ext?' is true and the native-code
|
||||
file is not a _loader variant. If a native-code version is prefer or
|
||||
is the only file that exists, it is supplied to `ext-proc' when
|
||||
`ext-proc' is #f, or an exception is raised (to report that an
|
||||
extension file cannot be used) when `ext-proc' is #f.
|
||||
|
||||
> moddep-current-open-input-file
|
||||
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
[get-module-code ([path-string?]
|
||||
[(and/c path-string? relative-path?)
|
||||
(any/c . -> . any)
|
||||
(or/c false/c (path? boolean? . -> . any))]
|
||||
(or/c false/c (path? boolean? . -> . any))
|
||||
any/c]
|
||||
. opt-> .
|
||||
any)])
|
||||
|
||||
|
@ -64,7 +65,7 @@
|
|||
|
||||
(define/kw (get-module-code path
|
||||
#:optional
|
||||
[sub-path "compiled"] [compiler compile] [extension-handler #f])
|
||||
[sub-path "compiled"] [compiler compile] [extension-handler #f] [prefer-so? #f])
|
||||
(unless (path-string? path)
|
||||
(raise-type-error 'get-module-code "path or string (sans nul)" path))
|
||||
(let*-values ([(path) (resolve path)]
|
||||
|
@ -90,16 +91,17 @@
|
|||
(cond
|
||||
;; Use .zo, if it's new enough
|
||||
[(date>=? zo path-d) (read-one zo #f)]
|
||||
;; Otherwise, use source if it exists
|
||||
[path-d (with-dir (lambda () (compiler (read-one path #t))))]
|
||||
;; No source --- maybe there's an .so?
|
||||
[(and (not path-d) (date>=? so path-d))
|
||||
;; Maybe there's an .so? Use it only if we don't prefer source.
|
||||
[(and (or (not path-d) prefer-so?)
|
||||
(date>=? so path-d))
|
||||
(if extension-handler
|
||||
(extension-handler so #f)
|
||||
(raise (make-exn:get-module-code
|
||||
(format "get-module-code: cannot use extension file; ~e" so)
|
||||
(current-continuation-marks)
|
||||
so)))]
|
||||
;; Use source if it exists
|
||||
[path-d (with-dir (lambda () (compiler (read-one path #t))))]
|
||||
;; Or maybe even a _loader.so?
|
||||
[(and (not path-d)
|
||||
(date>=? _loader-so path-d)
|
||||
|
|
Loading…
Reference in New Issue
Block a user