id
int64
0
45.1k
file_name
stringlengths
4
68
file_path
stringlengths
14
193
content
stringlengths
32
9.62M
size
int64
32
9.62M
language
stringclasses
1 value
extension
stringclasses
6 values
total_lines
int64
1
136k
avg_line_length
float64
3
903k
max_line_length
int64
3
4.51M
alphanum_fraction
float64
0
1
repo_name
stringclasses
779 values
repo_stars
int64
0
882
repo_forks
int64
0
108
repo_open_issues
int64
0
90
repo_license
stringclasses
8 values
repo_extraction_date
stringclasses
146 values
sha
stringlengths
64
64
__index_level_0__
int64
0
45.1k
exdup_ids_cmlisp_stkv2
sequencelengths
1
47
19,665
DefFunc.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/CommonLisp/Samples/DefFunc.lisp
(defun square (x) "Calculates the square of the single-float x." (declare (single-float x) (optimize (speed 3) (debug 0) (safety 1))) (the single-float (* x x)))
172
Common Lisp
.lisp
4
39.5
71
0.654762
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
21a482a74e4ed338f93ef156da3e1f4f009e12f8461212657b8cd29b883e8977
19,665
[ -1 ]
19,667
AvailableShells.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/CommonLisp/Samples/AvailableShells.lisp
(defun available-shells (&optional (file #p"/etc/shells")) (list-matching-lines file (lambda (line) (and (plusp (length line)) (char= (char line 0) #\/) (pathname (string-right-trim '(#\space #\tab) line))))))
254
Common Lisp
.lisp
8
25.25
58
0.565041
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
8c548cfc42a94d215157687700b6dc3f6a35b1fe82c88951c7cdd562e436ce36
19,667
[ -1 ]
19,668
LexicalHelloWorld.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/CommonLisp/Samples/LexicalHelloWorld.lisp
(defvar *stashed*) ;; will hold a function (tagbody (setf *stashed* (lambda () (go some-label))) (go end-label) ;; skip the (print "Hello") some-label (print "Hello") end-label) -> NIL
210
Common Lisp
.lisp
8
22.125
48
0.606965
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
4a949e2c4673ae355acd35ff65d1b0fefe7a9d1ece0905eb52f03905feaee094
19,668
[ -1 ]
19,675
UNTIL.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/CommonLisp/Samples/UNTIL.lisp
;; expansion of UNTIL makes liberal use of DO (defmacro until (expression &body body) `(do () (,expression) ,@body)) ;; macrolet establishes lexical operator binding for DO (macrolet ((do (...) ... something else ...)) (until (= (random 10) 0) (write-line "Hello")))
278
Common Lisp
.lisp
6
43.5
56
0.660517
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
593787a33d5cab9a90fb4133c9f0ba862a329155d1bc61c0e0908e9b6ed681bd
19,675
[ -1 ]
19,677
BirthdayParadox_V1.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/CommonLisp/Samples/BirthdayParadox_V1.lisp
(defconstant +year-size+ 365) (defun birthday-paradox (probability number-of-people) (let ((new-probability (* (/ (- +year-size+ number-of-people) +year-size+) probability))) (if (< new-probability 0.5) (1+ number-of-people) (birthday-paradox new-probability (1+ number-of-people)))))
367
Common Lisp
.lisp
8
34.625
67
0.564246
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
42cf95d3d9d1ec30b59e2593713e3416bc2b76b21f154c70d2c544323e72edb5
19,677
[ -1 ]
19,686
makefile.mk
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/makefile.mk
# Start of script # The Makefile for this project # Rename the secondary copying license # Since I don't know how to just rename a file, I will copy it and delete the original, that is as close as I can get with GNU Make right now copy /COPYINGL to /COPYING rm -f /COPYINGL echo "COPYING license file has been corrected." # This syntax isn't valid yet, I don't know how to write in GNU Make very well # File info # File type: Makefile (MAKEFILE, *.mk) # File version: 1 (Wednesday, August 18th 2021 at 6:41 pm) # Line count (including blank lines and compiler line): 14 # End of script
586
Common Lisp
.l
13
44.076923
141
0.760908
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
de9a8fa1daea17459f42137b346a6f0d3d82aa0ed189397102f782fb05133253
19,686
[ -1 ]
19,687
DRM-free_label.en.svg
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/DRM-free_label.en.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" version="1.1" x="0px" y="0px" width="120px" height="120px" viewBox="0 0 120 120" enable-background="new 0 0 120 120" xml:space="preserve" id="svg2" inkscape:version="0.48.4 r9939" sodipodi:docname="DRM-free label.en.svg"><metadata id="metadata32"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title /></cc:Work></rdf:RDF></metadata><defs id="defs30" /><sodipodi:namedview pagecolor="#ffffff" bordercolor="#666666" borderopacity="1" objecttolerance="10" gridtolerance="10" guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" inkscape:window-width="640" inkscape:window-height="480" id="namedview28" showgrid="false" inkscape:zoom="1.9666667" inkscape:cx="60.000002" inkscape:cy="60.000002" inkscape:window-x="0" inkscape:window-y="27" inkscape:window-maximized="0" inkscape:current-layer="g5" /><g id="Reverse_Logos" style="stroke:none"><g id="g5" style="stroke:none;fill:#000000"><path fill="none" stroke="#FFFFFF" stroke-width="2.7423" stroke-miterlimit="10" d="M85.961,97.259 c-7.566,5.27-16.65,8.136-25.977,8.136c-12.141,0-23.545-4.716-32.105-13.276c-8.066-8.067-12.768-18.801-13.236-30.225 c-0.41-10.01,2.449-19.757,8.1-27.855l-9.15-9.15C5.529,35.529,1.371,48.606,1.85,62.103c0.525,14.766,6.555,28.639,16.982,39.064 c10.975,10.975,25.586,17.02,41.146,17.02c12.734,0,25.072-4.168,35.131-11.779L85.961,97.259z" id="path7" style="stroke:#000000;fill:none" /><path fill="none" stroke="#FFFFFF" stroke-width="2.7423" stroke-miterlimit="10" d="M33.031,23.474 c7.764-5.732,17.238-8.869,26.982-8.869c12.143,0,23.545,4.714,32.105,13.274c8.066,8.067,12.77,18.802,13.236,30.226 c0.43,10.432-2.699,20.572-8.83,28.865l9.127,9.126c8.561-10.813,12.99-24.286,12.498-38.2 c-0.525-14.765-6.557-28.639-16.982-39.064C90.193,7.856,75.58,1.813,60.021,1.813c-13.152,0-25.887,4.438-36.117,12.533 L33.031,23.474z" id="path9" style="stroke:#000000;fill:none" /><g id="g11" style="stroke:none;fill:#000000"><path fill="#FFFFFF" d="M28.188,35.055h7.219c1.854,0,3.553,0.226,5.095,0.677s2.863,1.166,3.967,2.143 c1.103,0.978,1.961,2.231,2.575,3.76c0.614,1.529,0.921,3.372,0.921,5.527s-0.301,4.01-0.902,5.564s-1.447,2.833-2.537,3.835 c-1.091,1.003-2.382,1.742-3.873,2.218c-1.491,0.477-3.115,0.714-4.869,0.714h-7.595V35.055z M35.031,54.306 c0.877,0,1.704-0.106,2.481-0.32c0.776-0.212,1.447-0.583,2.012-1.109c0.563-0.526,1.009-1.253,1.335-2.181 c0.325-0.927,0.488-2.105,0.488-3.534s-0.163-2.594-0.488-3.497c-0.326-0.903-0.771-1.604-1.335-2.106 c-0.564-0.501-1.235-0.846-2.012-1.034c-0.777-0.188-1.604-0.282-2.481-0.282h-0.376v14.062H35.031z" id="path13" style="stroke:none;fill:#000000" /><path fill="#FFFFFF" d="M62.707,59.494l-4.211-8.196h-2.481v8.196h-6.467V35.055h9.249c1.303,0,2.551,0.126,3.741,0.376 c1.19,0.251,2.23,0.677,3.121,1.278c0.889,0.602,1.598,1.41,2.124,2.425s0.789,2.288,0.789,3.816 c0,1.755-0.356,3.209-1.071,4.362c-0.714,1.153-1.673,2.055-2.876,2.707l5.301,9.475H62.707z M56.015,46.185h2.331 c2.606,0,3.91-1.078,3.91-3.234c0-1.053-0.332-1.779-0.996-2.181c-0.664-0.4-1.636-0.602-2.914-0.602h-2.331V46.185z" id="path15" style="stroke:none;fill:#000000" /><path fill="#FFFFFF" d="M70.493,35.055h6.692l3.835,10.152l1.354,3.985h0.15l1.354-3.985l3.685-10.152h6.692v24.439h-6.016 v-7.219c0-0.626,0.031-1.316,0.095-2.068c0.062-0.752,0.131-1.523,0.206-2.312s0.163-1.56,0.264-2.312 c0.1-0.752,0.188-1.429,0.263-2.03h-0.15l-2.03,5.715l-3.384,8.234h-2.406l-3.384-8.234l-1.955-5.715h-0.15 c0.075,0.602,0.163,1.278,0.264,2.03c0.1,0.752,0.188,1.522,0.263,2.312s0.145,1.561,0.207,2.312s0.094,1.441,0.094,2.068v7.219 h-5.94V35.055z" id="path17" style="stroke:none;fill:#000000" /><path fill="#FFFFFF" d="M27.937,63.56h14.459v4.911h-8.594v4.229h7.366v4.91h-7.366v8.116h-5.865V63.56z" id="path19" style="stroke:none;fill:#000000" /><path fill="#FFFFFF" d="M55.531,85.726l-3.819-7.434h-2.251v7.434h-5.865V63.56h8.389c1.182,0,2.313,0.114,3.394,0.341 c1.079,0.227,2.022,0.614,2.83,1.159c0.807,0.545,1.449,1.279,1.927,2.2c0.478,0.92,0.716,2.075,0.716,3.461 c0,1.592-0.323,2.91-0.972,3.956c-0.647,1.046-1.518,1.865-2.608,2.456l4.808,8.593H55.531z M49.461,73.654h2.114 c2.364,0,3.547-0.977,3.547-2.933c0-0.955-0.302-1.614-0.904-1.978s-1.482-0.546-2.643-0.546h-2.114V73.654z" id="path21" style="stroke:none;fill:#000000" /><path fill="#FFFFFF" d="M62.627,63.56h14.322v4.911h-8.457v3.478h7.229v4.911h-7.229v3.956h8.798v4.911H62.627V63.56z" id="path23" style="stroke:none;fill:#000000" /><path fill="#FFFFFF" d="M79.203,63.56h14.322v4.911h-8.457v3.478h7.229v4.911h-7.229v3.956h8.798v4.911H79.203V63.56z" id="path25" style="stroke:none;fill:#000000" /></g></g></g><g id="Logos" style="stroke:#000000" /></svg>
5,829
Common Lisp
.l
93
54.516129
637
0.628248
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
d069a70daea0493e6fb5c6eea896aa27f8bd1fec033885fc9997e323af621f5b
19,687
[ -1 ]
19,689
AUTOMATE2001.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/AUTOMATE2001.yml
# A set of tasks for the Automate2001 bot to perform here automate2001_tasks: isAlldone: "False" - Automate-All-ContributorSrc: - Automate-Pull-Requests-archival isAdone: "False" Automate-Index-file isBdone: "False" Automate-Issue-archival isCdone: "False" - Automate-RepoData: - Automate-RepoData-Description isDDone: "False" Automate-RepoData-GitHubLink isEDone: "False" Automate-RepoData-GitHubGitLink isFDone: "False" Automate-RepoData-Linked isGDone: "False" Automate-RepoData-Topics isHDone: "False" # File version: 1 (2022, Tuesday, February 22nd at 8:07 pm)
569
Common Lisp
.l
26
20.769231
59
0.827778
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e817fbb3381ec151e0880a501c7388ac68734decd917887a956bea92f0f75343
19,689
[ -1 ]
19,690
SNU_Blue_and_gold_Legacy_Icon_SVG.svg
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/SNU_Blue_and_gold_Legacy_Icon_SVG.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!-- Created with Inkscape (http://www.inkscape.org/) --> <svg width="256.0px" height="256.0px" viewBox="0 0 256.0 256.0" version="1.1" id="SVGRoot" sodipodi:docname="SNU_Blue_and_gold_Legacy_Icon_SVG.svg" xml:space="preserve" inkscape:version="1.2.1 (2ed6d7ae0b, 2022-08-22, custom)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview id="namedview14" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:showpageshadow="2" inkscape:pageopacity="0.0" inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" inkscape:document-units="px" showgrid="true" inkscape:zoom="0.70199214" inkscape:cx="397.44035" inkscape:cy="78.348455" inkscape:window-width="1920" inkscape:window-height="967" inkscape:window-x="0" inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="layer1"><inkscape:grid type="xygrid" id="grid20" /></sodipodi:namedview><defs id="defs9" /><g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1"><image width="256" height="256" preserveAspectRatio="none" style="image-rendering:optimizeQuality" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAAXNSR0IArs4c6QAAAARnQU1BAACx jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA1tSURBVHhe7dpdjvaoGYThbCRryWk2nF1kHVlH /IkRU33b5s+AcVPSdTRdPPCCS5qR5h//+vd/zbblAtjWXADbmgtgW3MBbGsugG3NBbCtuQC2NRfA ttatAP/53z+zsMTsde0FwMfdAAPN5qsuAD7iLrCF2TQVBcBX2x22M5ugqAD4UofC1mZDZQqArzMN a8+QT8BCs0FSBcBHeYZ8FYw6Q95e9Isf5boA8QdfQvghDAeEbb7f/SIXBcAPVkh2hI0UkjYZnuOA wKexAPipEWKDYNMIMZsJbxEg811FBUBmKGwdIGMz4S0Ukl/0owD4eYEGpsEZDgjYNHgIQPhz/i4A ftgh/ukVOMwBAZsDr3CG/Le4AJaBV7iEJR/yVwHwew4x8SIc6YCATXB+AvyTQJd8yHUB4p9ft+zB 9nH5BPiHQVzyIS6AZdw9Af55FAOf8KcAi/+AxY/36yXuH3+KNLM4F8Ay0vePv0aILcsFsIzs/SMQ IbYmF8AySu4fmQixBbkAllF+/0gGyKzGBbCMqvtHOEBmKX8KcFj2xDjYAQEbrfb+kY8QW8THCoC/ 2gQNT4AlEWIruC7AISZehCMdELAJ2p4AqyLEXvdXAQ446CH+6RU4zAEBm6P5FbAwQuxdLoBlPHwF LA+QedHfBTjglAf960w4xgEBm+b5Q2BCgMxbMgUINDMato4Qs2m6PASGRIjN96MAB5wvQmwQbBoh ZjP1egvMiRCbjAU44HwKyY6wkULSJuv4HBgVITbTRQEOOB8g/BCGA8I2X98XwbQIsWmuCxDgiGfI V8GoM+TtLd3fBQMjxOZIFeCAIyZg4SUsScBCe9Ggp8HYAJkJMgUIcMqhsLW9btwDYXKAzGhFBQhw 0O6wnS1i6DNheITYOBUFCHDQLrCFLWX0Y2F+hNgg1QWIcNwGGGhrmvBq2CJCbIT2AgCOfglL7BPm PCJ2iRDrrlsB7Lea9kViowixvlwAy5j5OR6wXYBMRy6AZUz7FiPsGCDTiwtgGXM+RMCmEWLPuQCW MfoTvIN9I8QecgEsY+j3l4atI8SecAEsY9zHVwK7R4g1cwEsY9CXVwVnCJBp4wJYxojPrgGOESDT wAWwjO7fXDOcJEKsigtgGR2/tudwmAixci6AZfT61HrBeSLECrkAltHlO+sLR4oQK+ECWMbzj2wE nCpCLMsFsIyHX9hQOFuATJoLYBlPPq8JcLwAmQQXwDKav61pcMIIsUsugGU0fFXz4ZARYmcugGXU flJvwTkjxMAFsAx8T1+EX6RcAMvAx/RR+FGRC2AZ+JI+Cj8qcgEsA1/SR+FHRS6A5eFj+hz8HOUC 2NZcANuaC2BbcwFsay6Abc0FsK25ALY1F8C25gLY1lwA25oLYFtzAWxrLoBtzQWwre1bAPwfsyVK 1sZMApaUwIQz5HsZtIWOjZB5ApMTXIAKJWtjJgFLSmDCGfK9DNpCx0bIPIHJCZsWAPdVomRtzCRg SQlMOEO+l0Fb6NgImScwOc0FKFWyNmYSsKQEJpwh38ugLXRshMwTmJz2mwuAexkNu1/CklqYFiDT y6AtdGyEzBOYnOUCdIPdL2FJLUwLkOll0BY6NkLmCUzO+rUFwL2Mht0vYUktTAuQ6WXQFjo2QuYJ TC7hAvSB3S9hSS1MC5DpZdAWOjZC5glMLvE7C4B7UUimYe0drKqCUXewqhzmKCSrYJRCsg1mKiQf cgFSsPYOVlXBqDtYVQ5zFJJVMEoh2QYzFZIP/cIC4L4UkmlYewerqmDUHawqhzkKySoYpZBsg5kK yedcgFtYewerqmDUHawqhzkKySoYpZBsg5kKyed+QwFwRwrJNpipkKyCUSUwIQ1rFZJVMEoh2QYz FZJduAB5mKmQrIJRJTAhDWsVklUwSiHZBjMVkl18vgC4I4VkG8xUSFbBqBKYkIa1CskqGKWQbIOZ CsleXIAMzFRIVsGoEpiQhrUKySoYpZBsg5kKyV6+XQDckUJyKThqCUxIw1qFZBWMUki2wUyFZEcu wAtw1BKYkIa1CskqGKWQbIOZCsmOPlwA3JFCcik4aglMSMNahWQVjFJItsFMhWRfLsBsOGoJTEjD WoVkFYxSSLbBTIVkX18tAO7oDla9DsdTVZk7yCskq2CUQrINZioku3MBpsLxVFXmDvIKySoYpZBs g5kKye4+WQDc0R2seh2Op6oyd5BXSFbBKIVkG8xUSI7gAsyD46mqzB3kFZJVMEoh2QYzFZIjfPg/ gg+4rxGwYzOMVVWZO8grJKtglEKyDWYqJAdxATKwYzOMVVWZO8grJKtglEKyDWYqJAf5cAFwXyNg x2YYq6oyd5BXSFbBKIVkG8xUSI7jAqRgx2YYq6oyd5BXSFbBKIVkG8xUSI7z7X8FCnB3I2DHKhil kAyQUUgGyCgkq2CUQrINZiokh3IBimDHKhilkAyQUUgGyCgkq2CUQrINZiokh/p8AXB3I2DHKhil kAyQUUgGyCgkq2CUQrINZiokR3MB8rBjFYxSSAbIKCQDZBSSVTBKIdkGMxWSo/2GfwV6Dm9wB6uy sFwheYa8qso0wCiFZBvMVEhO4AL8gWe4g1VZWK6QPENeVWUaYJRCsg1mKiQncAFS76GwKgvLFZJn yKuqTAOMUki2wUyF5BwuQOpJFFZlYblC8gx5VZVpgFEKyTaYqZCcwwX4G95DIZmF5QrJM+RVVaYB Rikk22CmQnIaF+BveBKFZBaWKyTPkFdVmQYYpZBsg5kKyWlcgL/gPRSSWViukDxDXlVlGmCUQrIN ZiokZ3IB/oInUUhmYblC8gx5VZVpgFEKyTaYqZCcad0C4I4Uks9hvkIyC8sVkmlYWwITqmCUQrIN ZiokJ3MB/sB8hWQWlisk07C2BCZUwSiFZBvMVEhOtmgBcEcKyecwXyGZheUKyTSsLYEJVTBKIdkG MxWS87kAPffCcoVkGtaWwIQqGKWQbIOZCsn5ViwA7kgh+RzmKySzsFwhmYa1JTChCkYpJNtgpkLy FS4At4iQzMJyhWQa1pbAhCoYpZBsg5kKyVcsVwDckULyOcxXSGZhuUIyDWtLYEIVjFJItsFMheRb XIBrSGZhuUIyDWtLYEIVjFJItsFMheRb1ioA7ugOVpXDHIVkFYxSSJbDnDtY1QxjFZJpWKuQXIQL 8Bckq2CUQrIc5tzBqmYYq5BMw1qF5CIWKgDu6w5WlcMchWQVjFJIlsOcO1jVDGMVkmlYq5Bchwvw B5JVMEohWQ5z7mBVM4xVSKZhrUJyHasUAPc1E05yCUt6wS4BMnewqhnGjoAdl+ICuACc3B12XMoS BcB9zYSTXMKSXrBLgMwdrGqGsSNgx9W4ADzMGZb0gl0CZO5gVTOMHQE7rub9AuC+VEmmRJzTAKN6 wS5nyCsku8N2JTDhQ1yADIzqBbucIa+Q7A7blcCED3m5ALhHVZIpEec0wKhesMsZ8grJ7rBdCUz4 FhcgBaN6wS5nyCsku8N2JTDhW5b4j2Czt7gAtjUXwLbmAtjWXADbmgtgW3MBbGsugG3NBbCtuQC2 NRfAtuYC2NZcANuaC2BbcwFsay6Abc0FsK25ALY1F8C25gLY1lwA25oLYFtzAWxrLoBtzQWwrbkA tjUXwLbmAtjWXADbmgtgW3MBbGsugG3NBbCtuQC2NRfAtuYC2NZcANuaC2BbcwFsay6Abc0FsK25 ALY1F8C25gLY1lwA25oLYFtzAWxrLoBtzQWwrbkAtjUXwLbmAtjWXACb4T//+2ca8tOkCoAjrgPn tNXgvdpg5iAugHWDZ+oFu/TlAlgHeKBBsGkXLoC1w7vMgTM85AJYIzxKAhbewao0rG1WUQD8daZ1 TmIHPMclLKmFaZewpI0LYBXwEGfIP4f5Z8jXcgGsFF4BEO4O2ykkq7gAVgRPoJAcB/sqJMu5AJaH +48QmwNniBAr5AJYBi4/QGY+nCdApoQLYCm4+QCZt+BUATJZLoDdwrUHyLwLZwuQSXMB7Bau/YDA CnDCAwJpLoBdw50fEFgHznlAIMEFsGvfunOc9oDAHRfALuDCDwisBqc9IHDHBbALX7zwtjO7AEa4 7QMCa8KZDwhccgGMvnvbDSd3AYy+e9sNJ3cB7Adc9QGBxdUe3gWwH75+1bXndwHsh69fde35XQD7 4etXXXt+F8B++PpV157fBbAfvn7Vted3AeyHr1917fldAPsBV31AYHG1h3cBjL572w0ndwGMvnvb DSd3AYxw2wcE1oQzHxC45ALYhS9eeNuZXQC7gAs/ILAanPaAwB0XwC7gwg8IrAanPSBwxwWwa7jz AwLrwDkPCCS4AHYL135AYAU44QGBNBfAbuHaA2TehbMFyKS5AJaCmw+QeQtOFSCT5QJYBi4/QGY+ nCdApoQLYHm4/wixOXCGCLFCLoAVwRNEiI2G3SPEyrkAVgqvoJAcATsqJKtUFGAdOKdNg4c4Q/45 zD9DvpYLYNXwHJewpBamXcKSNi6AtcCLpGHtHaxKw9pmLoC1w7vMgTM85ALYU3idcbBvF6kCmFXB 99oLdunLBbD+8AW3wcxBXAAbDl/2HayawwWwrbkAtjUXwLbmAtjWXADb2L//+381Im/shByQMwAA AABJRU5ErkJggg== " id="image101" x="1.2304332" y="2.059566" /></g></svg>
6,438
Common Lisp
.l
112
54.473214
117
0.899289
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
792cfeeff2f73e84614ea95b1ac2679e3dabfcc177fdef7ef6ab5c03b27b8ff6
19,690
[ -1 ]
19,692
pull_request_template.md
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/pull_request_template.md
*** # Creating a pull request Thank you for taking the time to create a pull request in this repository! Please fill out this form before submitting your PR. **Note:** you can change the language of the formatting if needed, but it must be valid syntax. Supported languages include: ASCIIDoc, Org mode, Markdown, WikiText, ReStructuredText, Creole, Pod, RDoc, Textile, and plain text. Be sure to change thw `markdown` tag to the appropriate language. Provide a general summary of your changes in the Title above ```markdown Your summary description (title) goes here ``` ## Description Describe your changes in detail ```markdown Your issue description (body) goes here ``` ## Related Issue - [ ] This project only accepts pull requests related to open issues - [ ] If suggesting a new feature or change, please discuss it in an issue first - [ ] If fixing a bug, there should be an issue describing it with steps to reproduce - [ ] Please link to the issue here: ```markdown Link to the issue here, #__ ``` ## Motivation and Context Why is this change required? What problem does it solve? ```markdown ``` ## How Has This Been Tested? - [ ] Please describe in detail how you tested your changes. - [ ] Include details of your testing environment, and the tests you ran to. - [ ] see how your change affects other areas of the code, etc. ## Screenshots (if appropriate): Please include the screenshots inside your pull request as well as a local link (hard copy) **Warning:** `.webp` and `.heif` images are not accepted. Please convert them to a different format (such as PNG, JPG, JPEG, JIF, GIF, TIF, etc.) **Warning:** Images outside of `/.github/Pull_Requests/Queue/PR/` are not accepted, and will be removed from the PR within 24 hours if not fixed ```markdown Remove this section, and only include the links if you use this section. Be sure to delete image fields that are not needed. Max screenshots per PR: 5. Also, if screenshots aren't necessary, please delete this entire section ![Example1](/.github/Pull_Requests/Queue/PR/Image.png) ![Example2](/.github/Pull_Requests/Queue/PR/Image.png) ![Example3](/.github/Pull_Requests/Queue/PR/Image.png) ![Example4](/.github/Pull_Requests/Queue/PR/Image.png) ![Example5](/.github/Pull_Requests/Queue/PR/Image.png) ``` ## Types of changes What types of changes does your code introduce? Put an `x` in all the boxes that apply: - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Checklist: Go over all the following points, and put an `x` in all the boxes that apply. If you're unsure about any of these, don't hesitate to ask. We're here to help! - [ ] My source code (if source code is provided) follows the source code style of this project. - [ ] My change requires a change to the documentation. - [ ] My change does not delete necessary files - [ ] I have updated the documentation accordingly. - [ ] I have read the [**`CONTRIBUTING`**](/CONTRIBUTING.md) document in my spoken language, and understand the terms - [ ] I have added tests to cover my changes. - [ ] I have gone through all the steps, and have thoroughly read the instructions *** <!-- Template info Pull request template Version 1 (2022, Thursday, May 19th at 5:47 pm PST) File type: Markdown document (*.md *.mkd *.mdown *.markdown) Line count (including blank lines and compiler line): 102 !-->
3,520
Common Lisp
.l
63
54.269841
292
0.756946
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
25fd83710acdcab70ea9637b9447462404362a916d227742a372a8c48927e690
19,692
[ -1 ]
19,695
404.html
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/404.html
<HR> <img src="/404.jpeg" alt="404 error on 404 image file for 404 page, 404" width="300" height="200"> <H1>404</H1> <H2><a href="https://en.wikipedia.org/wiki/HTTP_404">File not found</a></H2> <HR> <p><a href="https://github.com/seanpm2001/404Day">Celebrate 404 day</a></p> <p>The file could not be found, is damaged, or you do not have permission to access it. Please <a href="https://github.com/seanwallawalla-testing/seanwallawalla-testing.github.io/issues">[raise an issue]</a> if a link is not working correctly.</p> <HR>
528
Common Lisp
.l
8
65
247
0.721154
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
a486034aeabf2cb3669a6420ef52bb2ad4774cf26d34758bc213e220b8e54953
19,695
[ -1 ]
19,702
issue-template_V1.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/OldVersions/ISSUE_TEMPLATE/ISSUE-TEMPLATE/1/1-100/issue-template_V1.yml
name: General issue description: Report a bug or other issue/Opening an issue in this SNU Programming Tools IDE project body: - type: markdown attributes: value: | Unknown - type: checkboxes attributes: label: Prerequisites description: | To rule out invalid issues, confirm and check each one of the checkboxes. options: - label: I verified that this is not an existing issue required: true - label: This is not a [question, poll, or discussion](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/discussions/) required: true - label: I checked the [documentation](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/tree/master/Docs/) to understand that the issue I report is not a normal behavior required: true validations: required: true - type: checkboxes attributes: label: I tried to reproduce the issue when... options: - label: The repository was downloaded to my device/was viewing through the web browser required: true - label: I was using the latest version of the project required: true - label: I was using the version from the right source required: false - label: I did not modify the project required: false - type: textarea attributes: label: Description description: Description of the bug or feature. Please also list the version of the programming language you tested with. validations: required: true - type: textarea attributes: label: Steps to Reproduce placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Expected Results description: What you expected to happen, example: no error is thrown validations: required: true - type: textarea attributes: label: Actual results description: What actually happened, error is thrown validations: required: true - type: input attributes: label: Git-image repository version validations: required: true - type: checkboxes attributes: label: Browsers effected, please open an issue in [SNU BrowserNose](https://github.com/seanpm2001/SNU_BrowserNose) as well, if BrowserNose fails to do the task. options: label: Tor required: false label: Mozilla Firefox required: false label: SeaMonkey required: false label: Pale Moon required: false label: TenFourFox required: false label: Konquerer required: false label: Line Mode Browser required: false label: IceWeasel/IceCat required: false label: IceRaven required: false label: DuckDuckGo required: false label: Safari required: false label: Netscape Navigator required: false label: Nexus required: false label: SlimJet required: false label: AOL Explorer required: false label: Opera Mini required: false label: Android stock browser required: false label: Dot browser required: false label: Microsoft Edge required: false label: Opera required: false label: Samsung Internet required: false label: Google Chrome required: false label: Google Chromium required: false label: Internet Explorer required: false label: Other required: false validations: required: true - type: input attributes: label: Specify the specific browser version down to the last number (example: Firefox 88.0.1esr) and specify if you are running on a desktop or mobile device. validations: required: true - type: checkboxes attributes: label: I am running this repository in a virtual machine... options: - label: Yes (with Oracle VM VirtualBox) required: false - label: Yes (with VMWare) required: false - label: Yes (with Hyper-V) required: false - label: Yes (with Qemu) required: false - label: Yes (with another virtual machine option that isn't listed) required: false - label: No (I am running it on my host computer) required: false - type: textarea attributes: label: Additional virtual machine configuration placeholder: | Sample (overwrite this) Microsoft Windows XP Service Pack 3 Registry modification for activation Internet Explorer 6 VirtualBox 6.1.20 (64 bit) 512 MB RAM 32 Gigabyte disk space Host operating system: Kubuntu 22.04 VirtualBox guest additions? Installed Internet type: Broadband Specific error: Page won't load, things aren't displaying correctly, see above validations: validations: required: true - type: textarea attributes: label: Version used placeholder: | What version are you using? (supported versions only) validations: required: true attributes: label: Validate issue options: - label: I have filled out all the fields required: true - label: I agree to the terms of the [GPL3 license](https://www.gnu.org/licenses/gpl-3.0.en.html) required: true - label: I have confirmed this issue isn't a duplicate required: true - label: I agree to follow the [code of conduct](https://github.com/seanpm2001/CODE_OF_CONDUCT.md) required: true - label: I want my answer to be archived into the repository required: false # Issue template info # 1B (2022, Thursday, May 19th at 6:50 pm PST) # File type: YAML document (*.yml *.yaml) # Line count (including blank lines and compiler line): 197 # File purpose: Serving as a modern issue template for this project.
6,192
Common Lisp
.l
184
25.967391
182
0.649925
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
b8574efa5dab06fbd178fa9fe18c8fcfbce742690ad351f9bffe91774dbd2b68
19,702
[ -1 ]
19,703
issue-template_V3.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/OldVersions/ISSUE_TEMPLATE/ISSUE-TEMPLATE/1/1-100/issue-template_V3.yml
name: General issue description: Report a bug or other issue/Opening an issue in this SNU Programming Tools IDE project body: - type: markdown attributes: value: | Unknown - type: checkboxes attributes: label: Prerequisites description: | To rule out invalid issues, confirm and check each one of the checkboxes. options: - label: I verified that this is not an existing issue required: true - label: This is not a [question, poll, or discussion](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/discussions/) required: true - label: I checked the [documentation](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/tree/master/Docs/) to understand that the issue I report is not a normal behavior required: true validations: required: true - type: checkboxes attributes: label: I tried to reproduce the issue when... options: - label: The repository was downloaded to my device/was viewing through the web browser required: true - label: I was using the latest version of the project required: true - label: I was using the version from the right source required: false - label: I did not modify the project required: false - type: textarea attributes: label: Description description: Description of the bug or feature. Please also list the version of the programming language you tested with. validations: required: true - type: textarea attributes: label: Steps to Reproduce placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Expected Results description: What you expected to happen, example - no error is thrown placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Actual results description: What actually happened, error is thrown validations: required: true - type: input attributes: label: Git-image repository version validations: required: true - type: checkboxes attributes: label: Browsers effected, please open an issue in [SNU BrowserNose](https://github.com/seanpm2001/SNU_BrowserNose) as well, if BrowserNose fails to do the task. options: label: Tor required: false label: Mozilla Firefox required: false label: SeaMonkey required: false label: Pale Moon required: false label: TenFourFox required: false label: Konquerer required: false label: Line Mode Browser required: false label: IceWeasel/IceCat required: false label: IceRaven required: false label: DuckDuckGo required: false label: Safari required: false label: Netscape Navigator required: false label: Nexus required: false label: SlimJet required: false label: AOL Explorer required: false label: Opera Mini required: false label: Android stock browser required: false label: Dot browser required: false label: Microsoft Edge required: false label: Opera required: false label: Samsung Internet required: false label: Google Chrome required: false label: Google Chromium required: false label: Internet Explorer required: false label: Other required: false validations: required: true - type: input attributes: label: Specify the specific browser version down to the last number (example: Firefox 88.0.1esr) and specify if you are running on a desktop or mobile device. validations: required: true - type: checkboxes attributes: label: I am running this repository in a virtual machine... options: - label: Yes (with Oracle VM VirtualBox) required: false - label: Yes (with VMWare) required: false - label: Yes (with Hyper-V) required: false - label: Yes (with Qemu) required: false - label: Yes (with another virtual machine option that isn't listed) required: false - label: No (I am running it on my host computer) required: false - type: textarea attributes: label: Additional virtual machine configuration placeholder: | Sample (overwrite this) Microsoft Windows XP Service Pack 3 Registry modification for activation Internet Explorer 6 VirtualBox 6.1.20 (64 bit) 512 MB RAM 32 Gigabyte disk space Host operating system: Kubuntu 22.04 VirtualBox guest additions? Installed Internet type: Broadband Specific error: Page won't load, things aren't displaying correctly, see above validations: validations: required: true - type: textarea attributes: label: Version used placeholder: | What version are you using? (supported versions only) validations: required: true attributes: label: Validate issue options: - label: I have filled out all the fields required: true - label: I agree to the terms of the [GPL3 license](https://www.gnu.org/licenses/gpl-3.0.en.html) required: true - label: I have confirmed this issue isn't a duplicate required: true - label: I agree to follow the [code of conduct](https://github.com/seanpm2001/CODE_OF_CONDUCT.md) required: true - label: I want my answer to be archived into the repository required: false # Issue template info # 3B (2022, Thursday, May 19th at 6:54 pm PST) # File type: YAML document (*.yml *.yaml) # Line count (including blank lines and compiler line): 201 # File purpose: Serving as a modern issue template for this project.
6,291
Common Lisp
.l
188
25.75
182
0.646353
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
5dcfb7a296faa7f64ebc327ce9e0e5967be18d43e452ada90e302c70523b2886
19,703
[ -1 ]
19,704
issue-template_V5.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/OldVersions/ISSUE_TEMPLATE/ISSUE-TEMPLATE/1/1-100/issue-template_V5.yml
name: General issue description: Report a bug or other issue/Opening an issue in this SNU Programming Tools IDE project body: - type: markdown attributes: value: | Unknown - type: checkboxes attributes: label: Prerequisites description: | To rule out invalid issues, confirm and check each one of the checkboxes. options: - label: I verified that this is not an existing issue required: true - label: This is not a [question, poll, or discussion](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/discussions/) required: true - label: I checked the [documentation](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/tree/master/Docs/) to understand that the issue I report is not a normal behavior required: true validations: required: true - type: checkboxes attributes: label: I tried to reproduce the issue when... options: - label: The repository was downloaded to my device/was viewing through the web browser required: true - label: I was using the latest version of the project required: true - label: I was using the version from the right source required: false - label: I did not modify the project required: false - type: textarea attributes: label: Description description: Description of the bug or feature. Please also list the version of the programming language you tested with. validations: required: true - type: textarea attributes: label: Steps to Reproduce placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Expected Results description: What you expected to happen, example - no error is thrown placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Actual results description: What actually happened, error is thrown validations: required: true - type: input attributes: label: Git-image repository version validations: required: true - type: checkboxes attributes: label: Browsers effected, please open an issue in [SNU BrowserNose](https://github.com/seanpm2001/SNU_BrowserNose) as well, if BrowserNose fails to do the task. options: label: Tor required: false label: Mozilla Firefox required: false label: SeaMonkey required: false label: Pale Moon required: false label: TenFourFox required: false label: Konquerer required: false label: Line Mode Browser required: false label: IceWeasel/IceCat required: false label: IceRaven required: false label: DuckDuckGo required: false label: Safari required: false label: Netscape Navigator required: false label: Nexus required: false label: SlimJet required: false label: AOL Explorer required: false label: Opera Mini required: false label: Android stock browser required: false label: Dot browser required: false label: Microsoft Edge required: false label: Opera required: false label: Samsung Internet required: false label: Google Chrome required: false label: Google Chromium required: false label: Internet Explorer required: false label: Other required: false validations: required: true - type: input attributes: label: Specify the specific browser version down to the last number (example Firefox 88.0.1esr) validations: required: true - type: checkboxes attributes: label: I am running this repository in a virtual machine... options: - label: Yes (with Oracle VM VirtualBox) required: false - label: Yes (with VMWare) required: false - label: Yes (with Hyper-V) required: false - label: Yes (with Qemu) required: false - label: Yes (with another virtual machine option that isn't listed) required: false - label: No (I am running it on my host computer) required: false - type: textarea attributes: label: Additional virtual machine configuration placeholder: | Sample (overwrite this) Microsoft Windows XP Service Pack 3 Registry modification for activation Internet Explorer 6 VirtualBox 6.1.20 (64 bit) 512 MB RAM 32 Gigabyte disk space Host operating system: Kubuntu 22.04 VirtualBox guest additions? Installed Internet type: Broadband Specific error: Page won't load, things aren't displaying correctly, see above validations: validations: required: true - type: textarea attributes: label: Version used placeholder: | What version are you using? (supported versions only) validations: required: true attributes: label: Validate issue options: - label: I have filled out all the fields required: true - label: I agree to the terms of the [GPL3 license](https://www.gnu.org/licenses/gpl-3.0.en.html) required: true - label: I have confirmed this issue isn't a duplicate required: true - label: I agree to follow the [code of conduct](https://github.com/seanpm2001/CODE_OF_CONDUCT.md) required: true - label: I want my answer to be archived into the repository required: false # Issue template info # 5B (2022, Thursday, May 19th at 6:58 pm PST) # File type: YAML document (*.yml *.yaml) # Line count (including blank lines and compiler line): 201 # File purpose: Serving as a modern issue template for this project.
6,229
Common Lisp
.l
188
25.414894
182
0.644872
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
83810c059c59d965a58f7bed3240eb7814bebf45bd0257915904a8f3d91a5289
19,704
[ -1 ]
19,705
issue-template_V4.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/OldVersions/ISSUE_TEMPLATE/ISSUE-TEMPLATE/1/1-100/issue-template_V4.yml
name: General issue description: Report a bug or other issue/Opening an issue in this SNU Programming Tools IDE project body: - type: markdown attributes: value: | Unknown - type: checkboxes attributes: label: Prerequisites description: | To rule out invalid issues, confirm and check each one of the checkboxes. options: - label: I verified that this is not an existing issue required: true - label: This is not a [question, poll, or discussion](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/discussions/) required: true - label: I checked the [documentation](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/tree/master/Docs/) to understand that the issue I report is not a normal behavior required: true validations: required: true - type: checkboxes attributes: label: I tried to reproduce the issue when... options: - label: The repository was downloaded to my device/was viewing through the web browser required: true - label: I was using the latest version of the project required: true - label: I was using the version from the right source required: false - label: I did not modify the project required: false - type: textarea attributes: label: Description description: Description of the bug or feature. Please also list the version of the programming language you tested with. validations: required: true - type: textarea attributes: label: Steps to Reproduce placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Expected Results description: What you expected to happen, example - no error is thrown placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Actual results description: What actually happened, error is thrown validations: required: true - type: input attributes: label: Git-image repository version validations: required: true - type: checkboxes attributes: label: Browsers effected, please open an issue in [SNU BrowserNose](https://github.com/seanpm2001/SNU_BrowserNose) as well, if BrowserNose fails to do the task. options: label: Tor required: false label: Mozilla Firefox required: false label: SeaMonkey required: false label: Pale Moon required: false label: TenFourFox required: false label: Konquerer required: false label: Line Mode Browser required: false label: IceWeasel/IceCat required: false label: IceRaven required: false label: DuckDuckGo required: false label: Safari required: false label: Netscape Navigator required: false label: Nexus required: false label: SlimJet required: false label: AOL Explorer required: false label: Opera Mini required: false label: Android stock browser required: false label: Dot browser required: false label: Microsoft Edge required: false label: Opera required: false label: Samsung Internet required: false label: Google Chrome required: false label: Google Chromium required: false label: Internet Explorer required: false label: Other required: false validations: required: true - type: input attributes: label: Specify the specific browser version down to the last number (example: Firefox 88.0.1esr) and specify if you are running on a desktop or mobile device. validations: required: true - type: checkboxes attributes: label: I am running this repository in a virtual machine... options: - label: Yes (with Oracle VM VirtualBox) required: false - label: Yes (with VMWare) required: false - label: Yes (with Hyper-V) required: false - label: Yes (with Qemu) required: false - label: Yes (with another virtual machine option that isn't listed) required: false - label: No (I am running it on my host computer) required: false - type: textarea attributes: label: Additional virtual machine configuration placeholder: | Sample (overwrite this) Microsoft Windows XP Service Pack 3 Registry modification for activation Internet Explorer 6 VirtualBox 6.1.20 (64 bit) 512 MB RAM 32 Gigabyte disk space Host operating system: Kubuntu 22.04 VirtualBox guest additions? Installed Internet type: Broadband Specific error: Page won't load, things aren't displaying correctly, see above validations: validations: required: true - type: textarea attributes: label: Version used placeholder: | What version are you using? (supported versions only) validations: required: true attributes: label: Validate issue options: - label: I have filled out all the fields required: true - label: I agree to the terms of the [GPL3 license](https://www.gnu.org/licenses/gpl-3.0.en.html) required: true - label: I have confirmed this issue isn't a duplicate required: true - label: I agree to follow the [code of conduct](https://github.com/seanpm2001/CODE_OF_CONDUCT.md) required: true - label: I want my answer to be archived into the repository required: false # Issue template info # 4B (2022, Thursday, May 19th at 6:56 pm PST) # File type: YAML document (*.yml *.yaml) # Line count (including blank lines and compiler line): 201 # File purpose: Serving as a modern issue template for this project.
6,292
Common Lisp
.l
188
25.75
182
0.646247
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
30166d4ad7b5dc576431ef8156e7810eed77b0df3d3bd97d1b231e65e6da7339
19,705
[ -1 ]
19,706
issue-template_V6.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/OldVersions/ISSUE_TEMPLATE/ISSUE-TEMPLATE/1/1-100/issue-template_V6.yml
name: General issue description: Report a bug or other issue/Opening an issue in this SNU Programming Tools IDE project body: - type: markdown attributes: value: | Unknown - type: checkboxes attributes: label: Prerequisites description: | To rule out invalid issues, confirm and check each one of the checkboxes. options: - label: I verified that this is not an existing issue required: true - label: This is not a [question, poll, or discussion](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/discussions/) required: true - label: I checked the [documentation](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/tree/master/Docs/) to understand that the issue I report is not a normal behavior required: true validations: required: true - type: checkboxes attributes: label: I tried to reproduce the issue when... options: - label: The repository was downloaded to my device/was viewing through the web browser required: true - label: I was using the latest version of the project required: true - label: I was using the version from the right source required: false - label: I did not modify the project required: false - type: textarea attributes: label: Description description: Description of the bug or feature. Please also list the version of the programming language you tested with. validations: required: true - type: textarea attributes: label: Steps to Reproduce placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Expected Results description: What you expected to happen, example - no error is thrown placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Actual results description: What actually happened, error is thrown validations: required: true - type: input attributes: label: Git-image repository version validations: required: true - type: checkboxes attributes: label: Browsers effected, please open an issue in [SNU BrowserNose](https://github.com/seanpm2001/SNU_BrowserNose) as well, if BrowserNose fails to do the task. options: label: Tor required: false label: Mozilla Firefox required: false label: SeaMonkey required: false label: Pale Moon required: false label: TenFourFox required: false label: Konquerer required: false label: Line Mode Browser required: false label: IceWeasel/IceCat required: false label: IceRaven required: false label: DuckDuckGo required: false label: Safari required: false label: Netscape Navigator required: false label: Nexus required: false label: SlimJet required: false label: AOL Explorer required: false label: Opera Mini required: false label: Android stock browser required: false label: Dot browser required: false label: Microsoft Edge required: false label: Opera required: false label: Samsung Internet required: false label: Google Chrome required: false label: Google Chromium required: false label: Internet Explorer required: false label: Other required: false validations: required: true - type: input attributes: label: Specify the specific browser version down to the last number (example Firefox 88.0.1esr) validations: required: true - type: checkboxes attributes: label: I am running this repository in a virtual machine... options: - label: Yes (with Oracle VM VirtualBox) required: false - label: Yes (with VMWare) required: false - label: Yes (with Hyper-V) required: false - label: Yes (with Qemu) required: false - label: Yes (with another virtual machine option that isn't listed) required: false - label: No (I am running it on my host computer) required: false - type: textarea attributes: label: Additional virtual machine configuration placeholder: | Sample (overwrite this) Microsoft Windows XP Service Pack 3 Registry modification for activation Internet Explorer 6 VirtualBox 6.1.20 (64 bit) 512 MB RAM 32 Gigabyte disk space Host operating system: Kubuntu 22.04 VirtualBox guest additions? Installed Internet type: Broadband Specific error: Page won't load, things aren't displaying correctly, see above validations: validations: required: true - type: textarea attributes: label: Version used placeholder: | What version are you using? (supported versions only) validations: required: true attributes: label: Validate issue options: - label: I have filled out all the fields required: true - label: I agree to the terms of the [GPL3 license](https://www.gnu.org/licenses/gpl-3.0.en.html) required: true - label: I have confirmed this issue isn't a duplicate required: true - label: I agree to follow the [code of conduct](https://github.com/seanpm2001/CODE_OF_CONDUCT.md) required: true - label: I want my answer to be archived into the repository required: false # Issue template info # 6B (2022, Thursday, May 19th at 6:59 pm PST) # File type: YAML document (*.yml *.yaml) # Line count (including blank lines and compiler line): 201 # File purpose: Serving as a modern issue template for this project.
6,230
Common Lisp
.l
188
25.414894
182
0.644765
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
71eecf8725aeb73ed3a44b6e0a025c7631731e045ad7ed625fb36431b1346aed
19,706
[ -1 ]
19,707
issue-template_V2.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/OldVersions/ISSUE_TEMPLATE/ISSUE-TEMPLATE/1/1-100/issue-template_V2.yml
name: General issue description: Report a bug or other issue/Opening an issue in this SNU Programming Tools IDE project body: - type: markdown attributes: value: | Unknown - type: checkboxes attributes: label: Prerequisites description: | To rule out invalid issues, confirm and check each one of the checkboxes. options: - label: I verified that this is not an existing issue required: true - label: This is not a [question, poll, or discussion](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/discussions/) required: true - label: I checked the [documentation](https://github.com/seanpm2001/SNU_2D_ProgrammingTools/tree/master/Docs/) to understand that the issue I report is not a normal behavior required: true validations: required: true - type: checkboxes attributes: label: I tried to reproduce the issue when... options: - label: The repository was downloaded to my device/was viewing through the web browser required: true - label: I was using the latest version of the project required: true - label: I was using the version from the right source required: false - label: I did not modify the project required: false - type: textarea attributes: label: Description description: Description of the bug or feature. Please also list the version of the programming language you tested with. validations: required: true - type: textarea attributes: label: Steps to Reproduce placeholder: | 1. [First Step] 2. [Second Step] 3. [and so on...] validations: required: true - type: textarea attributes: label: Expected Results description: What you expected to happen, example: no error is thrown - type: textarea attributes: label: Actual results description: What actually happened, error is thrown validations: required: true - type: input attributes: label: Git-image repository version validations: required: true - type: checkboxes attributes: label: Browsers effected, please open an issue in [SNU BrowserNose](https://github.com/seanpm2001/SNU_BrowserNose) as well, if BrowserNose fails to do the task. options: label: Tor required: false label: Mozilla Firefox required: false label: SeaMonkey required: false label: Pale Moon required: false label: TenFourFox required: false label: Konquerer required: false label: Line Mode Browser required: false label: IceWeasel/IceCat required: false label: IceRaven required: false label: DuckDuckGo required: false label: Safari required: false label: Netscape Navigator required: false label: Nexus required: false label: SlimJet required: false label: AOL Explorer required: false label: Opera Mini required: false label: Android stock browser required: false label: Dot browser required: false label: Microsoft Edge required: false label: Opera required: false label: Samsung Internet required: false label: Google Chrome required: false label: Google Chromium required: false label: Internet Explorer required: false label: Other required: false validations: required: true - type: input attributes: label: Specify the specific browser version down to the last number (example: Firefox 88.0.1esr) and specify if you are running on a desktop or mobile device. validations: required: true - type: checkboxes attributes: label: I am running this repository in a virtual machine... options: - label: Yes (with Oracle VM VirtualBox) required: false - label: Yes (with VMWare) required: false - label: Yes (with Hyper-V) required: false - label: Yes (with Qemu) required: false - label: Yes (with another virtual machine option that isn't listed) required: false - label: No (I am running it on my host computer) required: false - type: textarea attributes: label: Additional virtual machine configuration placeholder: | Sample (overwrite this) Microsoft Windows XP Service Pack 3 Registry modification for activation Internet Explorer 6 VirtualBox 6.1.20 (64 bit) 512 MB RAM 32 Gigabyte disk space Host operating system: Kubuntu 22.04 VirtualBox guest additions? Installed Internet type: Broadband Specific error: Page won't load, things aren't displaying correctly, see above validations: validations: required: true - type: textarea attributes: label: Version used placeholder: | What version are you using? (supported versions only) validations: required: true attributes: label: Validate issue options: - label: I have filled out all the fields required: true - label: I agree to the terms of the [GPL3 license](https://www.gnu.org/licenses/gpl-3.0.en.html) required: true - label: I have confirmed this issue isn't a duplicate required: true - label: I agree to follow the [code of conduct](https://github.com/seanpm2001/CODE_OF_CONDUCT.md) required: true - label: I want my answer to be archived into the repository required: false # Issue template info # 2B (2022, Thursday, May 19th at 6:52 pm PST) # File type: YAML document (*.yml *.yaml) # Line count (including blank lines and compiler line): 195 # File purpose: Serving as a modern issue template for this project.
6,154
Common Lisp
.l
182
26.10989
182
0.649992
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
401619180ca30f87877b9dd8296f0c7a7412f7bb5d5446eae8c03daccb0137dc
19,707
[ -1 ]
19,708
V1_config.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/OldVersions/ISSUE_TEMPLATE/CONFIG/YML/V1_config.yml
blank_issues_enabled: false contact_links: - name: I want to help develop url: https://github.com/seanpm2001/Teams/discussions/ about: Thank you for your interest in this project! Please consider joining a team to start developing with me - name: I want to help translate url: https://github.com/seanpm2001/Teams/discussions/ about: Thank you for your interest in this project! Please consider joining a team to start translating projects with me # File info # File version: 1 (2022, Thursday, May 19th at 7:07 pm PST) # File type: GitHub issue template config file (*.yml) # Line count (including blank lines and compiler line): 14
654
Common Lisp
.l
12
51.75
124
0.764431
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
24cb72c2757a113ed7d4f1f68501cdb21e6c41184d6805f82d757b2aa5998228
19,708
[ -1 ]
19,712
.FUNDING.yml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/.github/.FUNDING.yml
# These are supported funding model platforms github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: seanpm2001 # Creator page patreon: seanpm2001_software # Main page # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
780
Common Lisp
.l
13
58.769231
91
0.794503
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ebd6c96af3773ed36844e5889bdac36ac43026a72b8cc7e2f2a61de993cba630
19,712
[ -1 ]
19,716
GitHub_Default_IssueLabels.yaml
seanpm2001_SNU_2D_ProgrammingTools_IDE_CommonLisp/.github/Issues/GitHub_Default_IssueLabels.yaml
# Default GitHub issue data file (YAML) issuelabel_1: color1: "#ffffff" title1: "wontfix" description1: "This will not be worked on" issueLabel_2: color2: "#d876e3" title2: "question" description2: "Further information is requested" issueLabel_3: color3: "#e4e669" title3: "invalid" description3: "This doesn't seem right" issueLabel_4: color4: "#008672" title4: "help wanted" description4: "Extra attention is needed" issueLabel_5: color5: "#7057ff" title5: "good first issue" description5: "Good for newcomers" issueLabel_6: color6: "#a2eeef" title6: "enhancement" description6: "New feature or request" issueLabel_7: color7: "#cfd3d7" title7: "duplicate" description7: "This issue or pull request already exists" issueLabel_8: color8: "#0075ca" title8: "documentation" description8: "Improvements or additions to documentation" issueLabel_9: color9: "#d73a4a" title9: "bug" description9: "Something isn't working" # Users can also create their own issue labels, and customize the color, title, and description # issueLabel_10: color10: "#000000" title10: "void" description10: "not yet created" # No known limit on # of issue labels # End of file
1,150
Common Lisp
.l
14
81.142857
114
0.769366
seanpm2001/SNU_2D_ProgrammingTools_IDE_CommonLisp
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ac2c04c28bbae9721ee7e24122a01c42700ce541351277bb52dae214359629b5
19,716
[ -1 ]
19,786
PROJECT_LANG_1.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/PROJECT_LANG_1.lisp
; Start of script ; Project language file 1 ; For: /SNU/2D/ProgrammingTools/IDE/Lisp/ ; About: ; I decided to make Lisp the main project language file for this project (SNU / 2D / Programming Tools / IDE / Lisp) as this is a Lisp IDE, and it needs its main language to be represented here. (print "Project language file 1") (print "For: /SNU/2D/ProgrammingTools/IDE/Lisp/") (print "About:") (print "I decided to make Lisp the main project language file for this project (SNU / 2D / Programming Tools / IDE / Lisp) as this is a Lisp IDE, and it needs its main language to be represented here.") ; File info ; File type: Lisp source file (*.lsp *.lisp) ; File version: 1 (2022, Friday, November 4th at 1:04 am PST) ; Line count (including blank lines and compiler line): 19 ; End of script
792
Common Lisp
.lisp
14
55.285714
202
0.74031
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ef0030393b888264438f30221c2db2849a625e6415a4a4d7d0440defe81a3cae
19,786
[ -1 ]
19,792
LISPFactorialLoop.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISPFactorialLoop.lisp
; Start of script (defun factorial (n) (loop for i from 1 to n for fac = 1 then (* fac i) finally (return fac))) ; End of script
150
Common Lisp
.lisp
6
20.5
35
0.597222
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
63f2f85f7761a9332ff45112b9abeafde8322d655426bf87713c8dc67f8ca13a
19,792
[ -1 ]
19,793
LispLambda.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LispLambda.lisp
# Start of script (lambda (arg) (+ arg 1)) ((lambda (arg) (+ arg 1)) 5) (defun foo (a b c d) (+ a b c d)) (setf (fdefinition 'f) #'(lambda (a) (block f b...))) # End of script
178
Common Lisp
.lisp
6
28.333333
53
0.563953
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
0c8f92f624fe4bf5ab697b950b2e42a02380c2866c3b6a9b487903803f2ad542
19,793
[ -1 ]
19,794
LispList.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LispList.lisp
# Start of script (list 1 2 (quote foo)) (list 1 2 (list 3 4)) # End of script
80
Common Lisp
.lisp
4
18.75
22
0.657895
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ad6c682db31a97abb2374399863e2c93225157921e1f9336e5ab43cc083c4980
19,794
[ -1 ]
19,795
LISPFactorial1_V1.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISPFactorial1_V1.lisp
; Start of script (defun factorial (n) (if (= n 0) 1 (* n (factorial (- n 1))))) ; End of script
100
Common Lisp
.lisp
5
18.4
29
0.589474
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
f9b062a935044e79de4b5ab360ea9648db6d7d2cf490b294c621977cfa9ef10b
19,795
[ -1 ]
19,796
LISP_Foobar_V1.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISP_Foobar_V1.lisp
; Start of script (setf foo (list 'a 'b 'c)) (setf bar (cons 'x (cdr foo))) ; End of script
92
Common Lisp
.lisp
4
22
30
0.636364
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
bbf4d4be0af89de53c140ebe07b38429d83b264605c16242c11cd1f76a7aed5c
19,796
[ -1 ]
19,797
LISPFactorial2.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISPFactorial2.lisp
; Start of script (defun factorial (n &optional (acc 1)) (if (= n 0) acc (factorial (- n 1) (* acc n)))) ; End of script
131
Common Lisp
.lisp
5
23.2
38
0.579365
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
82e971ddac07c97f688b211897debdb561e9ed3ab83afee58762b3b04087a959
19,797
[ -1 ]
19,798
LISP_lisp.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISP_lisp.lisp
; Start of script (list 1 2 'a 3) ;Output: (1 2 a 3) (list 1 '(2 3) 4) ;Output: (1 (2 3) 4) ; End of script
113
Common Lisp
.lisp
6
17
21
0.566038
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
db3dde57b69423b03928020a23514a15d43db90f0e22e04fe145ecc22ef4c13f
19,798
[ -1 ]
19,800
LISP_Append.lisp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISP_Append.lisp
; Start of script (append '(1 2) '(3 4)) ;Output: (1 2 3 4) (append '(1 2 3) '() '(a) '(5 6)) ;Output: (1 2 3 a 5 6) ; End of script
138
Common Lisp
.lisp
6
21.166667
34
0.519084
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
2e9a870b86eab257f933a80381ad24f7c5f902fcdefb3486e39aebde43de067e
19,800
[ -1 ]
19,849
!LISP_HOME.html
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/!LISP_HOME.html
<!-- End of script !--> <HTML> <HEAD> <link rel="icon" href="SNUCFaviconTemplate.ico" type="image/x-icon"/> <!--<link rel="stylesheet" type="text/css" href="PROGCSS_V1.css">!--> <TITLE>LISP programming language home - SNU Programming</TITLE> </HEAD> <BODY BGCOLOR="BEIGE"> </HEAD> <script> // No JavaScript data available yet </script> <style> // From stylesheet /* Start of stylesheet rules */ /* Transparent boxes */ div.background { background: url(klematis.jpg) repeat; border: 2px solid black; } div.transbox { margin-top: 0px; margin-bottom: 0px; margin-right: 0px; margin-left: 0px; background-color: #777777; /* The text was there, the background was the wrong color. A new beautiful shade of blue was added to fix this - April 6th 2019 */ border: 1px solid black; opacity: 0.6; filter: alpha(opacity=80); /* For IE8 and earlier */ } div.transbox p { margin: 1%; /* make sure this stays at 1%. At 5%, there is a large spacing issue between each new paragraph */ font-weight: bold; color: #ffffff; } /* Sidebar */ body { margin: 0; } ul { list-style-type: none; margin: 0; padding: 0; width: 16%; background-color: #f1f1f1; position: fixed; height: 100%; overflow: auto; } li a { display: block; color: #000; padding: 8px 16px; text-decoration: none; } li a.active { background-color: #4CAF50; color: white; } li a:hover:not(.active) { background-color: #555; color: white; } /* Topbar */ /* Add a black background color to the top navigation */ .topnav { background-color: #333; overflow: hidden; } /* Style the links inside the navigation bar */ .topnav a { float: left; color: #f2f2f2; text-align: center; padding: 14px 16px; text-decoration: none; font-size: 17px; } /* Change the color of links on hover */ .topnav a:hover { background-color: #ddd; color: black; } /* Add a color to the active/current link */ .topnav a.active { background-color: #4CAF50; color: white; } /* Dropdown */ .dropdown { position: relative; display: inline-block; } .dropdown-content { display: none; position: absolute; background-color: #f9f9f9; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); padding: 12px 16px; z-index: 1; } .dropdown:hover .dropdown-content { display: block; } /* Headings */ H1 { color: black; } H2 { color: black; } H3 { color: black; } H4 { color: black; } H5 { color: black; } H6 { color: black; } /* Dividers, paragraphs */ .center { display: block; margin-left: auto; margin-right: auto; width: 50%; } // Note that it can not be centered if the width is set to 100% (full-width). !--> </style> <div class="topnav"> <a class="active" href="">[SNU LISP Programming]</a> <a href="../../Programming Tools/!SNU_SOFTWARE_CENTER_HOME.html">Back home</a><!-- empty link !--> <a href="about:blank">Exit</a><!-- empty link !--> </div> <!-- Top navigation bar !--> <!-- Divider !--> <!-- Sidebar !--> <!-- Match to content * Mascot at bottom of page, centered (unless the language doesn't have an official mascot) * Page color matches Logo, no black on white pages * Transparent boxes that match page color !--> <ul> <img src="SNUBLOCK()FaviconTemplate.png" alt="Programming language icon" width="225" height="225"> <li><a class="active" href="#home">SNU LISP programming</a></li> <HR> <details> <summary><li><a href="#EXPLORE">Page selection</a></li></summary> </details> <li><HR></li> <details><summary><li id="">Start</a></li></summary> <li><a href="#Top">Top</a></li> <li><a href="#LanguageInfo">Language info</a></li> </details> <li><HR></li> <details><summary><li id="">Samples and IDE</a></li></summary> <li><a href="#Samples">Sample programs</a></li> <li><a href="#VersionHistory">Version history</a></li> <li><a href="#IDECollection">IDE collection</a></li> </details> <li><HR></li> <details><summary><li id="">Documentation</a></li></summary> <li><a href="#LANDocumentation">[LANGUAGE] Documentation</a></li> <li><a href="#SnapshotSection">Page snapshots</a></li> </details> <li><HR></li> </ul> <div style="margin-left:15.1%;padding:1px 16px;height:1000px;"> <HR> <H2>SNU software center OLD/SNU programming >> Programming Language List >> LISP</H2> <HR id="Top"> <img src="Lisplogo.png" alt="LIS_P" width="81" height="81"> <!-- Reduced from original 17101x11678 !--> <H1>Welcome to the SNU Home page for the LISP programming language</H1> <HR> <div class="background"> <div class="transbox"> <details><summary><H1 id="LanguageInfo">Language info</H1></summary> <H2>Developed by: John McCarthy</H2> <H2>First version: 1958</H2> <H2>File types: *.??</H2> <H2>Language type: Multi-paradigm: functional, procedural, reflective, meta</H2> <H2>Open source status: Unknown</H2> <H2>Influenced by: IPL</H2> <H2>Influenced: CLIPS CLU COWSEL Dylan Elixir Forth Haskell Io Ioke JavaScript Julia, Logo Lua ML Nim Nu OPS5 Perl POP-2/11 Python R Rebol Ruby Scala Swift Smalltalk Tcl Wolfram Language</H2> </details> </div> </div> <HR> <H1>Part of the First programming languages family</H1> <HR> <div class="background"> <div class="transbox"> <details><summary><H1 id="VersionHistory">Version history</H1></summary> <p>Unknown</p> </details> </div> </div> <HR> <div class="background"> <div class="transbox"> <details><summary><H1 id="IDECollection">IDE by the version</H1></summary> <H2><button><H3><a href="">NoVer</</a></H3></button></H2> </details> </div> </div> <HR> <div class="background"> <div class="transbox"> <details><summary><H1 id="LANDocumentation">LISP documentation</H1></summary> <H2><button><a href="BasicsLISP_Doc.html">Basic LISP</a></button></H2> <H2><button><a href="AssemblyLISP_Doc.html">LISP and Assembly</a></button></H2> <H2><button><a href="IntermediateLISP_Doc.html">Intermediate LISP</a></button></H2> </details> </div> </div> <HR> <div class="background"> <div class="transbox"> <details><summary><H1 id="SnapshotSection">View older versions of this page</H1></summary> <H2>Notice</H2> <p>Snapshot 1 was originally made in the beginning of February 2019, an era before snapshots were introduced to the site. Clicking the link to snapshot 1 will nagivate you there, but will not give you a way back. Consider using your browsers back button, or loading a different page. For desktop computer users, you can just press the [BACKSPACE] key</p> <H2><a href="!LISP_HOME_Snapshot1.html">Snapshot 1</a></H2> <H2><a href="!LISP_HOME_Snapshot2.html">Snapshot 2</a></H2> <H2><a href="!LISP_HOME_Snapshot3.html">Snapshot 3</a></H2> <H2><a href="!LISP_HOME_Snapshot4.html">Snapshot 4</a></H2> <H2><a href="!LISP_HOME_Snapshot5.html">Snapshot 5</a></H2> <H2><a href="!LISP_HOME_Snapshot6.html">Snapshot 6</a></H2> <H2><a href="!LISP_HOME_Snapshot7.html">Snapshot 7</a></H2> <H2><a href="!LISP_HOME_Snapshot8.html">Snapshot 8</a></H2> <H2><a href="!LISP_HOME_Snapshot9.html">Snapshot 9</a></H2> <H2><a href="!LISP_HOME_Snapshot10.html">Snapshot 10</a></H2> </details> </div> </div> <HR> <img src="C_mascot" alt="No mascot found for the LISP programming language" width="128" height="128" center> <HR> </BODY> </HTML> <!-- End of script !-->
7,206
Common Lisp
.l
245
27.493878
357
0.691379
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
995fa5c780ef24950007747a5d452bf0a9225dd8b6af49c9110da1fcdfb4c885
19,849
[ -1 ]
19,858
LispOperators.lsp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LispOperators.lsp
# Start of script (+ 1 2 3 4) (incf x) (if nil (list 1 2 "foo") (list 3 4 "bar")) (or (and "zero" nil "never") "James" 'task 'time) # End of script
162
Common Lisp
.l
8
17.5
49
0.558442
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
86a33dede57260fa967ffbbd9bb1d4c0f56c2aaa4d1d2c086ca736ca451a8a29
19,858
[ -1 ]
19,859
LISP_Construct_V1.lsp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISP_Construct_V1.lsp
; Start of script (cons 1 '(2 3)) ;Output: (1 2 3) (cons '(1 2) '(3 4)) ;Output: ((1 2) 3 4) ; End of script
114
Common Lisp
.l
6
17.166667
21
0.542056
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
54eb7177a81a86e7fcd04dcb25daa7f0ae5c6f9b3a57c5aff5370fd4dc3957d7
19,859
[ -1 ]
19,863
LISP_ListReversal.lsp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISP_ListReversal.lsp
; Start of script (defun -reverse (list) (let ((return-value '())) (dolist (e list) (push e return-value)) return-value)) ; End of script
148
Common Lisp
.l
6
22
43
0.647887
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
c39da0d736e2dade42a9b68f731238259bde9f89e926d1d139671a7e37cdd99b
19,863
[ -1 ]
19,866
LISP_Mapcar_V1.lsp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISP_Mapcar_V1.lsp
; Start of script (mapcar #'+ '(1 2 3 4 5) '(10 20 30 40 50)) ; End of script
78
Common Lisp
.l
3
25
43
0.6
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
59bbc4baf14e351e823cd5ea6c61729c423720c3d5e07d8834854d8ce4a1110c
19,866
[ -1 ]
19,870
LISP_ShouldBeConstant.lsp
seanpm2001_SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-/Lisp (LISt Processor)/Samples/LISP_ShouldBeConstant.lsp
; Start of script (defun should-be-constant () '(one two three)) (let ((stuff (should-be-constant))) (setf (third stuff) 'bizarre)) ; bad! (should-be-constant) ; returns (one two bizarre) ; End of script
214
Common Lisp
.l
7
28.714286
50
0.682927
seanpm2001/SNU_2D_ProgrammingTools_IDE_Lisp_-LISt_Processor-
2
2
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
60686ba1c194520b2cbd300aaa44fe59a8e0ae9e80a780d90c35b3df48960129
19,870
[ -1 ]
19,909
rest-service.lisp
marcmos_lispcap/rest-service.lisp
(in-package :lispcap) (defun rest-service-start (table port) (hunchentoot:define-easy-handler (hosts-handler :uri "/hosts") () (setf (hunchentoot:content-type*) "text/plain") (print-host-table table)) (defvar *hunchentoot-acceptor* (make-instance 'hunchentoot:easy-acceptor :port port)) (hunchentoot:start *hunchentoot-acceptor*)) (defun rest-service-stop () (hunchentoot:stop *hunchentoot-acceptor*))
420
Common Lisp
.lisp
9
43.666667
87
0.745721
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
7edfeabfd96c35610611a916bd359fbba1b1da408299b70bfdc1e15ac7b74911
19,909
[ -1 ]
19,910
lispcap.lisp
marcmos_lispcap/lispcap.lisp
(in-package :lispcap) (defparameter *query-src-mac* #X001122334455) (defparameter *query-src-ip* 3232235521) (defvar *host-table* (make-hash-table)) (defun sniff (iface handler host-table timeout) (plokami:with-pcap-interface (pcap iface :timeout 0) (plokami:set-filter pcap "arp") (loop (plokami:capture pcap -1 handler) (query-inactive-hosts pcap host-table timeout)))) (defun parse-arp (host-table) (lambda (sec usec caplen len buffer) (with-input-from-sequence (stream buffer) (let* ((binary-types:*endian* :big-endian) (arp-datagram (parse-arp-frame sec usec caplen len buffer))) (with-slots (arp-header) arp-datagram (with-slots (mac-src ip-src) arp-header (update-host-activity host-table mac-src :ip ip-src) (print-arp arp-header))))))) (defun query-inactive-hosts (pcap-live host-table timeout) (mapcar (lambda (host) (query-host pcap-live host)) (get-inactive-hosts host-table timeout))) (defun start (iface port timeout) (rest-service-start *host-table* port) (sniff iface (parse-arp *host-table*) *host-table* timeout)) (defun stop () (rest-service-stop))
1,184
Common Lisp
.lisp
27
38.555556
73
0.689565
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
4bee837891bcc8658feb9aceadaf010aa85f3005c9e372eebc340a2d136dc780
19,910
[ -1 ]
19,911
format-address.lisp
marcmos_lispcap/format-address.lisp
(in-package :lispcap) (defun format-mac (mac) (apply #'format nil "~2,'0X:~2,'0X:~2,'0X:~2,'0X:~2,'0X:~2,'0X" (nreverse (loop repeat 6 for x = mac then (truncate x 256) collect (nth-value 1 (truncate x 256)))))) (defun format-ip (ip) (apply #'format nil "~D.~D.~D.~D" (nreverse (loop repeat 4 for x = ip then (truncate x 256) collect (nth-value 1 (truncate x 256))))))
467
Common Lisp
.lisp
11
32.545455
65
0.522026
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
3f1a9ad87c57abac0a24f07c4391a0160d50d0886c1a0b7b43ad294bd05fc7e8
19,911
[ -1 ]
19,912
arp.lisp
marcmos_lispcap/arp.lisp
(in-package :lispcap) (defconstant +arp-htype-ethernet+ 1) (defconstant +arp-ptype-ip+ #X800) (defconstant +arp-plen-ip+ 4) (defconstant +arp-oper-request+ 1) (defconstant +arp-oper-response+ 2) (define-binary-class arp () ((htype :binary-type u16 :initarg :htype) (ptype :binary-type u16 :initarg :ptype) (hlen :binary-type u8 :initarg :hlen) (plen :binary-type u8 :initarg :plen) (opcode :binary-type u16 :initarg :opcode) (mac-src :binary-type maclen :initarg :mac-src) (ip-src :binary-type u32 :initarg :ip-src) (mac-dst :binary-type maclen :initarg :mac-dst) (ip-dst :binary-type u32 :initarg :ip-dst))) (defun make-arp (opcode mac-src ip-src mac-dst ip-dst) (with-binary-output-to-vector (buffer-vector (make-array (list (sizeof 'arp)) :element-type '(unsigned-byte 8) :fill-pointer 0)) (let ((binary-types:*endian* :big-endian)) (write-binary 'arp buffer-vector (make-instance 'arp :htype +arp-htype-ethernet+ :ptype +arp-ptype-ip+ :hlen (sizeof 'maclen) :plen +arp-plen-ip+ :opcode opcode :mac-src mac-src :ip-src ip-src :mac-dst mac-dst :ip-dst ip-dst))) buffer-vector)) (defun print-arp (datagram) (with-slots (mac-src mac-dst opcode ip-src ip-dst) datagram (format t "~A (~A) → ~A (~A) (~[?~;request~;response~])~%" (format-mac mac-src) (format-ip ip-src) (format-mac mac-dst) (format-ip ip-dst) opcode)))
1,850
Common Lisp
.lisp
43
29.674419
65
0.516362
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
c0799517f965316453509e0661aa1f83476b04c93d212bf9a19c9106d7b94633
19,912
[ -1 ]
19,913
ethernet.lisp
marcmos_lispcap/ethernet.lisp
(in-package :lispcap) (define-unsigned maclen 6) (defconstant +ethernet-payload-min-length+ 46) (define-binary-class ethernet-header () ((mac-dst :binary-type maclen :initarg :mac-dst) (mac-src :binary-type maclen :initarg :mac-src) (type :binary-type u16 :initarg :type))) (defun make-ethernet-header (mac-dst mac-src type) (with-binary-output-to-vector (buffer-vector (make-array (list (sizeof 'ethernet-header)) :element-type '(unsigned-byte 8) :fill-pointer 0)) (let ((binary-types:*endian* :big-endian)) (write-binary 'ethernet-header buffer-vector (make-instance 'ethernet-header :mac-dst mac-dst :mac-src mac-src :type type)) buffer-vector))) (defun pad-ethernet-payload (payload) (if (< (length payload) +ethernet-payload-min-length+) (adjust-array payload (list +ethernet-payload-min-length+) :fill-pointer t) payload)) (defun make-ethernet-frame (mac-dst mac-src type payload) (concatenate '(vector (unsigned-byte 8)) (make-ethernet-header mac-dst mac-src type) (pad-ethernet-payload payload)))
1,305
Common Lisp
.lisp
29
33.655172
65
0.590873
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e0fcce722c53c6fb91997338b5fff453a944a898b6502ca6e347db32454bef3a
19,913
[ -1 ]
19,914
arp-inject.lisp
marcmos_lispcap/arp-inject.lisp
(in-package :lispcap) (defconstant +arp-ethertype+ #X0806) (defconstant +arp-mac-broadcast+ #XFFFFFFFFFFFF) (defun make-arp-frame (ether-mac-dst ether-mac-src arp-opcode arp-mac-src arp-ip-src arp-mac-dst arp-ip-dst) (make-ethernet-frame ether-mac-dst ether-mac-src +arp-ethertype+ (make-arp arp-opcode arp-mac-src arp-ip-src arp-mac-dst arp-ip-dst))) (defun make-arp-unicast-query (mac-src ip-src mac-dst ip-dst) (make-arp-frame mac-dst mac-src +arp-oper-request+ mac-src ip-src 0 ip-dst)) (defun make-arp-broadcast-query (mac-src ip-src ip-dst) (make-arp-unicast-query mac-src ip-src +arp-mac-broadcast+ ip-dst)) (defun inject-arp-query (pcap-live query-func host) (plokami:inject pcap-live (funcall query-func host)))
846
Common Lisp
.lisp
15
47.066667
80
0.653753
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
35a5f5e8ebf78895b8e7e423d8b9ecbd70326482cdd7d36285f0e8ac92e88f43
19,914
[ -1 ]
19,915
arp-capture.lisp
marcmos_lispcap/arp-capture.lisp
(in-package :lispcap) (defclass capture-metadata () ((sec :initarg :sec) (usec :initarg :usec) (caplen :initarg :caplen) (len :initarg :len))) (defclass arp-capture () ((ethernet-header :initarg :ethernet-header) (arp-header :initarg :arp-header) (capture-metadata :initarg :capture-metadata))) (defun parse-arp-frame (sec usec caplen len buffer) (with-input-from-sequence (buffer-stream buffer) (let ((binary-types:*endian* :big-endian)) (make-instance 'arp-capture :ethernet-header (read-binary 'ethernet-header buffer-stream) :arp-header (read-binary 'arp buffer-stream) :capture-metadata (make-instance 'capture-metadata :sec sec :usec usec :caplen caplen :len len)))))
1,039
Common Lisp
.lisp
22
29.636364
71
0.495069
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
7573a75457494418784423137f054caaf837602de998930d80e65305f85d1e8d
19,915
[ -1 ]
19,916
query.lisp
marcmos_lispcap/query.lisp
(in-package :lispcap) ;; TODO: Consider using other protocols to query host availability (e.g. MLD). (defun prepare-unicast-query (host) (make-arp-unicast-query *query-src-mac* *query-src-ip* (host-mac host) (host-ip host))) (defun query-host (pcap-live host &optional (query-func #'prepare-host-query)) (format t "Querying ~A...~%" (format-ip (host-ip host))) (plokami:inject pcap-live (funcall query-func host)))
501
Common Lisp
.lisp
10
40.5
78
0.609407
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ae51fd36407c296c193b414a5b4c96a39bf9b508fcaea1bfc85d1ebd31fb9747
19,916
[ -1 ]
19,917
host-table.lisp
marcmos_lispcap/host-table.lisp
(in-package :lispcap) (defclass host () ((mac :accessor host-mac :initarg :mac) (ip :accessor host-ip :initarg :ip) (last-activity :accessor host-last-activity :initarg :last-activity))) (defun update-host-activity (table mac &key (ip nil)) (setf (gethash mac table) (make-instance 'host :mac mac :ip ip :last-activity (get-universal-time)))) (defun print-host-table (table) (apply #'concatenate 'string (loop for host being the hash-value of table collect (format nil "~A ~A ~A~%" (format-mac (host-mac host)) (format-ip (host-ip host)) (- (get-universal-time) (host-last-activity host)))))) (defun get-inactive-hosts (table timeout) (let ((inactive-hosts '()) (current-time (get-universal-time))) (maphash (lambda (mac host) (declare (ignore mac)) (if (>= (- current-time (host-last-activity host)) timeout) (push host inactive-hosts))) table) inactive-hosts))
1,226
Common Lisp
.lisp
33
25.151515
74
0.515559
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
1fbc7b7d32437a9f6bd68c3da900ca17eb5060c6546a31c89098bc01bbe64cee
19,917
[ -1 ]
19,918
lispcap.asd
marcmos_lispcap/lispcap.asd
(asdf:defsystem #:lispcap :depends-on (#:binary-types #:flexi-streams #:plokami #:hunchentoot) :components ((:file "package") (:file "format-address") (:file "ethernet") (:file "arp") (:file "arp-capture") (:file "arp-inject") (:file "host-table") (:file "rest-service") (:file "query") (:file "lispcap")))
491
Common Lisp
.asd
15
19.466667
39
0.42437
marcmos/lispcap
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
86e259d97db2aad9882f7bc824d4a8b48773edd6da571fd66717cd0a58adf6c9
19,918
[ -1 ]
19,943
staple.ext.lisp
meawplex-plus_lispmath/staple.ext.lisp
(setq *print-case* :downcase) (defmethod staple:template ((system (eql (asdf:find-system :lispmath)))) (asdf:system-relative-pathname system #p"template.ctml")) (defclass my-page (staple:simple-page) ()) (defmethod staple:filename ((page my-page)) (make-pathname :name "defindexes" :type "html")) (defmethod staple:page-type ((system (eql (asdf:find-system :lispmath)))) 'my-page) (defmethod staple:resolve-source-link (source (page my-page)) (format NIL "http://github.com/mohindertalafuse/lispmath/blob/master/~a.lisp#L~a" (pathname-name (getf source :file)) (getf source :row)))
597
Common Lisp
.lisp
11
51.909091
84
0.728669
meawplex-plus/lispmath
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
5ad4a1498599d41f66cf9923df53b07fc2e40060069297152f173444fe033040
19,943
[ -1 ]
19,944
package.lisp
meawplex-plus_lispmath/package.lisp
(in-package #:cl-user) (defpackage #:lispmath (:nicknames "*No nicknames*") (:documentation "Handy math tools for Common Lisp.") (:use #:cl) (:export #:sin-degrees #:cos-degrees #:tan-degrees #:cotan-degrees #:cosec-degrees #:sec-degrees #:sec #:cotan #:cosec #:hypot #:fib #:genfib #:fibp #:source-p #:create-p #:genfib #:factorial #:factorialp #:perm #:comb #:genptrow #:genpt #:catn #:catnp #:tau #:τ #:2π #:2pi #:π #:ellipse-perimeter #:ellipse-area #:circle-area #:circumference #:+sin-degrees-identity+ #:+cos-degrees-identity+ #:+tan-degrees-identity+ #:+sec-degrees-identity+ #:+cot-degrees-identity+ #:+csc-degrees-identity+))
764
Common Lisp
.lisp
45
13.133333
54
0.608939
meawplex-plus/lispmath
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
95351ce9b94f6f538ec73468200eafb6994b1dd1ad995e551f5ee12397b31e4d
19,944
[ -1 ]
19,945
functions-and-predicates.lisp
meawplex-plus_lispmath/functions-and-predicates.lisp
(in-package #:lispmath) ;define our create-p macro and source-p function (defun source-p (func) "Return source code for predicate defining function. Expects quote function name as an argument." (let ((funcname (intern (concatenate 'string (symbol-name `,func) "P")))) `(defun ,funcname (args) (loop for i from 1 until (>= (,func i) args) finally (return (equalp (,func i) args)))))) (defmacro create-p (func docstring argname) "Return fully defined predicate function. Does NOT expect quote function name as an argument. Rather, expects straight name. (i.e. (create-p fofo).) Requires docstring as argument." (let ((funcname (intern (concatenate 'string (symbol-name `,func) "P")))) `(defun ,funcname (,argname) ,docstring (loop for i from 1 until (>= (,func i) ,argname) finally (return (equalp (,func i) ,argname)))))) ; main lisp-math functions (defun fib (n) "Take N and return the Nth fibonacci number." (cond ((<= n 0) (format t "Fibonacci of < 1 is not defined")) ((= 1 n) (values 1)) ((= 2 n) (values 1)) (t (+ (fib (- n 1)) (fib (- n 2)))))) (defun genfib (list-size) "Take LIST-SIZE and return a list of the first LIST-SIZE fibonacci numbers." (mapcar #'fib (loop for i from 1 to list-size collect i))) (defun factorial (a &optional (fact 1)) "Calculate factorial. Optional second arg for multifactorial." (cond ((< a 0) (format t "Factorial of < 0 is not defined")) (t (reduce #'* (loop for i from a downto 1 by fact collect i))))) (defun perm (n k) "Take N and K and return P(N, K). (P(N, K) is the permutations of N and K.)" (/ (factorial n) (factorial (- n k)))) (defun comb (n k) "Take N and K and return C(N, K). (C(N, K) is the combinations of N and K.)" (/ (perm n k) (factorial k))) (defun genptrow (n) "Take N and return the Nth row of Pascal's Triangle. The first row is row 0. Thus, (genptrow 1) evaluates to everything on row 0." (loop for i from 0 to (1- n) for y = (comb (1- n) i) collect y)) (defun genpt (rows) "Take ROWS and return the first ROWS rows of Pascal's Triangle." (loop for x from 1 to rows initially (print (format nil "~130:@<~A~>" "Warning: more than 17 rows looks funky")) do (print (format nil "~130:@<~A~>" (genptrow x))))) (defun catn (n) "Take N and return the Nth Catalan number. ((catn 0) evaluates to 0.)" (/ (comb (* 2 n) n) (1+ n))) ; add predicates for all necessary forms (create-p catn "Predicate for catn func." n) (create-p fib "Predicate for fib func." n) (create-p factorial "Predicate for factorial func." n)
2,800
Common Lisp
.lisp
72
33.555556
90
0.617853
meawplex-plus/lispmath
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e87335333b23a05c25d6061eb1ab05a7220e9c5fed6bb35f8f62f3a0c2c03cd6
19,945
[ -1 ]
19,946
circular.lisp
meawplex-plus_lispmath/circular.lisp
(in-package #:lispmath) ;; Some useful constants, no earmuffs so they are more like pi (defconstant tau (+ pi pi) "Going back to tau/pi. The literal name.") (defconstant 2pi tau "Another way to represent tau. In fact, tau is more often used than pi!") (defconstant 2π tau "And this too, but instead with the symbol for pi.") (defconstant π pi "There's going to be one last symbol...") (defconstant τ tau "This one.") ;; (defun ellipse-perimeter (a b) "Matt Parker's algorithm for estimating the perimeter of an ellipse, where perimeter ≈ π[53a/3 + 717b/35 - √(269a^2 + 667ab + 371b^2)] Implemented by Karsten Johansson (https://github.com/ksaj/ksaj-ellipses)" (check-type a number) ; Keep code safe from injection (check-type b number) ; (if (= a b) (princ "Use the circumference function for circles. This result will be inaccurate.")) (if (< a b) ; A needs to be the longer axis (rotatef a b)) (* pi (- (+ (* 53 (/ a 3)) (* 717 (/ b 35))) (sqrt (+ (* 269 (* a a)) (* 667 a b) (* 371 (* b b))))))) ;; (defun ellipse-area (a b) "Calculate area of an ellipse. Implemented by Karsten Johansson." (check-type a number) ; Keep code safe from injection (check-type b number) ; (* pi a b)) ;; (defun circle-area (radius) "Calculate area of a circle. Implemented by Karsten Johansson." (check-type radius number) (* pi radius radius)) ;; (defun circumference (radius) "Calculate circumference of a circle. Implemented by Karsten Johansson." (check-type radius number) (* tau radius))
1,659
Common Lisp
.lisp
39
38.179487
100
0.645951
meawplex-plus/lispmath
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e35162cd6f390f1e49406c63384102ea0604a88a5f27971a846d6a214846c1b8
19,946
[ -1 ]
19,947
trig.lisp
meawplex-plus_lispmath/trig.lisp
(in-package #:lispmath) ;; Earmuffs omitted to match other constants. Some useful identities. (defconstant +sin-degrees-identity+ 90 "For sine this time") (defconstant +cos-degrees-identity+ 360 "Cosine identity in degrees") (defconstant +tan-degrees-identity+ 45 "Tangent too") (defconstant +sec-degrees-identity+ 0 "Secant identity") (defconstant +cot-degrees-identity+ 45 "Same, but for cotangent") (defconstant +csc-degrees-identity+ 90 "Cosecant this time") (defun hypot (leg1 leg2) "Calculate hypotenuse length of triangle made by two legs." (sqrt (+ (* leg1 leg1) (* leg2 leg2)))) (defun sin-degrees (degrees) "Calculate the ratio of the opposite to the hypotenuse leg of the angle chosen. Returns number of type double-float; in other words, (sin-degrees 90) -> 1.0d0." (sin (* (/ pi 180) degrees))) (defun cos-degrees (degrees) "Calculate the ratio of the adjacent to the hypotenuse leg of the angle chosen. Returns number of type double-float; in other words, (cos-degrees 360) -> 1.0d0." (cos (* (/ pi 180) degrees))) (defun tan-degrees (degrees) "Calculate the ratio of the opposite to the adjacent leg of the angle chosen. Returns number of type double-float; in other words, (tan-degrees 45) -> 1.0d0." (tan (* (/ pi 180) degrees))) (defun sec-degrees (degrees) "Calulate the secant (colloquially the 'co-cosine') of an angle, which is 1/cos(angle). Returns number of type double float; in other words, (sec-degrees 0) -> 1.0d0." (/ 1 (cos-degrees degrees))) (defun cot-degrees (degrees) "Calculate the cotangent of an angle, which is 1/tan(angle). Returns number of type double float; in other words, (cot-degrees 45) -> 1.0d0." (/ 1 (tan-degrees degrees))) (defun csc-degrees (degrees) "Calculate the cosecant of an angle, which is 1/sin(angle). Returns number of type double float; in other words, (csc-degrees 90) -> 1.0d0." (/ 1 (sin-degrees degrees)))
1,909
Common Lisp
.lisp
35
52.485714
90
0.732583
meawplex-plus/lispmath
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
0f050a50a3442543633cbdeae1e7157b972646cb8708aba7376d631292dd6c72
19,947
[ -1 ]
19,948
lispmath.asd
meawplex-plus_lispmath/lispmath.asd
(asdf:defsystem #:lispmath :version "1.2.0" :description "The handy dandy math pack" :author "mohindertalafuse (Mo Talafuse) and stalafuse (Scott Talafuse) and ksaj (Karsten Johansson)" :homepage "https://mohindertalafuse.github.io" :bug-tracker "https://github.com/mohindertalafuse/lispmath/issues" :source-control (:git "https://github.com/mohindertalafuse/lispmath") :serial t :components ((:file "package") (:file "functions-and-predicates") (:file "trig") (:file "circular")))
537
Common Lisp
.asd
12
39.166667
104
0.689524
meawplex-plus/lispmath
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ce339e2ff581ffa5a7b3c31c8e89a625150f7b434710fe85e93a03419558cbf5
19,948
[ -1 ]
19,952
template.ctml
meawplex-plus_lispmath/template.ctml
<!DOCTYPE html> <html lang="en" lquery="(attr :lang language)"> <head> <meta charset="utf-8" /> <title>lispmath v1.0.0 documentation</title> <style lquery='(text (read-file (asdf:system-relative-pathname :staple "default/default.css")))'></style> </head> <body> <article class="project"> <header> <c:when test="images"> <img class="logo" src="logo.svg" alt="Logo" lquery="(attr :src (first images))" /> </c:when> <h1 lquery="(text title)">Name</h1> <c:when test="system"> <span class="version" lquery="(text (clip:clip system :version))">1.0</span> </c:when> <nav class="languages" iterate="(pages project)"> <c:when test="(string= title (** :title))"> <a href="#" lquery="(attr :href (relative-path * (** :page))) (text (first (language-codes:names language)))">LANG</a> </c:when> </nav> <c:when test="system"> <p class="description" lquery="(text (clip:clip system :description))"> Some short description of the lib. </p> </c:when> <nav class="pages" iterate="(pages project)"> <c:when test="(and (or (string/= title (** :title)) (eq * (** :page))) (string= language (** :language)))"> <a href="#" lquery="(attr :href (relative-path * (** :page))) (text title)">TITLE</a> </c:when> </nav> </header> <section id="documentation" lquery="(html documentation)"> </section> <c:when test="system"> <c:using value="system"> <section id="system"> <h2>System Information</h2> <c:when test="version"> <div class="row"> <label for="version">Version:</label> <a id="version" lquery="(text version)">version</a> </div> </c:when> <c:when test="dependencies"> <div class="row"> <label for="dependencies">Dependencies:</label> <ul id="dependencies" iterate="dependencies"><li><a class="external" lquery="(text (asdf:component-name *)) (attr :href (system-field 'homepage *))"></a></li></ul> </div> </c:when> <c:when test="author"> <div class="row"> <label for="author">Author:</label> <a id="author" href="#" lquery='(attr :href (when (extract-author-email author) (format NIL "mailto:~a" (extract-author-email author)))) (text (extract-author-name author))'>author</a> </div> </c:when> <c:when test="license"> <div class="row"> <label for="license">License:</label> <a id="license" href="#" lquery="(attr :href license-link) (text license)">license</a> </div> </c:when> <c:when test="homepage"> <div class="row"> <label for="homepage">Homepage:</label> <a id="homepage" href="#" lquery="(attr :href homepage) (text homepage)">http://example.com</a> </div> </c:when> <c:when test="source-control"> <div class="row"> <label for="sources">Sources:</label> <a id="sources" href="#" lquery="(attr :href source-control) (text source-control)">http://example.com</a> </div> </c:when> <c:when test="bug-tracker"> <div class="row"> <label for="bug-tracker">Report issues to:</label> <a id="bug-tracker" href="#" lquery="(attr :href bug-tracker) (text bug-tracker)">http://example.com</a> </div> </c:when> </section> </c:using> </c:when> <c:when test="packages"> <section id="index"> <h2>Definition Index</h2> <ul iterate="(mapcar #'staple::ensure-package-definition packages)"> <li> <article class="definition package" lquery="(attr :id id)"> <header> <h3> <a href="#" lquery="(attr :href xref) (text name)">FOO</a> </h3> <ul class="nicknames" iterate="nicknames"> <li lquery="(text *)">CL-FOO</li> </ul> <c:when test="source-link"> <a class="source-link" href="#" lquery="(attr :href source-link)">Source</a> </c:when> </header> <div class="docstring" lquery="(html formatted-documentation)">Docstring</div> <ul class="definitions" iterate="definitions"> <li> <article class="definition" lquery="(add-class (string-downcase type)) (add-class (when (typep * 'definitions:callable) (string-downcase :callable))) (attr :id id)"> <header> <span class="visibility" lquery="(text visibility)">visibility</span> <span class="type" lquery="(text type)">type</span> <h4 class="name"> <a href="#" lquery="(attr :href xref) (text designator)">name</a> </h4> <ul class="qualifiers" iterate="qualifiers"> <li class="qualifier" lquery="(text *)">qualifier</li> </ul> <ul class="arguments" iterate="(purify-arglist arguments)"> <c:if test="(listp *)"> <c:then> <ul class="arguments" iterate="*"> <li class="argument" lquery="(text *) (add-class (when (find * (symbol-value 'lambda-list-keywords)) :lambda-list-keyword))">argument</li> </ul> </c:then> <c:else> <li class="argument" lquery="(text *) (add-class (when (find * (symbol-value 'lambda-list-keywords)) :lambda-list-keyword))">argument</li> </c:else> </c:if> </ul> <c:when test="source-link"> <a class="source-link" href="#" lquery="(attr :href source-link)">Source</a> </c:when> </header> <div class="docstring" lquery="(html formatted-documentation)">Docstring</div> </article> </li> </ul> </article> </li> </ul> </section> </c:when> </article> <script lquery='(text (read-file (asdf:system-relative-pathname :staple "default/default.js")))'></script> </body> </html>
6,912
Common Lisp
.l
144
32.979167
200
0.481235
meawplex-plus/lispmath
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
bcc388ee6096adeaab770813dc009c60efc31f3e44cfe5c1daa84ad36e6f7f4b
19,952
[ -1 ]
19,970
axes.lisp
grapesmoker_cl-plot/src/axes.lisp
(in-package :plot) (defparameter *default-padding* 10) (defclass axis (line) ;; we'll go ahead and inherit any line-related properties from ;; the line class itself ;; min and max values being plotted on the axis ((min-value :accessor axis-min-value :initarg :min) (max-value :accessor axis-max-value :initarg :max) ;; list of major and minor ticks ;; ticks should probably be their own objects so we can just call ;; some generic draw-line method on them (major-ticks :accessor axis-major-ticks :initarg :major-ticks) (minor-ticks :accessor axis-minor-ticks :initarg :minor-ticks) ;; padding between the axis and the start of the plot (padding :accessor axis-padding :initarg :padding :initform *default-padding*) ;; label for the axis (label :accessor axis-label :initarg :label :initform nil) ;; internal variable, you probably shouldn't use this directly (label-position :accessor axis-label-position :initarg label-position :initform nil) ;; orientation in degrees, default is 0 (label-orientation :accessor axis-label-orientation :initarg label-orientation :initform 0) ;; formatters are functions that control the label/tick text (label-formatter :accessor axis-label-formatter :initarg :label-formatter) (tick-formatter :accessor axis-tick-formatter :initarg :tick-formatter))) (defclass axes (plot-object) ((x-axis :accessor axes-x-axis :initarg :x-axis :initform nil) (y-axis :accessor axes-y-axis :initarg :y-axis :initform nil) ;; I'm not sure what these are for, seemingly redundant with the ;; individual axes (x-pos :accessor axes-x :initarg :x :initform nil) (y-pos :accessor axes-y :initarg :y :initform nil) ;; offsets (x-off :accessor axes-x-off :initarg :x-off :initform nil) (y-off :accessor axes-y-off :initarg :y-off :initform nil) ;; how much space the axes are allowed to occupy ;; consider allowing this to be specified as a percentage (width :accessor axes-width :initarg :width :initform nil) (height :accessor axes-height :initarg :height :initform nil) ;; the data that the plots hold (data-objects :accessor axes-data :initarg :data :initform nil) (data-x-transforms :accessor axes-data-x-tforms :initarg :data-x-tforms :initform nil) (data-y-transforms :accessor axes-data-y-tforms :initarg :data-y-tforms :initform nil))) (defmethod initialize-instance :before ((ax axes) &rest args) (declare (ignore args)) ()) (defmethod initialize-instance :after ((ax axes) &rest args) ;; after the axes have been initialized we should initialize the ;; individual axis elements and make sure the axes ;; some parameters must be initialized so they'll go here if not ;; passed in otherwise (unless (getf args :width) (setf (axes-width ax) *default-axes-width*)) (unless (getf args :height) (setf (axes-height ax) *default-axes-height*)) (unless (getf args :x-off) (setf (axes-x-off ax) *default-x-offset*)) (unless (getf args :y-off) (setf (axes-y-off ax) *default-y-offset*)) ;; now that we can guarantee that the offset and dimensions are set, ;; we should also set the bounding box (unless (getf args :bbox) (let ((lower-left-x (axes-x-off ax)) (lower-left-y (axes-y-off ax)) (upper-right-x (+ (axes-x-off ax) (axes-width ax))) (upper-right-y (+ (axes-y-off ax) (axes-height ax)))) (setf (bbox ax) `(,lower-left-x ,lower-left-y ,upper-right-x ,upper-right-y)))) ;; now we should initialize the actual axes if they were not passed ;; in explicitly ;; WARNING! Creating your own axis objects is definitely something ;; the end-user should NOT do! The init functions will take care to ;; align the children axis objects properly relative to the parent. ;; Safety not guaranteed if this functionality is overwritten. (unless (getf args :x-axis) (setf (axes-x-axis ax) (make-instance 'axis :thickness *default-line-thickness* :color *default-line-color* :parent ax))) (unless (getf args :y-axis) (setf (axes-y-axis ax) (make-instance 'axis :thickness *default-line-thickness* :color *default-line-color* :parent ax))) (when (axes-data ax) (typecase (axes-data ax) (data-object (setf (axes-data ax) (list (axes-data ax)))) (cons (dolist (obj (axes-data ax)) (setf (plot-object-parent obj) ax))))) ;; once we've created the children, normalize them (normalize-axes ax)) (defmethod normalize-axes ((ax axes)) "Normalizes the children axis objects so that they fit properly within the bounding box of the parent axes." (let ((x-axis (axes-x-axis ax)) (y-axis (axes-y-axis ax)) (width (axes-width ax)) (height (axes-height ax)) (x-off (axes-x-off ax)) (y-off (axes-y-off ax))) ;;(axes-bbox (bbox ax))) ;; Note that normalize-axes is brutal; it will force the child ;; axis objects to have the right coordinates regardless of what ;; they had before (setf (line-start-x x-axis) x-off) (setf (line-end-x x-axis) (+ x-off width)) (setf (line-start-y x-axis) y-off) (setf (line-end-y x-axis) y-off) (setf (line-start-x y-axis) x-off) (setf (line-end-x y-axis) x-off) (setf (line-start-y y-axis) y-off) (setf (line-end-y y-axis) (+ y-off height)))) (defmethod set-data-to-axes-tforms ((ax axes)) (let* ((data-objects (axes-data ax)) (im-height (plot-image-height (plot-object-parent (plot-object-parent ax)))) (flat-x-data (apply #'append (mapcar #'data-obj-x-data data-objects))) (flat-y-data (apply #'append (mapcar #'data-obj-y-data data-objects))) (x-data-max (apply #'max flat-x-data)) (x-data-min (apply #'min flat-x-data)) (y-data-max (apply #'max flat-y-data)) (y-data-min (apply #'min flat-y-data)) (x-axis (axes-x-axis ax)) (y-axis (axes-y-axis ax)) (x-padding (axis-padding x-axis)) (y-padding (axis-padding y-axis)) (axes-bbox (bbox ax)) (x-axis-delta (- (elt axes-bbox 2) (elt axes-bbox 0) (* 2 x-padding))) (y-axis-delta (- (elt axes-bbox 3) (elt axes-bbox 1) (* 2 y-padding))) (x-data-delta (- x-data-max x-data-min)) (y-data-delta (- y-data-max y-data-min)) ;; scale factors (x-scale (/ x-axis-delta x-data-delta)) (y-scale (/ y-axis-delta y-data-delta)) ;; offsets (x-offset (- (elt axes-bbox 2) (* x-data-max x-scale) (* 2 x-padding))) (y-offset (- (elt axes-bbox 3) (* y-data-max y-scale) (* 2 y-padding)))) (labels ((scale-x (x) (coerce (+ (* x x-scale) x-offset x-padding) 'float)) (scale-y (y) (coerce (- im-height (+ (* y y-scale) y-offset y-padding)) 'float))) (setf (axes-data-x-tforms ax) #'scale-x) (setf (axes-data-y-tforms ax) #'scale-y)))) (defmethod scale-data-to-axes ((ax axes)) "This function scales the data supplied to the axes by performing the necessary affine transformations. ax should already know where it lives in image space; now the trick is to transform the data also into image space." ;; an axes object could hold multiple data-objects that all need to ;; be transformed (print (length (axes-data ax))) (loop for data in (axes-data ax) with x-tform = (axes-data-x-tforms ax) with y-tform = (axes-data-y-tforms ax) ;;do ;; (format t "x data: ~A~%" (data-obj-x-data data)) collect (let* ((scaled-data (make-instance 'data-object :color (data-obj-color data) :style (data-obj-style data) :type (data-obj-type data) :thickness (data-obj-thickness data) :parent (plot-object-parent data))) (x-data (data-obj-x-data data)) (y-data (data-obj-y-data data))) ;; currently we only accept sequences as data; at some point we ;; should add support for vectors ;; until we get a proper condition system up ;;(format t "x-axis-delta: ~F, y-axis-delta: ~F~%" x-axis-delta y-axis-delta) ;;(format t "x-scale: ~F, y-scale: ~F~%" x-scale y-scale) (let ((scaled-x-data (mapcar x-tform x-data)) (scaled-y-data (mapcar y-tform y-data))) ;;(format t "~A~%" scaled-x-data) ;;(format t "~A~%" scaled-y-data) (setf (data-obj-x-data scaled-data) scaled-x-data) (setf (data-obj-y-data scaled-data) scaled-y-data) scaled-data)))) (defmethod set-tick-marks ((ax axes) &key (num-major-ticks 5) (step-fraction 0.2)) (declare (ignore step-fraction)) (let* ((data-objects (axes-data ax)) (im-height (plot-image-height (plot-object-parent (plot-object-parent ax)))) (flat-x-data (apply #'append (mapcar #'data-obj-x-data data-objects))) (flat-y-data (apply #'append (mapcar #'data-obj-y-data data-objects))) (x-data-max (apply #'max flat-x-data)) (x-data-min (apply #'min flat-x-data)) (y-data-max (apply #'max flat-y-data)) (y-data-min (apply #'min flat-y-data)) (x-axis (axes-x-axis ax)) (y-axis (axes-y-axis ax)) (x-tform (axes-data-x-tforms ax)) (y-tform (axes-data-y-tforms ax)) (space-between-x-ticks (abs (/ (- x-data-max x-data-min) num-major-ticks))) (space-between-y-ticks (abs (/ (- y-data-max y-data-min) num-major-ticks))) (major-x-ticks (loop with x-coord = x-data-min while (<= x-coord x-data-max) collect (let ((tick (make-instance 'tick :type :major :color *default-line-color* :axis-coord x-coord :start-x (funcall x-tform x-coord) :end-x (funcall x-tform x-coord) :start-y (- im-height (line-start-y x-axis)) :end-y (- im-height (- (line-end-y x-axis) 5))))) (incf x-coord space-between-x-ticks) tick))) (major-y-ticks (loop with y-coord = y-data-min while (<= y-coord y-data-max) collect (let ((tick (make-instance 'tick :type :major :color *default-line-color* :axis-coord y-coord :start-x (line-start-x y-axis) :end-x (- (line-end-x y-axis) 5) :start-y (funcall y-tform y-coord) :end-y (funcall y-tform y-coord)))) (incf y-coord space-between-y-ticks) tick)))) (setf (axis-major-ticks x-axis) major-x-ticks) (setf (axis-major-ticks y-axis) major-y-ticks))) (defmethod draw-axis ((ax axis) context) ;;(with-context (context) (draw-line ax context)) (defmethod draw-plot-object ((ax axis) context) (with-context (context) (draw-line ax context))) (defmethod copy-axis-line ((ax axis)) "Creates a line with all the properties of the axis." (make-instance 'line :color (line-color ax) :thickness (line-thickness ax) :style (line-style ax) :start-x (line-start-x ax) :end-x (line-end-x ax) :start-y (line-start-y ax) :end-y (line-end-y ax))) (defmethod draw-plot-object ((ax axes) context) (with-context (context) ;; do some math here to transform from the data coordinates to the ;; picture coordinates ;; hmm, we might not want to use the draw-plot-object generic to ;; draw the axes. reason being that axes know their coordinate ;; system, while the children of the axes do not. so the function ;; that draws the axes needs to take some sort of coords as an ;; argument. need to think carefully about whether we want to ;; expand the args of the generic or make the draw-axes function ;; special (let* ((scaled-data (scale-data-to-axes ax)) (x-axis (axes-x-axis ax)) (y-axis (axes-y-axis ax)) ;; (width (axes-width ax)) ;; (height (axes-height ax)) (parent-plot (plot-object-parent ax)) (parent-image (plot-object-parent parent-plot)) ;; (im-width (plot-image-width parent-image)) (im-height (plot-image-height parent-image))) ;; at this point we are assuming the axes are normalized so that ;; the children's start/end points line up with the corners of ;; the bounding box ;; draw the tick marks (set-tick-marks ax) ;; draw the axes themselves (dolist (axis `(,x-axis ,y-axis)) ;; image-y = image-height - y (let ((axis-line (copy-axis-line axis))) (setf (line-start-y axis-line) (- im-height (line-start-y axis-line))) (setf (line-end-y axis-line) (- im-height (line-end-y axis-line))) (draw-plot-object axis-line context) (loop for mark in (axis-major-ticks axis) do (draw-plot-object mark context)))) ;; now draw the data (dolist (data-obj scaled-data) (loop for x in (data-obj-x-data data-obj) for y in (data-obj-y-data data-obj) do (let ((data-point (make-instance 'point :x x :y y ;;o (- im-height y) :color (data-obj-color data-obj) :weight (data-obj-thickness data-obj) ))) (draw-plot-object data-point context)))))))
13,922
Common Lisp
.lisp
328
34.295732
88
0.605399
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
2b5542eba4aaf7abc5081a2ce8133fd85a7858b99ce7601420055f2bb3fc08dd
19,970
[ -1 ]
19,971
line.lisp
grapesmoker_cl-plot/src/line.lisp
(in-package :plot) (defclass line (plot-object) ((start-x :accessor line-start-x :initarg :start-x :initform nil) (start-y :accessor line-start-y :initarg :start-y :initform nil) (end-x :accessor line-end-x :initarg :end-x :initform nil) (end-y :accessor line-end-y :initarg :end-y :initform nil) ;; line thickness (thickness :accessor line-thickness :initarg :thickness :initform *default-line-thickness*) ;; don't know what "style" means yet, but things like dashed, etc. (style :accessor line-style :initarg :style :initform nil) ;; color as an rgb-triplet (color :accessor line-color :initarg :color :initform *default-line-color*))) (defmethod print-object ((l line) stream) (format t "#LINE<(~D, ~D) -> (~D, ~D)>" (line-start-x l) (line-start-y l) (line-end-x l) (line-end-y l))) ;; it's not clear to me whether a line actually needs to have a ;; bounding box; put it in for now and we'll figure it out if we need ;; to remove it for some reason (defmethod initialize-instance :after ((l line) &rest args) (declare (ignore args)) (cond ((and (numberp (line-start-x l)) (numberp (line-start-y l)) (numberp (line-end-x l)) (numberp (line-end-y l))) (let ((lower-left-x (min (line-start-x l) (line-end-x l))) (lower-left-y (min (line-start-y l) (line-end-y l))) (upper-right-x (max (line-start-x l) (line-end-x l))) (upper-right-y (max (line-start-y l) (line-end-y l)))) (setf (bbox l) `(,lower-left-x ,lower-left-y ,upper-right-x ,upper-right-y)))))) (defmethod draw-line ((l line) context) ;; in reality this should be a generic (draw plot-object) method and ;; then we should just dispatch on the object type. also we don't ;; need to create a context in this function because it's so low ;; level, the context will be passed down to us from above (with-context (context) (destructuring-bind (r g b) (line-color l) (set-source-rgb r g b) (set-line-width (line-thickness l)) (move-to (line-start-x l) (line-start-y l)) (line-to (line-end-x l) (line-end-y l)) (stroke)))) (defmethod draw-plot-object ((l line) context) ;; context is passed down to us from above (with-context (context) (destructuring-bind (r g b) (line-color l) (set-source-rgb r g b) (set-line-width (line-thickness l)) (move-to (line-start-x l) (line-start-y l)) (line-to (line-end-x l) (line-end-y l)) (stroke))))
2,688
Common Lisp
.lisp
71
31.28169
91
0.60743
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
0b6184bd972da36d5586d3a446c3edecca982b0d970b8ad2c5ab92d762af6b82
19,971
[ -1 ]
19,972
image.lisp
grapesmoker_cl-plot/src/image.lisp
(in-package :plot) ;; some defaults (defparameter *default-im-width* 640) (defparameter *default-im-height* 480) (defparameter *default-axes-width* 600) (defparameter *default-axes-height* 440) (defparameter *default-x-offset* 20) (defparameter *default-y-offset* 20) (defparameter *default-line-color* '(0 0 0)) (defparameter *default-line-thickness* 2.0) (defclass plot-image (plot-object) ;; the image's bbox is just the size of the actual image in pixels ;; the image holds the set of all plots represented on it ((plots :accessor plot-image-plots :initarg :plots :initform nil) ;; width and height dictate the size of the image in pixels (width :accessor plot-image-width :initarg :width) (height :accessor plot-image-height :initarg :height) ;; background color as an rgb triple (bg-color :accessor plot-image-bg-color :initarg :bg-color) ;; the output type of the image e.g. pdf, svg, png, etc. (output-type :accessor plot-image-output-type :initarg :output-type) ;; image filename (filename :accessor plot-image-filename :initarg :filename))) (defmethod initialize-instance :after ((im image) &rest args) (unless (getf args :width) (setf (image-width im) *default-im-width*)) (unless (getf args :height) (setf (image-width im) *default-im-height*)) (setf (bbox im) (list 0 0 (image-width im) (image-height im))))
1,459
Common Lisp
.lisp
36
35.694444
68
0.691384
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
1c39074997f1944ec30e3d4d8a396042a3f35d01266bee27a40c845b0efc5f2a
19,972
[ -1 ]
19,973
options.lisp
grapesmoker_cl-plot/src/options.lisp
(in-package :plot) ;; a parameter to hold all of our options and the means for setting ;; them. it will actually hold a list of conses whose car is the ;; option and whose cdr is a function for setting those options (defparameter *plot-options* '()) (defmacro define-option (option-name option-handler) "This macro takes as an argument an option and a handler that is used to set that option. It stores it in the alist *plot-options*. option-name must be a keyword, option-handler is the name of the function used to set it. e.g. (define-option :line-width set-line-width)" (let ((option-handler-name (gensym))) `(progn (let ((,option-handler-name ',option-handler)) (push (cons ,option-name ,option-handler-name) *plot-options*))))) (defmacro with-options ((&rest options) &rest body) (if (oddp (length options)) (error 'error "Odd number of arguments to with-options!")) `(progn (loop for (opt val) on '(,@options) for i upfrom 0 if (evenp i) do (let ((option-handler (cdr (assoc opt *plot-options*)))) (funcall option-handler val))) ,@body)) (defmacro with-test ((&rest args) &rest body) (format t "~A~%" args) `(progn ,@body))
1,246
Common Lisp
.lisp
30
36.7
75
0.671358
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
bfbd7f0e10c845cc2d3374566a548132f9866391687e58e90b45baad0387468b
19,973
[ -1 ]
19,974
plots.lisp
grapesmoker_cl-plot/src/plots.lisp
(in-package :plot) (defclass plot (plot-object) ;; a plot owns the axes that belong to it and the labels; its ;; bounding box is the right size to contain all of it ((title :accessor plot-title :initarg :title :initform nil) (x-label :accessor plot-x-label :initarg :x-label :initform nil) (y-label :accessor plot-y-label :initarg :y-label :initform nil) (axes :accessor plot-axes :initarg :axes :initform nil) (plot-type :accessor plot-type :initarg :plot-type :initform :scatter))) ;; at some point this function will have to draw the labels as well ;; but not yet (defmethod draw-plot-object ((pl plot) context) (dolist (ax (plot-axes pl)) (draw-plot-object ax context)))
815
Common Lisp
.lisp
24
27.125
67
0.628644
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
b9397342d591bb54911167286b6a6bd61e15405bb9aaa6f54c63814673d70905
19,974
[ -1 ]
19,975
ticks.lisp
grapesmoker_cl-plot/src/ticks.lisp
(in-package :plot) (defclass tick (line) ;; a tick is just a subclass of line, but it also knows where on the ;; axis it lives. this is a data coordinate ((axis-coord :accessor tick-axis-coord :initarg :axis-coord :initform nil) ;; is it a label? (label :accessor tick-label :initarg :label :initform nil) ;; is it minor or major? (type :accessor tick-type :initarg :type :initform nil))) (defmethod draw-plot-object ((tt tick) context) ;; do some stuff here to transform from the data coordinates to ;; physical coordinates; as a rule a tick doesn't need to know its ;; image coordinates until it's ready to be drawn, so we can do the ;; calculation here (call-next-method))
776
Common Lisp
.lisp
21
31.190476
70
0.659574
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
c85ce1a921a3cfd4a13610ab2db5271b22c050492d65c1f07c9ed7ef9e3e7d39
19,975
[ -1 ]
19,976
plot-objects.lisp
grapesmoker_cl-plot/src/plot-objects.lisp
(in-package :plot) (defclass plot-object () ;; every plot object should know who its parent is so we can ;; navigate up and down the hierarchy in any direction ((parent :accessor plot-object-parent :initarg :parent :initform nil) ;; every object that we plot needs to have a bounding box ;; which is a 4-tuple of (lower-left-x lower-left-y upper-right-x upper-right-y) (bbox :accessor bbox :initarg :bbox :initform nil))) (defmethod lower-left ((obj plot-object)) (subseq (bbox obj) 0 2)) (defmethod upper-right ((obj plot-object)) (subseq (bbox obj) 2 4)) (defgeneric draw-plot-object (obj context) (:documentation "A generic function that draws the plot-object in the given context. Every class that derives from plot-object should implement this function."))
832
Common Lisp
.lisp
19
39.263158
86
0.70581
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
207341aa50af52aa07490ce4620583d9b8c92fb19a2ca136359402fa81d215c3
19,976
[ -1 ]
19,977
point.lisp
grapesmoker_cl-plot/src/point.lisp
(in-package :plot) (defparameter *default-point-color* '(0 0 1)) (defparameter *default-point-weight* 2.5) (defclass point (plot-object) ;; a point is just a plot object with x and y coordinates, plus some ;; style information ((x :accessor point-x :initarg :x :initform nil) (y :accessor point-y :initarg :y :initform nil) ;; point weight (weight :accessor point-weight :initarg :weight :initform *default-point-weight*) ;; don't know what "style" means yet, but things like dashed, etc. (style :accessor point-style :initarg :style :initform nil) ;; color as an rgb-triplet (color :accessor point-color :initarg :color :initform *default-point-color*))) (defmethod initialize-instance :after ((p point) &rest args) (declare (ignore args)) ;; points do have bounding-boxes! (when (and (point-x p) (point-y p) (point-weight p)) (let ((offset (/ (point-weight p) 2))) (setf (bbox p) (list (- (point-x p) offset) (- (point-y p) offset) (+ (point-x p) offset) (+ (point-y p) offset)))))) (defmethod draw-plot-object ((p point) context) ;; drawing a point is like drawing a line from the point to itself (with-context (context) (destructuring-bind (r g b) (point-color p) (let ((saved-line-cap (get-line-cap))) (set-line-cap :round) (set-source-rgb r g b) (set-line-width (point-weight p)) (move-to (point-x p) (point-y p)) (line-to (point-x p) (point-y p)) (stroke) (set-line-cap saved-line-cap)))))
1,686
Common Lisp
.lisp
48
28.104167
70
0.595471
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
492def5e49c0dc979e8e962f0ae76b73e19ad8530522fe02c598e60f9b44e851
19,977
[ -1 ]
19,978
data-object.lisp
grapesmoker_cl-plot/src/data-object.lisp
(in-package :plot) ;; a class that holds the actual data that gets plotted (defclass data-object (plot-object) ((x-data :accessor data-obj-x-data :initarg :x-data :initform nil) (y-data :accessor data-obj-y-data :initarg :y-data :initform nil) (style :accessor data-obj-style :initarg :style :initform nil) (color :accessor data-obj-color :initarg :color :initform *default-point-color*) (thickness :accessor data-obj-thickness :initarg :thickness :initform *default-point-weight*) ;; type indicates how to actually render the data contained in the object (type :accessor data-obj-type :initarg :type :initform nil)))
777
Common Lisp
.lisp
22
27.181818
76
0.62367
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
b4bb74e8c20f11e0e15c8eeb6c1d87e18b0234a50e6677fe4a6f2b8834c21f18
19,978
[ -1 ]
19,979
plot-image.lisp
grapesmoker_cl-plot/src/plot-image.lisp
(in-package :plot) ;; some defaults (defparameter *default-im-width* 640) (defparameter *default-im-height* 480) (defparameter *default-axes-width* 600) (defparameter *default-axes-height* 440) (defparameter *default-x-offset* 20) (defparameter *default-y-offset* 20) (defparameter *default-line-color* '(0 0 0)) (defparameter *default-line-thickness* 2.0) (defparameter *default-bg-color* '(1 1 1)) (defclass plot-image (plot-object) ;; the image's bbox is just the size of the actual image in pixels ;; the image holds the set of all plots represented on it ((plots :accessor plot-image-plots :initarg :plots :initform nil) ;; width and height dictate the size of the image in pixels (width :accessor plot-image-width :initarg :width) (height :accessor plot-image-height :initarg :height) ;; background color as an rgb triple (bg-color :accessor plot-image-bg-color :initarg :bg-color :initform '(1 1 1)) ;; the output type of the image e.g. pdf, svg, png, etc. (output-type :accessor plot-image-output-type :initarg :output-type :initform :png) ;; image filename (filename :accessor plot-image-filename :initarg :filename))) (defmethod initialize-instance :after ((im plot-image) &rest args) (unless (getf args :width) (setf (plot-image-width im) *default-im-width*)) (unless (getf args :height) (setf (plot-image-height im) *default-im-height*)) (setf (bbox im) (list 0 0 (plot-image-width im) (plot-image-height im))) ;; make sure our children know who their parents are (when (plot-image-plots im) (dolist (pl (plot-image-plots im)) (setf (plot-object-parent pl) im)))) (defmethod print-object ((im plot-image) stream) (format stream "#IMAGE<(~Dx~D)>" (plot-image-width im) (plot-image-height im))) (defmethod draw-plot-object ((im plot-image) context) (declare (ignore context)) (let* ((filename (plot-image-filename im)) (width (plot-image-width im)) (height (plot-image-height im)) (output-type (plot-image-output-type im)) (bg-color (plot-image-bg-color im)) (surface (case output-type (:png (create-image-surface :argb32 width height)) (t nil))) (context (case output-type (:png (create-context surface)) (:pdf (create-pdf-context filename width height)) (:svg (create-svg-context filename width height))))) (destructuring-bind (r g b) bg-color (unwind-protect (with-context (context) (set-source-rgb r g b) (paint) (dolist (pl (plot-image-plots im)) (draw-plot-object pl context))) (destroy context)) (case output-type (:png (surface-write-to-png surface filename))))))
3,273
Common Lisp
.lisp
80
30.025
81
0.569453
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
b65404457b07a995f0d587ea60c20f79a25f95d8fcfcb743ab569b25163fc76f
19,979
[ -1 ]
19,980
plot-functions.lisp
grapesmoker_cl-plot/src/plot-functions.lisp
(in-package :plot) (defun plot (x y filename &key (style :point) (color *default-point-color*) (thickness *default-point-weight*) (output-type :png) (im-height *default-im-height*) (im-width *default-im-width*)) "The main interface to the plotter." ;; we'll want to handle multiple cases: ;; x, y are both integers -> plot dot at location (x, y) ;; x, y are both equal-length sequences -> plot y as function of x ;; x is a sequence but y is a list of sequences of equal length -> ;; plot all sequences in y as functions of x ;; x, y are both lists of sequences -> plot each y as function of ;; each x ;; x is a point or a sequence and y is a function -> plot mapcar y x ;; as function of x ;; x and y are both functions -> at each step, evaluate x, then ;; evaluate y(x), collect, and plot the results ;; function returns the axes object plotted ;; a bunch of assertions should go here about the data ;; this stuff is independent of the form of the data (let* ((axes (make-instance 'axes)) (plot (make-instance 'plot :plot-type :scatter :axes (list axes))) (image (make-instance 'plot-image :filename filename :output-type output-type :height im-height :width im-width :plots (list plot))) (data (make-instance 'data-object :color color :thickness thickness :style style))) (setf (plot-object-parent plot) image) (setf (plot-object-parent axes) plot) (cond ((and (numberp x) (numberp y)) (setf (data-obj-x-data data) (list x)) (setf (data-obj-y-data data) (list y)) (push data (axes-data axes)) (setf (plot-object-parent data) axes)) ((and (listp x) (listp y) (every #'numberp x) (every #'numberp y)) (unless (= (length x) (length y)) (error 'error)) (setf (data-obj-x-data data) x) (setf (data-obj-y-data data) y) (push data (axes-data axes))) ((and (listp x) (listp y) (every #'listp x) (every #'listp y)) (print "multiple lists") (setf (axes-data axes) nil) (unless (= (length x) (length y)) (error 'error)) (loop for x-sub in x for y-sub in y do (unless (and (= (length x-sub) (length y-sub)) (every #'numberp x-sub) (every #'numberp y-sub)) (error 'error)) (let ((new-data (make-instance 'data-object :color color :thickness thickness :style style :parent axes :x-data x-sub :y-data y-sub))) (push new-data (axes-data axes))))) (t ())) (when (axes-data axes) (format t "plotting ~%") (set-data-to-axes-tforms axes) (draw-plot-object image nil) axes)))
3,488
Common Lisp
.lisp
77
29.61039
110
0.477673
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
52f6070f2bfb4327d9dbed03c7cacb47b047f62932efb36ffdaa2d1c48d1a689
19,980
[ -1 ]
19,981
basic-tests.lisp
grapesmoker_cl-plot/tests/basic-tests.lisp
(in-package :plot) (defun basic-test (filename) (let* ((surface (create-image-surface :argb32 640 480)) (context (create-context surface)) (axis (make-instance 'axis :thickness 5.0 :start-x 25 :start-y 25 :end-x 25 :end-y 275 :color '(0 0 0)))) (unwind-protect (with-context (context) (set-source-rgb 1 1 1) (paint) (draw-axis axis context)) (destroy context)) (surface-write-to-png surface filename))) (defun draw-points-test (filename num-points) (let* ((surface (create-image-surface :argb32 640 480)) (context (create-context surface))) (unwind-protect (with-context (context) (set-source-rgb 1 1 1) (paint) (dotimes (n num-points) (let* ((pt-x (random 640)) (pt-y (random 480)) (color `(,(random 1.0) ,(random 1.0) ,(random 1.0))) (weight (random 10.0)) (new-point (make-instance 'point :x pt-x :y pt-y :color color :weight weight))) (draw-plot-object new-point context)))) (destroy context)) (surface-write-to-png surface filename))) (defun draw-axes-test (filename) (let* ((surface (create-image-surface :argb32 640 480)) (context (create-context surface))) (unwind-protect (with-context (context) (set-source-rgb 1 1 1) (paint) (let ((axes (make-instance 'axes :x-axis (make-instance 'axis :color '(0 0 0) :thickness 5 :start-x 20 :start-y 460 :end-x 620 :end-y 460) :y-axis (make-instance 'axis :color '(0 0 0) :thickness 5 :start-x 20 :start-y 460 :end-x 20 :end-y 20)))) (draw-plot-object axes context))) (destroy context)) (surface-write-to-png surface filename))) (defun draw-axes-test-2 (filename) (let* ((surface (create-image-surface :argb32 640 480)) (context (create-context surface))) (unwind-protect (with-context (context) (set-source-rgb 1 1 1) (paint) (let* ((new-image (make-instance 'plot-image)) (new-plot (make-instance 'plot :parent new-image)) (axes (make-instance 'axes :parent new-plot))) (draw-plot-object axes context))) (destroy context)) (surface-write-to-png surface filename))) (defun draw-axes-with-data-test (filename x-data y-data) (let* ((surface (create-image-surface :argb32 640 480)) (context (create-context surface))) (unwind-protect (with-context (context) (set-source-rgb 1 1 1) (paint) (let* ((new-image (make-instance 'plot-image)) (new-plot (make-instance 'plot :parent new-image)) (axes (make-instance 'axes :parent new-plot :data (list (make-instance 'data-object :x-data x-data :y-data y-data :color '(1 0 0)))))) (draw-plot-object axes context))) (destroy context)) (surface-write-to-png surface filename))) (defun scale-test (filename num-points) (let* ((surface (create-image-surface :argb32 640 480)) (context (create-context surface))) (unwind-protect (with-context (context) (set-source-rgb 1 1 1) (paint) (scale 640 480) (rotate (deg-to-rad 90)) (dotimes (n num-points) (let* ((pt-x (random 1.0)) (pt-y (random 1.0)) (color `(,(random 1.0) ,(random 1.0) ,(random 1.0))) (weight (random 100.0))) (multiple-value-bind (x y) (user-to-device pt-x pt-y) (format t "x: ~F, y: ~F~%" x y) (let ((new-point (make-instance 'point :x x :y y :color color :weight weight))) (draw-plot-object new-point context)))))) (destroy context)) (surface-write-to-png surface filename))) (defun draw-points-pdf-test (filename num-points) (let* ((context (create-pdf-context filename 640 480))) (unwind-protect (with-context (context) (set-source-rgb 1 1 1) (paint) (dotimes (n num-points) (let* ((pt-x (random 640)) (pt-y (random 480)) (color `(,(random 1.0) ,(random 1.0) ,(random 1.0))) (weight (random 10.0)) (new-point (make-instance 'point :x pt-x :y pt-y :color color :weight weight))) (draw-plot-object new-point context)))) (destroy context)))) ;; (surface-write-to-png surface filename)))
5,469
Common Lisp
.lisp
120
29.316667
152
0.478277
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
d32ad9a2a7dc5b71c59faa2b16f3ae65a8a24eb072b7b10c087a38aff3c997db
19,981
[ -1 ]
19,982
cl-plot.asd
grapesmoker_cl-plot/cl-plot.asd
(eval-when (:compile-toplevel :load-toplevel :execute) (ql:quickload :cl-cairo2)) (defpackage :cl-plot (:nicknames :plot) (:use :cl :cairo) (:documentation "Plotting routines based on cl-cairo2")) (defsystem "cl-plot" :name "cl-plot" :description "A plotting library in Lisp written using cl-cairo2." :version "0.1" :author "Jerry Vinokurov <[email protected]>" :license "GPL v3" :defsystem-depends-on (#:cl-cairo2) :depends-on (#:cl-cairo2) :components ((:module src :components ((:file "options") (:file "plot-objects") (:file "point") (:file "line") (:file "ticks") (:file "axes") (:file "plots") (:file "data-object") (:file "plot-image") (:file "plot-functions")) :serial t) (:module tests :components ((:file "basic-tests"))) ))
900
Common Lisp
.asd
32
21.875
68
0.581692
grapesmoker/cl-plot
2
2
0
GPL-2.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
d89b72bf672462be9c89e63e5e97f600b241ea2b27bda8ddd62fe02ea5314bb5
19,982
[ -1 ]
20,011
GeneR.lisp
TheLostLambda_Lisp-Land/GeneR.lisp
(defun G0 (celli var) (let ((Gval (parse-gene (nth 0 (fetch-value :DNA celli *cells*)))) (Chlorop nil)) (cond ((btwn Gval 0 9) (setf Chlorop 1)) ((btwn Gval 10 19) (setf Chlorop 2)) ((btwn Gval 20 29) (setf Chlorop 3)) (t (setf Chlorop 1))) ;;This is the "default value". AKA if the gene is not expressed. (cond ((equal var 'chlorop) Chlorop)))) (defun G1 (celli var) (let ((Gval (parse-gene (nth 1 (fetch-value :DNA celli *cells*)))) (Perm nil)) (cond ((btwn Gval 0 9) (setf Perm 2)) ((btwn Gval 10 19) (setf Perm 3)) ((btwn Gval 20 29) (setf Perm 4)) (t (setf Perm 1))) ;;This is the "default value". AKA if the gene is not expressed. (cond ((equal var 'perm) Perm)))) (defun G2 (celli var) (let ((Gval (parse-gene (nth 2 (fetch-value :DNA celli *cells*)))) (Perm nil) (Rigd nil)) (cond ((btwn Gval 0 7) (setf Perm 3) (setf Rigd 3)) ((btwn Gval 8 14) (setf Perm 2) (setf Rigd 1)) ((btwn Gval 15 21) (setf Perm 1) (setf Rigd 1)) ((btwn Gval 22 28) (setf Perm 0) (setf Rigd 0)) (t (setf Perm 0) ;;This is the "default value". AKA if the gene is not expressed. (setf Rigd 0))) (cond ((equal var 'perm) Perm) ((equal var 'rigd) Rigd)))) (defun GeneR (celli var) (cond ((equal var 'chlorop) (let ((Chlorop 0)) (incf Chlorop (G0 celli var)) Chlorop)) ((equal var 'perm) (let ((Perm 0)) (incf Perm (G1 celli var)) (incf Perm (G2 celli var)) Perm)) ((equal var 'rigd) (let ((Rigd 0)) (incf Rigd (G2 celli var)) Rigd))))
1,951
Common Lisp
.lisp
60
22.566667
94
0.483751
TheLostLambda/Lisp-Land
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
28f384b39a8c11872e3bef7166181c1524562257d7333b56e1eaa4fba1843f70
20,011
[ -1 ]
20,012
LL.lisp
TheLostLambda_Lisp-Land/LL.lisp
;;Stage 1: Implement Characteristics of Life (2 weeks) : DONE ;;Stage 1.5: Add complementary functions (2 weeks) : DONE ;;Stage 2: Add in realism and research (6+ weeks) : IN PROGRESS ;;Stage 3: Beautify and refine code (TBD) : TODO ;;;; Current Task: Do TODO's (ql:quickload 'lispbuilder-sdl) (ql:quickload 'lispbuilder-sdl-gfx) (defparameter *width* 100) (defparameter *height* 100) (defparameter *area* (* *width* *height*)) (defparameter *pixsize* 5) ;;Note + TODO: One "pixel" in the sim is equal to 20um, this is an estimate, revise in stage two. (defparameter *umperpix* 20) ;;TODO: Use this in stage two to create a correctly scaled measure of size. (defparameter *cellHP* 150) (defparameter *cells* nil) (defparameter *world* nil) (defparameter *generation* 0) (defparameter *datafile* "Celldata.db") (defun btwn (x min max) (and (>= x min) (<= x max))) (defun random-range (min max) (+ min (random (- max min) (make-random-state t)))) (defun fout (in) (format *standard-output* "~a" in) (force-output *standard-output*)) (defun remove-nth (n lst) ;;TODO: Make iterative in stage three. (if (or (zerop n) (null lst)) (cdr lst) (cons (car lst) (remove-nth (1- n) (cdr lst))))) (defmacro dotimes-dec (var-and-limit &rest body) (let ((var (first var-and-limit)) (limit (second var-and-limit))) `(do ((,var (1- ,limit) (1- ,var))) ((<= ,var -1)) ,@body))) (defmacro fetch-value (accessor index lst) `(getf (nth ,index ,lst) ,accessor)) (defun seek-propval (accessor value lst) (let ((prop-cells '())) (mapcar #'(lambda (x) (if (equal (getf x accessor) value) (setf prop-cells (append prop-cells x)) (continue))) lst) prop-cells)) (defun surround-space (cen) (let ((x (car cen)) (y (cdr cen)) (openspcs '())) (if (seek-propval :POS (cons x (1+ y)) *cells*) (continue) (setf openspcs (append openspcs `(,(cons x (1+ y)))))) (if (seek-propval :POS (cons (1+ x) (1+ y)) *cells*) (continue) (setf openspcs (append openspcs `(,(cons (1+ x) (1+ y)))))) (if (seek-propval :POS (cons (1+ x) y) *cells*) (continue) (setf openspcs (append openspcs `(,(cons (1+ x) y))))) (if (seek-propval :POS (cons (1+ x) (1- y)) *cells*) (continue) (setf openspcs (append openspcs `(,(cons (1+ x) (1- y)))))) (if (seek-propval :POS (cons x (1- y)) *cells*) (continue) (setf openspcs (append openspcs `(,(cons x (1- y)))))) (if (seek-propval :POS (cons (1- x) (1- y)) *cells*) (continue) (setf openspcs (append openspcs `(,(cons (1- x) (1- y)))))) (if (seek-propval :POS (cons (1- x) y) *cells*) (continue) (setf openspcs (append openspcs `(,(cons (1- x) y))))) (if (seek-propval :POS (cons (1- x) (1+ y)) *cells*) (continue) (setf openspcs (append openspcs `(,(cons (1- x) (1+ y)))))) openspcs)) (defun fetch-props (lst) (let ((nlst nil)) (do ((i 0 (+ i 2))) ((>= i (length lst))) ;;TODO: Modify to deal with non-sequences in stage 3. (push (nth i lst) nlst)) (reverse nlst))) (defun new-cell (POS ATP NA AA FA G O2 CO2 DNA) (push (list :POS POS :ATP ATP :NA NA :AA AA :FA FA :G G :O2 O2 :CO2 CO2 :DNA DNA :HP *cellHP*) *cells*)) (defun new-world (TEMP PH NAC AAC FAC GC O2C CO2C RAD BPV LUX) (setf *world* (list :TEMP TEMP :PH PH :NAC NAC :AAC AAC :FAC FAC :GC GC :O2C O2C :CO2C CO2C :RAD RAD :BPV BPV :LUX LUX))) (defun parse-gene (gene) (let ((gene-val 0)) (dotimes (i (length gene)) (setf gene-val (+ (* (expt 2 i) (nth i (reverse gene))) gene-val))) gene-val)) (defun parse-DNA (DNA-seq) (let ((DNA-val nil)) (dotimes (i (length DNA-seq)) (push (parse-gene (nth i DNA-seq)) DNA-val)) (reverse DNA-val))) (defun dump-ci () (dolist (entry *cells*) (format t "~%~{~a:~10t~a~%~}~%" entry))) (defun save-sim (filename) (with-open-file (out filename :direction :output :if-exists :supersede) (with-standard-io-syntax (print *cells* out) (print *world* out)))) (defun load-sim (filename) (with-open-file (in filename) (with-standard-io-syntax (setf *cells* (read in)) (setf *world* (read in))))) (defun rand-mutate (DNA-seq) (let ((CDNA-seq (copy-tree DNA-seq))) (let ((gene (random-range 0 (length CDNA-seq)))) (let ((base (random-range 0 (length (nth gene CDNA-seq))))) (cond ((= (nth base (nth gene CDNA-seq)) 0) (setf (nth base (nth gene CDNA-seq)) 1)) (t (setf (nth base (nth gene CDNA-seq)) 0))) CDNA-seq)))) (defun mutate-times (DNA-seq times) (dotimes (i times) (rand-mutate DNA-seq))) (defun close-sim () (format t "Saving simulation state and exiting...~%") (save-sim *datafile*) (exit)) (defun init-sim () (format t "Loading simulation state and starting...~%") (load "GeneR.lisp") (when (probe-file *datafile*) (load-sim *datafile*)) (format t "Done.")) (defun Cell-Apo (celli) ;;Note: Function for cellular death and anything HP related. (if (<= (fetch-value :HP celli *cells*) 0) (progn ;;TODO: Once 'Cell-Env' can expel molecules, replace this code with a 'Cell-Env' call. (incf (getf *world* :NAC) (fetch-value :NA celli *cells*)) (incf (getf *world* :AAC) (fetch-value :AA celli *cells*)) (incf (getf *world* :FAC) (fetch-value :FA celli *cells*)) (incf (getf *world* :GC) (fetch-value :G celli *cells*)) (incf (getf *world* :O2C) (fetch-value :O2 celli *cells*)) (incf (getf *world* :CO2C) (fetch-value :CO2 celli *cells*)) (setf *cells* (remove-nth celli *cells*))) ;;TODO: Put other HP effecting conditions here... (decf (fetch-value :HP celli *cells*) 1) ;;Note: Cell aging condition. )) (defun Cell-Vir (celli) ;;Note + TODO: Viruses are pretty crazy, there is a lot to do here, revise in stage two... (let ((BPVP nil) (Chance nil) (CPS nil) (NBPVP nil)) (setf BPVP (* (/ (getf *world* :BPV) *area*) 100)) (setf Chance (random-range 1 101)) (setf CPS (truncate (/ BPVP 100))) (setf NBPVP (- BPVP (* CPS 100))) (when (<= NBPVP Chance) (incf CPS 1)) (dotimes (i CPS) (when (= (random-range 1 (+ (GeneR celli 'perm) 1)) 1) (decf (fetch-value :HP celli *cells*) 10) (incf (getf *world* :BPV) 1))))) (defun Cell-Env (celli) ;;Note + TODO: This is scientifically flawed, revise in stage two... (let ((prop nil) (cprop nil) (propcont nil) (cpropcont nil)) (do ((i 0 (1+ i))) ((>= i 6)) ;;Note + TODO: 6 is for the four main macromolecules plus CO2 and O2, make more portable later... (setf prop (nth i '(:NAC :AAC :FAC :GC :O2C :CO2C))) ;;TODO: Make more portable later... (setf cprop (nth i '(:NA :AA :FA :G :O2 :CO2))) ;;TODO: Make more portable later... (setf propcont (getf *world* prop)) (setf cpropcont (fetch-value cprop celli *cells*)) ;;NOTE + TODO: This is a hiding place for bugs, review this. (cond ((> cpropcont (/ propcont *area*)) (let ((CPSD (truncate (- cpropcont (/ propcont *area*))))) (dotimes (i CPSD) (when (= (random-range 1 (+ (GeneR celli 'perm) 1)) 1) (decf (fetch-value cprop celli *cells*) 1) (incf (getf *world* prop)))))) ((< cpropcont (/ propcont *area*)) (let ((PropVal nil) (Chance nil) (CPS nil) (NPropVal nil)) (setf PropVal (* (/ (getf *world* prop) *area*) 100)) (setf Chance (random-range 1 101)) (setf CPS (truncate (/ PropVal 100))) (setf NPropVal (- PropVal (* CPS 100))) (when (<= NPropVal Chance) (incf CPS 1)) (dotimes (i CPS) (when (= (random-range 1 (+ (GeneR celli 'perm) 1)) 1) (decf (getf *world* prop) 1) (incf (fetch-value cprop celli *cells*) 1))))) (t (continue)))))) (defun Cell-Pho (celli) ;;TODO: Incorperate Lux into the photosynthesis process. (when (> (GeneR celli 'chlorop) 1) (cond ((> 1 0) (dotimes (i 4) ;;Dummy Value: 4 is a place-holder for the chloroplast count. (when (and (> (fetch-value :CO2 celli *cells*) 6) (> (fetch-value :O2 celli *cells*) 6)) (decf (fetch-value :CO2 celli *cells*) 6) (incf (fetch-value :O2 celli *cells*) 6) (incf (fetch-value :G celli *cells*) 1)))) ;;Note: Photosynthesis 6 CO2 + 6 H2O → C6H12O6 + 6 O2. For now, Water is ignored (t (format t "If you see this message, the laws of science have broken down.~%Now is the time for panic"))))) (defun Cell-Met (celli) ;;TODO: Add a better way to regulate the ATP synthesis (when (< (fetch-value :ATP celli *cells*) 1500) ;;Dummy Value: 1500 is the place-holder for max APT value. (cond ((> 1 0) ;;Note + TODO: This is the condition for mitochondrial respiration, revise during stage two... (dotimes (i 2) ;;Dummy Value: 2 is a place-holder for the mitochondron count. (cond ((and (>= (fetch-value :O2 celli *cells*) 6) (>= (fetch-value :G celli *cells*) 1)) ;;Note: Aerobic Respiration C6H12O6 + 6 O2 → 6 CO2 + 6 H2O + 38 ATP. For now, Water is ignored (decf (fetch-value :G celli *cells*) 1) (decf (fetch-value :O2 celli *cells*) 6) (incf (fetch-value :CO2 celli *cells*) 6) (incf (fetch-value :ATP celli *cells*) 38)) ((and (< (fetch-value :O2 celli *cells*) 6) (>= (fetch-value :G celli *cells*) 1)) ;;Note: Anaerobic Respiration C6H12O6 → 2 CO2 + 2 C2H5OH + 2 ATP. For now Ethanol is ignored (decf (fetch-value :G celli *cells*) 1) (incf (fetch-value :CO2 celli *cells*) 2) (incf (fetch-value :ATP celli *cells*) 2))))) ;;TODO: This is the condition for ATP synthesis via a proton gradient. (t (format t "If you see this message, the laws of science have broken down.~%Now is the time for panic"))))) ;;TODO: Prevent cells from overlapping (defun Cell-Loc (celli &optional (dir (random 33 (make-random-state t)))) ;;Note + Dummy Value: This is the function for cellular locomotion. (let ((x (car (fetch-value :POS celli *cells*))) (y (cdr (fetch-value :POS celli *cells*)))) ;;TODO: Find a more realistic and controlled method of locomotion. (when (and (>= (fetch-value :ATP celli *cells*) 25) (<= dir 8)) ;;Dummy Value: 25 is ATP cost for movement. (decf (fetch-value :ATP celli *cells*) 25) ;;Dummy Value: 25 is ATP cost for movement. (cond ((= dir 1) (setf (fetch-value :POS celli *cells*) (cons x (mod (1+ y) *height*)))) ((= dir 2) (setf (fetch-value :POS celli *cells*) (cons (mod (1+ x) *width*) y)) (setf (fetch-value :POS celli *cells*) (cons x (mod (1+ y) *height*)))) ((= dir 3) (setf (fetch-value :POS celli *cells*) (cons (mod (1+ x) *width*) y))) ((= dir 4) (setf (fetch-value :POS celli *cells*) (cons (mod (1+ x) *width*) y)) (setf (fetch-value :POS celli *cells*) (cons x (mod (1- y) *height*)))) ((= dir 5) (setf (fetch-value :POS celli *cells*) (cons x (mod (1- y) *height*)))) ((= dir 6) (setf (fetch-value :POS celli *cells*) (cons (mod (1- x) *width*) y)) (setf (fetch-value :POS celli *cells*) (cons x (mod (1- y) *height*)))) ((= dir 7) (setf (fetch-value :POS celli *cells*) (cons (mod (1- x) *width*) y))) ((= dir 8) (setf (fetch-value :POS celli *cells*) (cons (mod (1- x) *width*) y)) (setf (fetch-value :POS celli *cells*) (cons x (mod (1+ y) *height*)))))))) (defun Cell-Mut (celli) (when (<= (random-range 1 101) (getf *world* :RAD)) (setf (fetch-value :DNA celli *cells*) (rand-mutate (fetch-value :DNA celli *cells*))))) ;;NOTE + TODO: Truncate here is breaking the conservation law. Some molicules are just destroyed. Fix this. (defun Cell-Rep (celli) (when (>= (fetch-value :ATP celli *cells*) 1500) (let ((POS (fetch-value :POS celli *cells*)) (ATP (truncate (/ (- (fetch-value :ATP celli *cells*) 1000) 2))) (NA (truncate (/ (fetch-value :NA celli *cells*) 2))) (AA (truncate (/ (fetch-value :AA celli *cells*) 2))) (FA (truncate (/ (fetch-value :FA celli *cells*) 2))) (G (truncate (/ (fetch-value :G celli *cells*) 2))) (O2 (truncate (/ (fetch-value :O2 celli *cells*) 2))) (CO2 (truncate (/ (fetch-value :CO2 celli *cells*) 2))) (DNA (fetch-value :DNA celli *cells*))) (setf (fetch-value :ATP celli *cells*) ATP) (setf (fetch-value :NA celli *cells*) NA) (setf (fetch-value :AA celli *cells*) AA) (setf (fetch-value :FA celli *cells*) FA) (setf (fetch-value :G celli *cells*) G) (setf (fetch-value :O2 celli *cells*) O2) (setf (fetch-value :CO2 celli *cells*) CO2) (new-cell POS ATP NA AA FA G O2 CO2 DNA) (Cell-Loc 0 (random 9 (make-random-state t)))))) (defun Cell-Sft (celli) (let ((cellpos (fetch-value :POS celli *cells*))) (when (<= (length (seek-propval :POS cellpos *cells*)) 1) (let ((sur-spc (surround-space cellpos))) (if (equal sur-spc nil) (progn (Cell-Loc celli (random 9 (make-random-state t))) (Cell-Sft celli)) (setf (fetch-value :POS celli *cells*) (nth (random-range 0 (length sur-spc)) sur-spc))))))) (defun next-tick () (incf *generation* 1) (dotimes-dec (i (length *cells*)) (Cell-Env i)) (dotimes-dec (i (length *cells*)) (Cell-Pho i)) (dotimes-dec (i (length *cells*)) (Cell-Met i)) (dotimes-dec (i (length *cells*)) (Cell-Loc i)) (dotimes-dec (i (length *cells*)) (Cell-Mut i)) (dotimes-dec (i (length *cells*)) (Cell-Vir i)) (dotimes-dec (i (length *cells*)) (Cell-Rep i)) (dotimes-dec (i (length *cells*)) (Cell-Apo i)) (dotimes-dec (i (length *cells*)) (Cell-Sft i)) (fout *generation*) (fresh-line)) (defun autoplay-sim (&optional (delay 0)) (sdl:with-init () (sdl:window (* *pixsize* *width*) (* *pixsize* *height*) :title-caption "Lisp Land") (setf (sdl:frame-rate) 60) (sdl:with-events () (:quit-event () t) (:idle () (sleep delay) (next-tick) (sdl:clear-display sdl:*black*) (dotimes (celli (length *cells*)) (let ((POS (fetch-value :POS celli *cells*))) (sdl-gfx:draw-box (sdl:rectangle :x (* (car POS) *pixsize*) :y (* (cdr POS) *pixsize*) :w *pixsize* :h *pixsize*) :color (if (> (GeneR celli 'chlorop) 1) sdl:*green* sdl:*white*)))) (sdl:update-display))))) (init-sim)
14,698
Common Lisp
.lisp
280
45.728571
191
0.598126
TheLostLambda/Lisp-Land
2
0
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
67f5a1da74336f3381aa5e093e245adaaeec4f786b7c623a8a637a75c15b458f
20,012
[ -1 ]
20,031
nburst.lsp
asrin475_Lisp-Tamimi/nburst.lsp
(defun c:nb ( / *error* idx sel ) (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) (LM:startundo (LM:acdoc)) (if (setq sel (LM:ssget "\nSelect blocks to burst: " (list "_:L" (cons '(0 . "INSERT") ( (lambda ( / def lst ) (while (setq def (tblnext "block" (null def))) (if (= 4 (logand 4 (cdr (assoc 70 def)))) (setq lst (vl-list* "," (cdr (assoc 2 def)) lst)) ) ) (if lst (list '(-4 . "<NOT") (cons 2 (apply 'strcat (cdr lst))) '(-4 . "NOT>"))) ) ) ) ) ) ) (repeat (setq idx (sslength sel)) (setq ob (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))) ; (if (and (> (length (vlax-invoke ob 'getattributes)) 0) (vlax-write-enabled-p ob)) ; (vla-delete ob) ; ) (progress) (LM:burstnested ob) ) ) (LM:endundo (LM:acdoc)) (princ) ) ;; Burst Nested - Lee Mac ;; Bursts the supplied block & all nested blocks found within. ;; obj - [vla] VLA Block Reference Object (defun LM:burstnested ( obj / col idx lay lin lst obj ) ; (if (and (/= obj nil) (/= (vlax-invoke obj 'GetAttributes) nil) (vlax-write-enabled-p obj)) ; (vla-delete obj) ; (progn (if (and (= "AcDbBlockReference" (vla-get-objectname obj)) (vlax-write-enabled-p obj) (not (vl-catch-all-error-p (setq lst (vl-catch-all-apply 'vlax-invoke (list obj 'explode))))) ) (progn (setq lay (vla-get-layer obj) col (vla-get-color obj) lin (vla-get-linetype obj) ) (foreach att (vlax-invoke obj 'getattributes) (if (vlax-write-enabled-p att) (progn (if (= "0" (vla-get-layer att)) (vla-put-layer att lay) ) (if (= acbyblock (vla-get-color att)) (vla-put-color att col) ) (if (= "byblock" (strcase (vla-get-linetype att) t)) (vla-put-linetype att lin) ) ) ) (if (= :vlax-false (vla-get-invisible att)) ( (if (and (vlax-property-available-p att 'mtextattribute) (= :vlax-true (vla-get-mtextattribute att))) LM:burst:matt2mtext LM:burst:att2text ) (entget (vlax-vla-object->ename att)) ) ) ) ; foreach (foreach new lst (if (vlax-write-enabled-p new) (if (= "AcDbAttributeDefinition" (vla-get-objectname new)) (vla-delete new) (progn (if (= "0" (vla-get-layer new)) (vla-put-layer new lay) ) (if (= acbyblock (vla-get-color new)) (vla-put-color new col) ) (if (= "byblock" (strcase (vla-get-linetype new) t)) (vla-put-linetype new lin) ) (LM:burstnested new) ) ) ) ) (vla-delete obj) ) ) ; ) ;) (princ) ) (defun LM:burst:removepairs ( itm lst ) (vl-remove-if '(lambda ( x ) (member (car x) itm)) lst) ) (defun LM:burst:remove1stpairs ( itm lst ) (vl-remove-if '(lambda ( x ) (if (member (car x) itm) (progn (setq itm (vl-remove (car x) itm)) t))) lst) ) (defun LM:burst:att2text ( enx ) (entmakex (append '((0 . "TEXT")) (LM:burst:removepairs '(000 002 070 074 100 280) (subst (cons 73 (cdr (assoc 74 enx))) (assoc 74 enx) enx) ) ) ) ) (defun LM:burst:matt2mtext ( enx ) (entmakex (append '((0 . "MTEXT") (100 . "AcDbEntity") (100 . "AcDbMText")) (LM:burst:remove1stpairs '(001 007 010 011 040 041 050 071 072 073 210) (LM:burst:removepairs '(000 002 042 043 051 070 074 100 101 102 280 330 360) enx) ) ) ) ) ;; ssget - Lee Mac ;; A wrapper for the ssget function to permit the use of a custom selection prompt ;; msg - [str] selection prompt ;; arg - [lst] list of ssget arguments (defun LM:ssget ( msg arg / sel ) (princ msg) (setvar 'nomutt 1) (setq sel (vl-catch-all-apply 'ssget arg)) (setvar 'nomutt 0) (if (not (vl-catch-all-error-p sel)) sel) ) ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) (setq ind 0) (defun progress(/ chars) (setq chars '("-" "\\" "|" "\/")) ;(repeat 40 (princ (strcat "\rPlease wait... " (nth ind chars))) (setq ind (rem (1+ ind) (length chars))) ;) (princ) ) (vl-load-com) (princ)
6,099
Common Lisp
.l
169
23.254438
126
0.446859
asrin475/Lisp-Tamimi
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
f3cff8af3e5402543c076ac92a6f8cdd54e19b27cf11c8c681fcb12d49b5908e
20,031
[ -1 ]
20,032
rt.lsp
asrin475_Lisp-Tamimi/rt.lsp
;by Mohamedh Asrin 2018 (vl-load-com) (defun c:yt() (defun replaceText(text / toFind toReplace vlText) (setq toFind "X =") (setq vlText (vlax-ename->vla-object text) vlTextString (vla-get-TextString vlText)) (setq index (vl-string-search toFind vlTextString)) ;(print (itoa index)) (if (/= nil index) (vla-put-TextString vlText (substr vlTextString (1+ index))) (vla-delete vlText)) (princ) ) (defun selectText(/ texts) (setq texts (ssget '((0 . "*TEXT")))) (if (OR (= nil texts) (< (sslength texts) 1)) (progn (princ "Invalid Selection") (selectText) ) (progn ;text blocks (princ (itoa (sslength texts))) ; (repeat (setq i (sslength texts)) ; (replaceText (ssname text (setq i (1- i))))) (setq i 0) (while (< i (sslength texts)) (replaceText (ssname texts i)) (setq i (1+ i)) ) ) ) ) (selectText) (princ) ) ; ******************************************************************* ; Change MTEXT STEXT Text Continuously ; COMMAND : T4 ; ******************************************************************* (defun c:T4(/ usertext sel) ;(setq usertext (strcase (getstring "\nText to Replace: ") nil)) (princ "*** Source Text ***") (setq obj (vlax-ename->vla-object (ssname (ssget "_+.:E:S" '((0 . "*TEXT"))) 0))) (setq usertext (vlax-get obj 'TextString)) (princ "*** Select Text to Replace ***") (while (setq sel (ssget "_+.:E:S" '((0 . "*TEXT")))) (progn (if (> (sslength sel) 0) (progn (setq name (ssname sel 0)) (setq p (vlax-ename->vla-object name)) (vlax-put p 'TextString usertext) ) ) ) ) )
1,668
Common Lisp
.l
60
23.933333
83
0.556325
asrin475/Lisp-Tamimi
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
bbffb1adb2478f7aa01c267d7741cd0b2d2be39189c61969821674701119af04
20,032
[ -1 ]
20,033
MyLsp2.lsp
asrin475_Lisp-Tamimi/MyLsp2.lsp
; *************************************************** ; MyLisp.lsp is a collection of tools that make autocad ease and it is created and maintained by Mohamedh Asrin ; &copy All Right Reserved 2017 01 18 12:16 AM ; ; ; (setq MYVER "v1.3 alpha 15 - bumble bee") #| ; *************************************************** ; CHANGES ; *************************************************** ; Initial Release 1.0 ; ; 2017-01-24 ; improved ml trim function - MJ ; MLine Weld - WA ; ; 1.1.0 ; ; Selection of blocks is always top to bottom ; No matter how the selection is made ; ; 1.1.2 ; ; fix - Object snap variable is not reverted to backup in command r2 ; ; 1.2.1 ; ; ** pc command has been redesiged ; * fix - r2 command cmdecho and osmode not restoring ; ; 1.2.5 ; ; ** p2j - now prints to jpeg ; * the same set of models can now print to other printers as well (limit_thrushold more than 5 blocks) ; * ; ; 1.3 ; ; ** I don't know what else has been edited ; ; ******** stil i can't remember, edited today also ; ; *************************************************** |# ;LOADS VLA COMPONENTS (vl-load-com) (load ".\\progress.lsp") (setq acApp (vlax-get-acad-object)) (setq acDoc (vla-get-ActiveDocument acApp)) (setq acSpace (vla-get-ModelSpace acDoc) ;GLOBAL PRINTERS pXerox "Xerox.pc3" hp7510 "Officejet 7510 series.pc3" p8600 "Officejet8600.pc3" hp400 "HP400.pc3" hp7610 "HP7610.pc3" Robot "Robot.pc3") ; PRINTERS AND THE DEFAULT PAPER SIZES (setq $G_PRINTERS '( (XEROX ("Xerox.pc3" "A3 (297 x 420mm)")) (HP400 ("HP400.pc3" "A4")) (HP7510 ("Officejet 7510 series.pc3" "A3 297x420mm - plain paper")) (ROBOT ("Robot.pc3" "A3")) (P8600 ("Officejet8600.pc3" "")) (PDF ("DWG To PDF.pc3" "ISO full bleed A3 (297.00 x 420.00 MM)")) (JPEG ("PublishToWeb JPG.pc3" "TO_JPEG_3200X2560")) ; the paper size for jpeg is a userdefined size ) $G_STYLES '( (COLOR "for print.ctb") (BLACK "for black.ctb") (JPEG "TO-JPEG.ctb") (CROKY "croky.ctb") ) $G_PRINTING_METHOD '( (FACE_UP "fup") (FACE_DOWN "fdown") ) ) (setq $TAMIMI "TAMIMI" $CORDS 'COORDINATES $HISTORY 'HISTORY) ;PRINTER SUPPORT FUNCTIONS (defun $get_printer(printer_name /) (car (cadr (assoc printer_name $G_PRINTERS)))) (defun $get_paper_for_printer(printer_name /) (cadr (cadr (assoc printer_name $G_PRINTERS)))) (defun $get_printing_style(style_name /) (cadr (assoc style_name $G_STYLES))) (defun $get_priniting_method(method_id /) (cadr (assoc method_id $G_PRINTING_METHOD))) ;setting up printer for old function (setq pHp Robot) (setq blocksToSelect '((-4 . "<OR") (-4 . "<AND") (0 . "INSERT") (-4 . "<OR") ;ADD TITLE BLOCKS NAME WITH THE FOLOWING PATTERN TO BE SELECTED. (2 . "vvvvvvvv") (2 . "ba") (2 . "rerere") (2 . "HEAT_SCH") (2 . "bantha") (2 . "wefgetttttttt") (2 . "ERGWERGERG") (2 . "wergwergwergr") (2 . "TAMIMI-*") (2 . "erhgrethrt") (2 . "tr") (2 . "FI SHEET") (2 . "block") (2 . "sh-2222") (-4 . "OR>") (-4 . "AND>") (-4 . "<AND") (0 . "LWPOLYLINE") (8 . "WALL") (-4 . ">") (43 . 0.06) ; cover page contains this outer line (-4 . "AND>") (-4 . "OR>")) ;LIST<F2><F2><F2> ) ;SETQ ; ERROR HANDLER FOR THIS LSP (defun *error* (msg / cancel) (if (not (member msg '("Function cancelled" "quit / exit abort"))) (progn (print msg) (ODCL:closeProgress) ) (progn (ODCL:closeProgress) ;(vla-EndUndoMark acDoc) ) ) ) (defun c:ql(/ lp alp ch) (setq TAG:ATTR "STAIR_NO") (setq alp '("A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")) (defun p:letter(ch / ) (princ "Prepating Letters...\n") (princ) (if (not *letter_pos*) (setq *letter_pos* 0)) (if (member ch alp) (setq *letter_pos* (get-position ch alp))) (princ (strcat ">> Starts from : " (nth *letter_pos* alp))) (while (setq ent (car (entsel "\nSelect Attribute: "))) (if (not ent) (p:letter (nth *letter_pos* alp)) (progn ;CONVERT ENTITY TO VLA OBJECT (setq ve (vlax-ename->vla-object ent)) (mapcar '(lambda (at) (if (= (vla-get-tagstring at) TAG:ATTR) (progn (vla-put-TextString at (nth *letter_pos* alp)) (setq *letter_pos* (1+ *letter_pos*)) (if (= *letter_pos* 26) (setq *letter_pos* 0))) )) ; applying fucntion to (vlax-invoke ve 'GetAttributes)) )) ) ) (defun getLetterPos(/ input) (setq input (getstring "Type Letter / Number : ")) (if (AND (/= (atoi input) 0) (<= (atoi input) 26)) (progn (print "number") (setq *letter_pos* (1- (atoi input))) (p:number) ) (progn (print (strcase (substr input 1 1))) (p:letter (strcase (substr input 1 1))) ) ) ) (getLetterPos) ;(exit) ) (defun c:E2(/ lp num) (setq ATTRTAG:STRING "W1") (defun modeContinuous(/ obj) (setq num (atoi ATTRNUMBER)) (print) (while (setq block (car (entsel "\rSelect Object <= Incremental: "))) (if (OR (= nil block) (/= (vla-get-objectname (setq obj (vlax-ename->vla-object block))) "AcDbBlockReference")) ;OR (progn (princ "\nInvalid attibute\n") (modeContinuous) ) ;else (progn (mapcar '(lambda (attr) (if (= (vla-get-tagstring attr) ATTRTAG:STRING) (vla-put-TextString attr (strcat "W-" (itoa num))) ) ) (vlax-invoke obj 'GetAttributes) ) ;mapcar (setq num (1+ num)) (setq ATTRNUMBER (itoa num)) ) ;progn ) ;if ) ;while (exit) ) ;defun (defun modeMultiple() (setq winTags (ssget '((0 . "INSERT")(8 . "Win-no")))) (if (> (sslength winTags) 0) (progn (print "foreach") (foreach tag (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex winTags)))) (PasteWord tag) );foreach );progn );if (princ) (getWord) ) (defun PasteWord(obj /) (progn (mapcar '(lambda (attr) (if (= (vla-get-tagstring attr) ATTRTAG:STRING) (vla-put-TextString attr (strcat "W-" ATTRNUMBER)) ) ) (vlax-invoke obj 'GetAttributes) ) ;mapcar ) ;progn ) ;defun (defun modeSingle(/) (princ) ) (defun getWord(/ input) (if (= nil ATTRNUMBER) (setq ATTRNUMBER "1")) (setq input (getstring (strcat "\nSpecify Window number <W-" ATTRNUMBER ">: "))) (if (and (/= input "") (/= (atoi input) 0)) (setq ATTRNUMBER input)) (getInput) ) (defun getInput(/ ve) ;(print) (initget "C M") (setq input (entsel "\rSelect Window Attribute or [Continuous / Multiple]: ")) (cond ((= input "C") (modeContinuous)) ((= input "M") (modeMultiple)) ((if (and (/= input nil) (setq ve (vlax-ename->vla-object (car input))) (= (vla-get-objectname ve) "AcDbBlockReference")) (PasteWord ve)) ) ) (getInput) (princ) ) (getWord) ;(exit) ) (defun c:ww(/ window_objects output_file ec) (setq output_file (strcat "C:\\Users\\Asrin\\Desktop\\" (getvar 'dwgname)) ec (getvar 'cmdecho)) ;(setvar 'cmdecho 0) (if (setq window_objects (ssget)) (progn (if (not (findfile output_file)) (progn (command "-WBLOCK" output_file "" "0,0" window_objects "") (princ (strcat "Block created : " output_file))) ) ) (progn (princ "No objects have been selected!") (exit)) ) (princ) ) ; ******************************************************************* ; COMMAND : DD ; Renaming Electrical Panel Board names when they are too lot to handle ; ******************************************************************* (defun c:dd( / p q lst obj ent i j k apply input ipre) (setq alp '( "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z") ipre "") (if (not *pre*) (setq *pre* "PANEL ") (progn (princ) (princ (strcat "Prefix : " *pre*)) )) ; checking value of k (if (OR (not *k*) (= -1 *k*) (> *k* 25)) (setq *k* 0)) (defun getPosition ( / input) (setq input (getstring (strcat "\nSEtting \/ Starts with <" (itoa (1+ *k*)) "><" (nth *k* alp) ">: "))) (if (= input "") (progn ; no input is detected ;(setq *k* *k*) ;(print "no input") ) (progn ;input is a number (if (= (strcase (substr input 1 2) nil) "SE") (getPrefix) (progn (if (AND (/= (atoi input) 0) (<= (atoi input) 26)) (progn (print "number") (setq *k* (1- (atoi input))) ) (progn (if (member (strcase input) alp) (setq *k* (get-position (strcase input) alp)) (setq *k* 0) ) ) ) ) ) ) ) ) (defun getPrefix () ;(initget "PANEL PANEL- P-") (setq txt (getstring T (strcat "\nPrefix [Type any text] <" *pre* ">: "))) (if (/= txt "") (setq *pre* txt)) (print *pre*) (princ) (getPosition) ) ;(initget 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25) ;getting input (getPosition) ; GET NUMBER OR CHAR AS A INPUT ;(print (strcat "-> " input)) ;(princ) (print (strcat "Begining from: " (itoa (1+ *k*)) " -> " (nth *k* alp))) (princ) ;(prompt "\nSelect objects with order:") (if (= 1 1) (progn ;(princ (sslength lst)) (setq i 0 ;j (sslength lst) ) (while (setq lst (ssget "_+.:E:S" (list '(0 . "TEXT,MTEXT")))) (setq obj (ssname lst 0)) (setq p (vlax-ename->vla-object obj)) ;(setq q (vlax-get p 'TextString)) ;( ( (nth i alp))) ;get rid of out of bound index (if (> *k* 25) (progn (setq index (/ *k* 25)) (setq ipre (nth (1- index) alp)) (setq *k* 0) ) ) (vlax-put p 'TextString (strcat *pre* "" ipre (nth *k* alp))) ;(vlax-put p 'TextString (strcat (itoa *k*))) ; REPLACE NUMBERS ONLY (setq i (1+ i) *k* (1+ *k*)) ; adding 1 to the k will start ) ; while (princ) ) ; progn (princ) ) ; if ;(prompt "\nSelect objects with order:") ; (if (setq lst (ssget (list '(0 . "TEXT,MTEXT")))) ; (progn ; (princ (sslength lst)) ; (setq i 0 ; j (sslength lst)) ; (while (< i j) ; (setq obj (ssname lst i)) ; (setq p (vlax-ename->vla-object obj)) ; ;(setq q (vlax-get p 'TextString)) ; ;( ( (nth i alp))) ; ;get rid of out of bound index ; (if (> *k* 25) ; (progn ; (setq index (/ *k* 25)) ; (setq ipre (nth (1- index) alp)) ; (setq *k* 0) ; ) ; ) ; (vlax-put p 'TextString (strcat pre " " ipre (nth *k* alp))) ; (setq i (1+ i) ; *k* (1+ *k*)) ; ; adding 1 to the k will start ; ) ; while ; (princ) ; ) ; progn ; (princ) ; ) ; if (princ) (exit) ) (defun c:ff( / alp a) (setq alp '( "A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K" "L" "M" "N" "O" "P" "Q" "R" "S" "T" "U" "V" "W" "X" "Y" "Z")) (print (get-position "R" alp)) (princ) ) (defun get-position(ch lst / l i ret) (setq l (length lst) i 0) ;(print l) (while (< i l) (if(= (nth i lst) ch) (progn (setq ret i) ;(print "got it") ) ) (setq i (1+ i)) ) (* ret 1) ;(princ) ) ; ******************************************************************* ; Removes All Dimensions / by the specified value ; ******************************************************************* (defun c:rd ( / dims ans num) ;"Documentation for c:rd." ;(SETQ dims (ssget '((0 . "DIMENSION")))) (SETQ ans (strcase (getstring "\nRemove Dimensions (All / Enter Value) <All>: "))) (if (= ans "") (setq ans "A")) (cond ( ; cond 1 (= ans "A") (progn (SETQ dims (ssget '((0 . "*DIMENSION")))) (if dims (command "_erase" dims "")) ) ) ( ; cond 2 (> (atof ans) 0.0) (progn (setq num (atof ans) dims (ssget (list '(0 . "*DIMENSION") '(-4 . "<AND") '(-4 . ">") (cons 42 (- num 0.049)) '(-4 . "<") (cons 42 (+ num 0.049)) '(-4 . "AND>") ))) (if dims (command "_erase" dims "")) ) ; (setq num (atof ans) ; dims (ssget (list '(0 . "*DIMENSION") ; '(-4 . "<AND") ; '(-4 . "<OR") '(-4 . "=") (cons 42 num) '(-4 . ">") (cons 42 num) '(-4 . "OR>") ; '(-4 . "<") (cons 42 (+ num 0.001)) ; '(-4 . "AND>") ; ))) ;(PRINT num) ) (progn (princ "\n*** Invalid Number on Input") ) ) (princ) );defun rd ;making a block of columns only (defun c:mc(/) (defun selectColumns(/ cols) (if (and (setq cols (ssget ":S" '((0 . "INSERT")))) ; select current columns block (setq base_point (getpoint "Pick base point:"))) (progn (command "_explode" cols) (setq cols (ssget "_P")) (setq current_block_name (getAvailableBlockName "COLS_")) ;(princ current_block_name) (command "-block" current_block_name base_point cols "") (insertBlock current_block_name base_point) (princ (strcat "\nBLOCK NAME: " current_block_name "\n")) (command "-refedit" (entlast) "_O" "_A" "_Y") ) ) ) (defun getAvailableBlockName(_prefix / dwg block_name num current_block name_limit_thrushold) (setq dwg (getvar 'dwgname)) ; example.dwg (setq block_name (strcat _prefix (strcase (substr dwg 1 (- (strlen dwg) 4)) nil) "_")) ; BLOCK_EXAMPE_ (setq num 1 name_limit_thrushold 10) (repeat name_limit_thrushold (if (= (blockAvailable (strcat block_name (itoa num))) nil) (progn (setq current_block (strcat block_name (itoa num))) current_block ) (setq num (1+ num)) ) ) ) (selectColumns) (princ) ) (defun c:mb(/) (defun makeBlock(/ blocks base_point current_block_name) (if (and (setq blocks (ssget)) (setq base_point (getpoint "Pick base point:"))) (progn (setq current_block_name (getAvailableBlockName)) ;(princ current_block_name) (command "-block" current_block_name base_point blocks "") (insertBlock current_block_name base_point) (princ (strcat "\nBLOCK NAME: " current_block_name "\n")) ) ) (princ) ) (defun getAvailableBlockName( / dwg block_name num current_block name_limit_thrushold) (setq dwg (getvar 'dwgname)) ; example.dwg (setq block_name (strcat "BLOCK_" (strcase (substr dwg 1 (- (strlen dwg) 4)) nil) "_")) ; BLOCK_EXAMPE_ (setq num 1 name_limit_thrushold 10) (repeat name_limit_thrushold (if (= (blockAvailable (strcat block_name (itoa num))) nil) (progn (setq current_block (strcat block_name (itoa num))) current_block ) (setq num (1+ num)) ) ) ) (makeBlock) (princ) ) ; common lisp routine to use both functions (defun blockAvailable(name / available) (setq available (tblsearch "block" name)) available ) (defun insertBlock(name point /) (vla-InsertBlock acSpace (vlax-3d-point point) name 1 1 1 0) ) (defun c:rb(/ current_block) (defun draw_Rectangle() ;gets the last created block (makeBlock) (setq current_block (entlast)) ;(print "current block") (if (/= nil current_block) (progn (setq pointers (getBoundingBox current_block)) (print pointers) (command "_rectangle" "_non" (car pointers) "_non" (cadr pointers)) (command "_offset" 1 (entlast) pause "") (command "_offset" 0.8 (entlast) pause "") (command "_explode" current_block) ) ) ) (defun makeBlock(/ objects base_point current_block_name) (setq current_block_name "tamimi_temp" objects (ssget '((-4 . "<OR") (8 . "WAL") (8 . "HIDDEN") (-4 . "OR>")))) (setq base_point (getpoint "Pick base point:")) (if (/= (blockAvailable current_block_name) nil) (command "-purge" "B" current_block_name "N" "")) (command "-block" current_block_name base_point objects "") (insertBlock current_block_name base_point) ;now the block is inserted and it can be called by entlast ) (defun getBoundingBox(obj /) (vla-getboundingbox (vlax-ename->vla-object obj) 'p1 'p2) (setq cords (list p1 p2)) (setq cords (mapcar 'vlax-safearray->list cords)) cords ) (draw_Rectangle) (princ) ) (defun c:cb(/ block_to_find block_name blocks) (setq block_to_find (ssget ":S" '((0 . "INSERT")))) (if (/= block_to_find nil) (progn (setq block_name (cdr (assoc 2 (entget (ssname block_to_find 0))))) ;name of block (print block_name) (setq blocks (ssget "_X" (list (cons 0 "INSERT") (cons 2 block_name)))) (command "_SELECT" blocks) (if (> (sslength blocks) 0) (progn ;remove ;(command "_SELECT" blocks) (while (> (getvar 'cmdactive) 0) (command pause) (setq blocks (ssget "_P"))) (initget "Y N") (setq cont (getstring (strcat "\n::: Delete blocks (" (itoa (sslength blocks)) " found)? (Yes/No) <N>: "))) (if (= (strcase cont nil) "Y") (command "_ERASE" blocks "") (princ "OK") ) ;(command "-purge" "B" block_name "N" "") ; purgeblock ) ) ) ) (princ) ) (defun c:mb2(/ asset) ;make the selection (setq asset (ssget) back asset QF (getvar 'qaflags)) (SETQ attbs (ssget "_P" '( (-4 . "<OR") (0 . "TEXT") (0 . "*DIMENSION") (-4 . "<AND") (0 . "INSERT") (-4 . "<OR") (2 . "BLOCK_STAIR_NO") (2 . "dtag") (2 . "A$C23000B7B") (-4 . "OR>") (-4 . "AND>") (-4 . "OR>") ))) (if attbs (progn (princ (strcat "Deleting " (itoa (sslength attbs)) " blocks...")) (command "_erase" attbs "") ) (print "No Attributes") ) ;(sssetfirst nil asset) (setvar "qaflags" 1) (princ "Exploding objects... phase 1") (command "_explode" asset "") (print (itoa (sslength asset))) (setvar "qaflags" 0) (SETQ doortags (ssget "_P" '( (-4 . "<OR") (0 . "TEXT") (-4 . "<AND") (0 . "INSERT") (8 . "door") (-4 . "AND>") (-4 . "OR>") ))) (if doortags (progn (princ "Deleting door tags...") (command "erase" doortags "") ) ) (setvar "qaflags" 1) (princ "Exploding objects... phase 2") (sssetfirst nil asset) (command "_explode" asset "") (setvar "qaflags" 0) (print (itoa (sslength asset))) (princ "Changing Color to 8...") (setq i 0 ss (ssadd)) (repeat (sslength asset) (if (/= (entget (ssname asset i)) nil) (setq ss (ssadd (ssname asset i) ss)) ) (setq i (1+ i)) ) (print (itoa (sslength ss))) (command "_chprop" ss "" "_color" 8 "") (command "_select" ss) (setvar 'qaflags 0) ) ; ******************************************************************* ; helps to erase objects like text, door tags when creating block ; for layout other than architecture ; ******************************************************************* (defun c:rx ( / blocks ans) ;"Documentation for c:rd." (SETQ blocks (ssget '( (-4 . "<OR") (0 . "TEXT") (8 . "Win-no") (8 . "DTAG") (-4 . "<AND") (0 . "INSERT") (8 . "door") (-4 . "AND>") (-4 . "<AND") (0 . "CIRCLE") (8 . "DIM") (-4 . "AND>") (-4 . "OR>") ))) ;(SETQ ans (strcase (getstring "\nWould you like to Remove <Y>: "))) (if blocks (command "_.erase" blocks "")) (princ) );defun (defun c:ln(/ obj length_all) (setq obj (ssget '((0 . "*LINE")))) (setq length_all (mapcar 'vla-get-length (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex obj))))) ) (princ (strcat "\nTotal Length: " (rtos (apply '+ length_all)) " m.")) (princ) ) (defun c:bf(/ area ground perc output) (defun get(obj / rtn) (princ (vla-get-TextString obj)) (setq rtn (atof (vl-string-subst "" "\\pxqj;" (vla-get-TextString obj)))) ) (if (AND (vlax-property-available-p (setq area (vlax-ename->vla-object (car (entsel "Area: ")))) 'TextString) (vlax-property-available-p (setq ground (vlax-ename->vla-object (car (entsel "Ground: ")))) 'TextString) (vlax-property-available-p (setq perc (vlax-ename->vla-object (car (entsel "Output: ")))) 'TextString) ) (progn (print (strcat "Area:" (rtos (get area)) "\n" "Ground:" (rtos (get ground)) "\n")) (setq output (/ (* (get ground) 100) (get area))) (vla-put-TextString perc (strcat (rtos output 2 0) " %")) ) ) (princ) ) ; ******************************************************************* ; Draw polylines along with hatch bounderies ; ******************************************************************* (defun c:hp ( / e i l s lsorted) (vla-StartUndoMark acDoc) (if (setq s (ssget '((0 . "HATCH")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (entget e) lsorted (vl-remove-if-not '(lambda (x) (and (= 10 (car x)) (not (= (car (cdr x)) 0.0)))) l) ; it's been sorted to eleminate other eliments ;lsorted (reverse (cdddr (reverse lsorted))) ) ;(princ (cdr (car lsorted))) (princ lsorted) ;(princ (car (cdr (car lsorted)))) (apply 'command (append '("_.pline") (apply 'append (mapcar (function (lambda ( x ) (list "_non" (trans (cdr x) e 1)) ) ) lsorted ) ) (list (cdr (car lsorted))) (if (= 1 (logand 1 (cdr (assoc 70 l)))) '("_C") '("")) ) ) ) ) (vla-EndUndoMark acDoc) (princ) ) ; ******************************************************************* ; Draw Multilines over polylines ; ******************************************************************* (defun c:mh ( / e i l s acadObj doc) (vla-StartUndoMark acDoc) (if (setq s (ssget '((0 . "LWPOLYLINE") (-4 . "<NOT") (1 . "ARC") (-4 . "NOT>")))) (repeat (setq i (sslength s)) (setq e (ssname s (setq i (1- i))) l (entget e) ) (apply 'command (append '("_.mline") (apply 'append (mapcar (function (lambda ( x ) (list "_non" (trans (cdr x) e 1)) ) ) (vl-remove-if-not '(lambda ( x ) (= 10 (car x))) l) ) ) (if (= 1 (logand 1 (cdr (assoc 70 l)))) '("_C") '("")) ) ) ) ) (vla-EndUndoMark acDoc) (princ) ) (defun c:mj ( / cm e1 e2 i1 i2 il m1 m2 o1 o2 p1 ss ml_start ml_end ml_cir_int ml_cross_line) #| (setq acApp (vlax-get-acad-object)) (setq acDocs (vla-get-ActiveDocument acApp)) (setq acSpace (vla-get-ModelSpace acDocs)) |# ; start undo mark (vla-StartUndoMark acDoc) (if (setq ss (ssget "_:L" '((0 . "MLINE")))) (progn (setq cm (getvar 'cmdecho)) (setvar 'cmdecho 0) (repeat (setq i1 (sslength ss)) (setq e1 (ssname ss (setq i1 (1- i1))) o1 (vlax-ename->vla-object e1) ml_start (car (group3 (vlax-get o1 'coordinates))) ; ml start coordinates ml_end (last (group3 (vlax-get o1 'coordinates))) ) (repeat (setq i2 i1) (setq e2 (ssname ss (setq i2 (1- i2))) o2 (vlax-ename->vla-object e2) il (group3 (vlax-invoke o1 'intersectwith o2 acextendnone)) ) (cond ( (= 1 (length il)) (command "_.-mledit" "_CJ" (list e1 (car il)) (list e2 (car il)) "") ) ( (= 4 (length il)) (command "_.-mledit" "_OC" (list e1 (car il)) (list e2 (cadr il)) "") ) ( (= 2 (length il)) (setq p1 (car il) m1 (group3 (vlax-get o1 'coordinates)) m2 (group3 (vlax-get o2 'coordinates)) ) (if (< (min (distance p1 (car m1)) (distance p1 (last m1))) (min (distance p1 (car m2)) (distance p1 (last m2))) ) (command "_.-mledit" "_OT" (list e1 (car il)) (list e2 (cadr il)) "") (command "_.-mledit" "_OT" (list e2 (car il)) (list e1 (cadr il)) "") ) ) ) ) ) (setvar 'cmdecho cm) ) ) (vla-EndUndoMark acDoc) (princ) ) ; Trims Multilines less intelligently -MJ (defun c:mmj ( / cm e1 e2 i1 i2 il m1 m2 o1 o2 p1 ss ml_start ml_end ml_cir_int ml_cross_line ml_cord) (vla-StartUndoMark acDoc) (if (setq ss (ssget "_:L" '((0 . "MLINE")))) (progn (setq cm (getvar 'cmdecho)) (setvar 'cmdecho 0) (repeat (setq i1 (sslength ss)) (setq e1 (ssname ss (setq i1 (1- i1))) o1 (vlax-ename->vla-object e1) ml_start (car (group3 (vlax-get o1 'coordinates))) ; ml start coordinates ml_end (last (group3 (vlax-get o1 'coordinates))) ml_cord '() ml_cord (cons ml_start ml_cord) ml_cord (cons ml_end ml_cord) ) (repeat (setq i2 i1) (setq e2 (ssname ss (setq i2 (1- i2))) o2 (vlax-ename->vla-object e2) il (group3 (vlax-invoke o1 'intersectwith o2 acextendnone)) ) ;(princ (strcat "\nINTERSECT: " )) (princ il) (princ ml_cord) (foreach cor ml_cord (progn (if (AND (/= il nil) (not (member cor il)) (>= (distance cor (car il)) 0.15)) (progn (setq tempcircle (vla-addcircle acSpace (vlax-3d-point (trans cor 0 1)) 0.1) ml_cir_int (group3 (vlax-invoke o1 'intersectwith tempcircle acextendnone)) ) (if ml_cir_int (setq ml_cross_line (vla-addline acSpace (vlax-3d-point (car ml_cir_int)) (vlax-3d-point (last ml_cir_int)))) ) ;(princ (car ml_cir_int)) ;(princ (last ml_cir_int)) (vla-delete tempcircle) ) ) ) ) (cond ( (= 1 (length il)) (command "_.-mledit" "_CJ" (list e1 (car il)) (list e2 (car il)) "") ) ( (= 4 (length il)) (command "_.-mledit" "_OC" (list e1 (car il)) (list e2 (cadr il)) "") ) ( (= 2 (length il)) (setq p1 (car il) m1 (group3 (vlax-get o1 'coordinates)) m2 (group3 (vlax-get o2 'coordinates)) ) (if (< (min (distance p1 (car m1)) (distance p1 (last m1))) (min (distance p1 (car m2)) (distance p1 (last m2))) ) (command "_.-mledit" "_OT" (list e1 (car il)) (list e2 (cadr il)) "") (command "_.-mledit" "_OT" (list e2 (car il)) (list e1 (cadr il)) "") ) ) ) ) ) (setvar 'cmdecho cm) ) ) (vla-EndUndoMark acDoc) (princ) ) ; function used by the mline trim command (defun group3 (l / r) (repeat (/ (length l) 3) (setq r (cons (list (car l) (cadr l) (caddr l)) r) l (cdddr l) ) ) (reverse r) ) ; ******************************************************************* ; Weld Multiline when they're broken ; ******************************************************************* (defun c:wa(/ ss i1 e1 o1 m1) (if (setq ss (ssget "_:L" '((0 . "MLINE")))) (progn ;(setq cm (getvar 'cmdecho)) ;(setvar 'cmdecho 0) (repeat (setq i1 (sslength ss)) ;(print (itoa i1)) (setq e1 (ssname ss (setq i1 (1- i1))) o1 (vlax-ename->vla-object e1) m1 (group3 (vlax-get o1 'coordinates)) ) ;(princ (command "_.-mledit" "_WA" (list e1 (car m1)) (list e1 (last m1)) "") );repeat );progn ) (princ) ) ; ******************************************************************* ; ******************************************************************* ; change the dimension style and the layer. (defun ld(ans / prev text ans layer) ;(initget "i o") ;(setq ans (strcase(getstring "\nChoose [Inner/Outer] <Inner>: "))) (setq layer "DIM") (if (= ans "") (setq ans "I")) (if (= ans "I") (progn (princ "\n*** Inner Dimension") (_SetDimStyleCurrent "al-tamimi- new dim") ) ; progn (progn (princ "\n*** Outer Dimension") (_SetDimStyleCurrent "NO XL") ) ) (setq prev (getvar "CLAYER")) (setvar "CLAYER" layer) (command "_.-layer" "ON" layer "") (princ (strcat "\n*** LAYER CHANGED: " prev "->" layer)) (princ) ) (defun c:ldl(/ dims dimstyle) (setvar 'cmdecho 0) (defun selDims() (prompt "Select Dimension") (if (setq dims (ssget ":S" '((0 . "DIMENSION")))) (progn (setq ent (entget (ssname dims 0))) (setq dimstyle (cdr (assoc 3 ent))) (princ (strcat "*** DIMESION STYLE : " dimstyle)) (_SetDimStyleCurrent dimstyle) (command "_.DIMLINEAR") ) (progn (princ "*** Select a valid Dimension") (selDims) ) ) ) (selDims) (princ) ) (defun c:ldi() (ld "I") )(defun c:ldo() (ld "O") ) (defun _SetDimStyleCurrent (dim / ) (if (tblsearch "DIMSTYLE" dim) (vla-put-activeDimstyle acDoc (vla-item (vla-get-Dimstyles acDoc) dim) ) (alert "Invalid Dimension Style") ) (princ) ) ; ******************************************************************* ; ******************************************************************* ;executes 3 most important commands on the go (defun C:PAL (/ file old now) (command ".-LAYER" "Set" '0 "") (setq old 0 now old t_file_has_access T) (if (not (setq old (get_file_size))) ;if the file unable to access this makes the var old nil, so arithmatic throws error (progn (setq t_file_has_access nil) (setq old 0)) ; making it nil to zero ) (command ".AUDIT" "Y") (princ "*** PURGING...") ; NO USE WONT SHOW IN THE COMMAND LINE (command ".PURGE" "All" "" "N") (PRINC (strcat "\n*** LOCATION : " (getvar 'dwgprefix))) (PRINC (strcat "\n*** SAVING CURRENT DRAWING : " (getvar 'dwgname) " ...")) ; SHOWING CURRENT DRAWING NAME (PRINC) (command ".QSAVE") (princ "\n*** DONE.") (if (/= t_file_has_access nil) (setq now (get_file_size))) (if (> old now) (princ (strcat "\n*** FILE REDUCED : " (rtos (- old now) 2 2) " KB \\U+2193")) (princ (strcat "\n*** FILE INCREASED : " (rtos (- now old) 2 2) " KB \\U+2191")) ) ;(command ".ZOOM" "Extents") (princ)) ;Purges all unused symbols ; ******************************************************************* ; Converts Text to MText ; ******************************************************************* (defun c:t2m() (if (setq tx (ssget '((0 . "TEXT")))) (progn (command "txt2mtxt" (ssname tx 0) "") ) ) ) ; ******************************************************************* ; CONVERTS EDUCATIONAL DWG -> DXF -> DWG ; Unfortunately it works only on single document mode sdi=1 ; ******************************************************************* (defun c:dxf(/ dxffilename dwg dxf) ;(vl-load-com) (setvar "lispinit" 0) ;LISP-Prg. mem. resistent (setq dwgpath "D:\\DWG\\" dxfpath "D:\\DXF\\") (setq dwg (getvar 'dwgname)) (setq dxf (strcat dxfpath (substr dwg 1 (- (strlen dwg) 4)) ".dxf")) (setq dxffilename (strcat (substr dwg 1 (- (strlen dwg) 4)) ".dxf")) (princ) (princ (strcat "\n*** SAVING CURRENT FILE: " dwg)) (command "_.QSAVE") (command "dxfout" dxf "16") (princ (strcat "\n*** DXF FILE HAS BEEN SAVED : " dxf)) ;(setvar 'sdi 0) (command "_FILEOPEN" dxf) ; (setq acApp (vlax-get-acad-object)) ; (setq acDocs (vla-get-documents acApp)) ; (vla-open acDocs dxf) (if (= (getvar 'dwgname) dxffilename) (command "_.SAVEAS" "2010" (strcat dwgpath dwg)) ) ;(setvar 'sdi 1) (princ) ) ; ******************************************************************* ; PRINT WITH AL TAMIMI WATERMARK OVER THE CROOCKY ; ******************************************************************* (defun c:pc(/ filewatermark zstyle *error*) (setq acadObj (vlax-get-acad-object) doc (vla-get-ActiveDocument acadObj) modelSpace (vla-get-ModelSpace doc) filewatermark "watermark.dwg") ; (defun *error* (msg) ; (if (wm) ; (vla-delete wm) ; ) ; (princ "\nRollback is done!") ; ) (setq orientation "l" styleColor "for print.ctb" styleCroky "croky.ctb") ; (setq zstyle "croky.ctb" ; zprinter "DWG To PDF.pc3" ; zpaper "ISO full bleed A3 (297.00 x 420.00 MM)") ; DEFAULT VALUES (setq zstyle styleCroky zprinter pXerox zpaper "A3 297x420mm - plain paper") (if (setq color (getstring "\nColor Options [Color or Black] <Black>: ")) (progn (if (= (strcase (substr color 1 1) nil) "C") (setq zstyle styleColor zprinter pHp) ) ) ) (if (setq ps (getstring "\nSelect paper size [A4, A3] <A4>: ")) (if(= (strcase ps nil) "A3") (if (= zstyle styleColor) (setq zpaper "A3 297x420mm - plain paper") ; hp (setq zpaper "A3 (297 x 420mm)") ; Xerox ) ; else (if (= zstyle styleColor) (setq zpaper "A4") ; for hp (setq zpaper "A4 (210 x 297mm)") ; for xerox ) ) ) (if (setq land (getstring "\nOrientation [Potrait or Landscape] <Landscape>: ")) (progn (if (= (strcase (substr land 1 1) nil) "P") (setq orientation "p") ) ) ) (princ (strcat "\n" zprinter " | " zpaper " | " zstyle " | " (if (= orientation "l") "Landscape" "Potrait"))) ;(if (setq box (ssget)) (setq minExt (getpoint "\nSelect First Point: ")) (print minExt) ;(initget 32) (setq maxExt (getcorner minExt "\nSelect Second Point: ")) (print maxExt) (if (= 1 1) (Progn ;(setq box (ssname box 0)) ;(command "zoom" "_object" box "") ;(setq bc (getvar 'viewctr)) ;(command "zoom" "p") ;(princ bc) (if (not (findfile filewatermark)) (progn (alert "Watermark dwg file is not available in the working directory.") (exit) ) ) ;GETTING UPPER AND LOWER POINTS ;CENTER OF BOTH POINTS (setq cpoints (mapcar '(lambda (p1 p2) (/ (+ p1 p2) 2.0)) minExt maxExt)) (print cpoints) (setq wm (vla-InsertBlock modelSpace (vlax-3d-point cpoints) filewatermark 1 1 1 0)) (command "zoom" "_object" (vlax-vla-object->ename wm) "") ;WATER MARK CENTER POINT (setq wmc (getvar 'viewctr)) ;(print wmc) (command "zoom" "p") (command "_.DRAWORDER" (vlax-vla-object->ename wm) "" "_back") (vla-move wm (vlax-3d-point wmc) (vlax-3d-point cpoints)) ;(vla-rotate wm (vlax-3d-point bc) 0.7853981) ; value for 45 deg (vla-put-layer wm "WATERMARK") ;(command "rotate" (vlax-vla-object->ename wm) "" bc 45) ;(setq vlbox (vlax-ename->vla-object box)) ;(vla-GetBoundingBox vlbox 'minExt 'maxExt) ;(setq minExt (vlax-safearray->list minExt) ; maxExt (vlax-safearray->list maxExt)) ; box distance (setq dbox (distance minExt maxExt)) (print (rtos dbox)) (print minExt) (print maxExt) ;Watermark region (vla-GetBoundingBox wm 'wminExt 'wmaxExt) (setq wminExt (vlax-safearray->list wminExt) wmaxExt (vlax-safearray->list wmaxExt)) (setq dwm (distance wminExt wmaxExt)) (print (rtos dwm)) (vla-rotate wm (vlax-3d-point cpoints) (angle minExt maxExt)) (setq sf (/ (- dbox 10) dwm)) (print (rtos sf)) (vla-scaleentity wm (vlax-3d-point cpoints) sf) ;PLOT (plotter2 zprinter zpaper zstyle minExt maxExt "N" orientation) ) ) (vla-delete wm) (princ "*** PRINT COMPLETED") (princ) ) (defun c:p2j(/ filewatermark zstyle *error* *UniNum* genFilename tofile) (if (not *UniNum*) (setq *UniNum* 0)) (defun genFilename() (princ (itoa *UniNum*)) (setq loc (getvar 'dwgprefix) i 1 fn "") (while (> i *UniNum*) (if (not (findfile (strcat loc (itoa i) ".jpg"))) (progn (setq fn (strcat loc (itoa i) ".jpg") *UniNum* i) fn ) (setq i (1+ i)) ) ) ) (setq tofile (genFilename)) (setq acadObj (vlax-get-acad-object) doc (vla-get-ActiveDocument acadObj) modelSpace (vla-get-ModelSpace doc) filewatermark "watermark.dwg") ; (defun *error* (msg) ; (if (wm) ; (vla-delete wm) ; ) ; (princ "\nRollback is done!") ; ) (setq orientation "l" styleColor "for print.ctb" styleCroky "croky.ctb" styleJpeg "TO-JPEG.ctb" jpegprinter "PublishToWeb JPG.pc3") ; DEFAULT VALUES (setq zstyle styleJpeg zprinter jpegprinter zpaper "TO_JPEG_3200X2560") ; TO_JPEG_3200X2560 - is predefined under autocad ; zpaper "Sun Hi-Res (1600.00 x 1280.00 Pixels)") (princ (strcat "\n" zprinter " | " zpaper " | " zstyle " | " (if (= orientation "l") "Landscape" "Potrait"))) ;(if (setq box (ssget)) (setq minExt (getpoint "\nSelect First Point: ")) (print minExt) ;(initget 32) (setq maxExt (getcorner minExt "\nSelect Second Point: ")) (print maxExt) (if (= 1 1) (Progn ;(setq box (ssname box 0)) ;(command "zoom" "_object" box "") ;(setq bc (getvar 'viewctr)) ;(command "zoom" "p") ;(princ bc) (if (not (findfile filewatermark)) (progn (alert "Watermark dwg file is not available in the working directory.") (exit) ) ) ;GETTING UPPER AND LOWER POINTS ;CENTER OF BOTH POINTS (setq cpoints (mapcar '(lambda (p1 p2) (/ (+ p1 p2) 2.0)) minExt maxExt)) (print cpoints) (setq wm (vla-InsertBlock modelSpace (vlax-3d-point cpoints) filewatermark 1 1 1 0)) (command "zoom" "_object" (vlax-vla-object->ename wm) "") ;WATER MARK CENTER POINT (setq wmc (getvar 'viewctr)) ;(print wmc) (command "zoom" "p") (command "_.DRAWORDER" (vlax-vla-object->ename wm) "" "_back") (vla-move wm (vlax-3d-point wmc) (vlax-3d-point cpoints)) ;(vla-rotate wm (vlax-3d-point bc) 0.7853981) ; value for 45 deg (vla-put-layer wm "WATERMARK") ;(command "rotate" (vlax-vla-object->ename wm) "" bc 45) ;(setq vlbox (vlax-ename->vla-object box)) ;(vla-GetBoundingBox vlbox 'minExt 'maxExt) ;(setq minExt (vlax-safearray->list minExt) ; maxExt (vlax-safearray->list maxExt)) ; box distance (setq dbox (distance minExt maxExt)) (print (rtos dbox)) (print minExt) (print maxExt) ;Watermark region (vla-GetBoundingBox wm 'wminExt 'wmaxExt) (setq wminExt (vlax-safearray->list wminExt) wmaxExt (vlax-safearray->list wmaxExt)) (setq dwm (distance wminExt wmaxExt)) (print (rtos dwm)) (vla-rotate wm (vlax-3d-point cpoints) (angle minExt maxExt)) (setq sf (/ (- dbox 10) dwm)) (print (rtos sf)) (vla-scaleentity wm (vlax-3d-point cpoints) sf) ;PLOT (princ (strcat "####################" tofile)) (princ) (plotterj zprinter zpaper zstyle minExt maxExt tofile) ) ) (vla-delete wm) (princ "*** PRINT COMPLETED") (princ) ) ; ******************************************************************* ; FINAL PRINTINGS ; ******************************************************************* (defun a2(zprinter zpaper zstyle plottype / msg plotOrder) (setq plotOrder "") (cond ((OR (eq plottype 'pdf) (eq plottype 'black)) (setq plotOrder "BOTTOM - TOP")) ((= plottype 'colour) (setq plotOrder "TOP - BOTTOM")) ) (setq msg (strcat "*** BALADIYA CHECK LIST ***\n" "\n1. Site Plan Values & Scale (1:150)" "\n2. Section Lines & Section (a-a),(b-b)" "\n3. Elevation (4)" "\n4. Title Block & Titles" "\n\n" "*** Customer Name ***\n" "___________________________________________\n" "\n| Printer: " zprinter "\n| Paper: " zpaper "\n| Style: " zstyle "\n___________________________________________" )) (alert msg) ) ; PDF (defun c:p2p(/ zpaper zstyle) ;Current_printer_identifier (setq cpi 'PDF) (if (setq color (getstring "\nColor or Black <Color>: ")) (progn (setq color (strcase color nil)) ; making uppercase (if (OR (= color "B") (= color "BLACK")) (setq zstyle ($get_printing_style 'black)) (setq zstyle ($get_printing_style 'color)) ) ) ) ;(princ "\n**************************** [ BOTTOM -> TOP ] ****************************") (p2 ($get_printer cpi) ($get_paper_for_printer cpi) zstyle 'pdf nil :vlax-false :vlax-true) ) (defun c:pjpg(/ zprinter zpaper zstyle) (setq zstyle "for print.ctb" zprinter "PublishToWeb JPG.pc3" zpaper "Sun Hi-Res (1600.00 x 1280.00 Pixels)") (if (setq color (getstring "\nColor or Black <Color>: ")) (progn (setq color (strcase color nil)) ; making uppercase (if (OR (= color "B") (= color "BLACK")) (setq zstyle "for black.ctb") ) ) ) ;(princ "\n**************************** [ BOTTOM -> TOP ] ****************************") (p2 zprinter zpaper zstyle 'jpg nil :vlax-false :vlax-true) ) ;BLACK (defun c:p2B(/) ;Current_printer_identifier (setq cpi 'XEROX) ;************************** ;*******- FACE DOWN- ******** ;************************** ;(princ "\n**************************** [ BOTTOM -> TOP ] ****************************") (p2 ($get_printer cpi) ($get_paper_for_printer cpi) ($get_printing_style 'BLACK) 'black nil :vlax-false :vlax-true) ) ;COLOUR (defun c:p2C(/) ;Current_printer_identifier (setq cpi 'ROBOT) ;************************** ;*******- FACE UP- ******** ;************************** ;(princ "\n**************************** [ TOP -> BOTTOM ] ****************************") (p2 ($get_printer cpi) ($get_paper_for_printer cpi) ($get_printing_style 'COLOR) 'colour nil :vlax-false :vlax-true) ) ;COLOUR (defun c:p24(/) ;;Current_printer_identifier (setq cpi 'HP400) ;************************** ;*******- FACE DOWN -****** ;************************** ;(princ "\n**************************** [ TOP -> BOTTOM ] ****************************") (p2 ($get_printer cpi) ($get_paper_for_printer cpi) ($get_printing_style 'COLOR) 'black nil :vlax-false :vlax-true) ) (defun p2 (zprinter zpaper zstyle plottype ss isHistory needSort / gc:UcsBoundingBox gc:TMatrixFromTo cm dwgn object llpt lst ss urpt zstyle zprinter zpaper f_cpi) (setq cm (getvar 'cmdecho)) (setvar 'cmdecho 0) ;; by Gilles Chanteau ;; gc:UcsBoundingBox ;; Returns the UCS coordinates of the object bounding box about current UCS ;; ;; Arguments ;; obj: an entity (ENAME or VLA-OBJCET) ;; _OutputMinPtSym: a quoted symbol (output) ;; _OutputMaxPtSym: a quoted symbol (output) (defun gc:UcsBoundingBox (obj _OutputMinPtSym _OutputMaxPtSym) (and (= (type obj) 'ename) (setq obj (vlax-ename->vla-object obj)) ) (vla-transformby obj (vlax-tmatrix (gc:TMatrixFromTo 1 0))) (vla-getboundingbox obj _OutputMinPtSym _OutputMaxPtSym) (vla-transformby obj (vlax-tmatrix (gc:TMatrixFromTo 0 1))) (set _OutputMinPtSym (vlax-safearray->list (eval _OutputMinPtSym))) (set _OutputMaxPtSym (vlax-safearray->list (eval _OutputMaxPtSym))) ) ;; gc:TMatrixFromTo ;; Returns the 4X4 transformation matrix from a coordinate system to an other one ;; ;; Arguments ;; from to: same arguments as for the 'trans' function (defun gc:TMatrixFromTo (from to) (append (mapcar (function (lambda (v o) (append (trans v from to t) (list o)) ) ) '( (1.0 0.0 0.0) (0.0 1.0 0.0) (0.0 0.0 1.0) ) (trans '(0.0 0.0 0.0) to from) ) '((0.0 0.0 0.0 1.0)) ) ) (defun printSet(/) (initget "C B P") (setq cont (getstring (strcat "\n::: Print a Copy of (Color/Black/cPDF/Esc to Cancel) <Esc>: "))) (setq ans (strcase (substr cont 1 1) nil)) (cond ((= ans "B") (setq f_cpi 'XEROX zstyle ($get_printing_style 'BLACK) zprinter ($get_printer f_cpi) zpaper ($get_paper_for_printer f_cpi) plottype 'black) ) ((= ans "C") (setq f_cpi 'ROBOT zstyle ($get_printing_style 'COLOR) zprinter ($get_printer f_cpi) zpaper ($get_paper_for_printer f_cpi) plottype 'colour) ) ((= ans "P") (setq f_cpi 'PDF zstyle ($get_printing_style 'COLOR) zprinter ($get_printer f_cpi) zpaper ($get_paper_for_printer f_cpi) plottype 'pdf) ) ((exit)) ) ;cond (doPrint) ) (defun doPrint(/ cords folder dwgname fn isOverrideEnabled) ;Setting up constraints (setq project_limit_thrushold 5 sorting_thrushold 3 progress_thrushold 5) (if ss (progn ;(setvar 'filedia 0) ; to do (setq vc (getvar "VIEWCTR") vs (getvar "VIEWSIZE") ve (trans '(0 0 1) 0 1) increment 1 cords '()) ;the output of the paper from hp printer is 'faced' ;so the last paper should be ordered first ;but the black xerox will print the paper off faced - thus it should print the first page first (if (eq plottype 'colour) (setq i (sslength ss) delta -1) (setq i -1 delta 1) ) ;ss ; sorting ename blocks (if (and (<= sorting_thrushold (sslength ss)) (OR (= :vlax-false isHistory) (= :vlax-true needSort))) (progn (setq cont (getstring "\n::: Sort-Blocks? (Yes/No) <N>: ")) (if (= (strcase cont nil) "Y") (setq block_entities (sortBlocks (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) ; sort blocks (setq block_entities (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) ;un- sorted ) ) (setq block_entities (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))) ;un- sorted ) (if (<= progress_thrushold (length block_entities)) (progn ;(load ".\\progress.lsp") (ODCL:showProgress zprinter (length block_entities)) ; initiate progress with total blocks count ) ) ;FILENAME FOR PLOT TO PDF (setq dwgname "n") ;Preparing the folder to save the PDF or JPEG (if (OR (= plottype 'pdf) (= plottype 'jpg)) (progn (setq fn (getvar "dwgname") fn (cadr (fnsplitl fn))) (setq folder (getDefualtPDFLocation fn)) ; getting rid of exiting pdf files files ; directory pattern folder/file (if (/= nil (setq files (vl-directory-files folder "*.pdf"))) (progn (setq cont (getstring (strcat "\n::: Delete exiting " (itoa (length files)) " PDF files? (Yes/No) <Y>: "))) (if (/= "N" (strcase cont T)) (progn (foreach file files (progn (princ (strcat "> Deleting... " file " - ")) (if (vl-file-delete (strcat folder "\\" file)) (princ "Done.\n") (princ "Failed.\n")) ) ) ;foreach ) (princ "") ) ;if ) ;progn ) ;if ) ;progn ) ;if ;init progress (acet-ui-progress-init "Printing in Progress : " (length block_entities)) ;print loop (repeat (length block_entities) ;(setq hnd (ssname ss (setq i (+ i delta)))) (setq object (nth (setq i (+ i delta)) block_entities)) (gc:UcsBoundingBox object 'llpt 'urpt) (setq lst (cons llpt lst) lst (cons urpt lst)) (setq llpt (apply 'mapcar (cons 'min lst)) urpt (apply 'mapcar (cons 'max lst))) ;(print lst) (setq lst nil) ; **********************; ; --- PLOTTING ---- ; ; **********************; ; if the plot type is in one of these, then the filename will an incremental number inside that folder (if (OR (= plottype 'pdf) (= plottype 'jpg)) (setq dwgname (strcat folder "\\" (itoa increment))) ) (command "zoom" "_object" object "") (princ (strcat "\n*** Printing " (itoa increment) " of " (itoa (sslength ss)) " ***")) ;increment progress (acet-ui-progress-safe increment) (ODCL:setProgress increment) ; PAUSING THE SECOND PRINT (if (= increment 2) (progn (setq cont (getstring "\n::: Continue Printing (Yes/No) <Y>: ")) (if (= (strcase cont nil) "N") (Progn (command "_ZOOM" "_C" (trans vc ve 1) vs) ; RESTORING ZOOM LEVEL (princ (strcat "\n*** Plot to \"" zprinter "\" has been cancelled!")) (exit)) ; EXIT ) ) ) ;PLOT (if (= plottype 'jpg) (plotterj zprinter zpaper zstyle llpt urpt dwgname) (plotter zprinter zpaper zstyle llpt urpt dwgname) ) ;getting cords (setq cords (cons (list llpt urpt) cords)) (setq increment (1+ increment)) (command "_DELAY" 500) ) ;repeat ;********************* ;RESTORING ZOOM LEVEL ;********************* (ODCL:closeProgress) (acet-ui-progress-done) (command "_ZOOM" "_C" (trans vc ve 1) vs) ;save last printed date (markLastPrint) ;(print (setq rev (reverse cords))) ;mark history (mark_history (if (/= plottype 'colour) (reverse cords) cords) plottype) ; if it is colour cords will be ordered top - bottom ; PREPARING THE SAME SELECTION SET FOR ANOTHER PRINT (if (> (sslength ss) project_limit_thrushold) (progn ;********************************* ;STORING COORDINATES INTO THE FILE ;********************************* ; (initget "Y N") ; (setq ans (getstring "\nWould you like to save these block references for later Printing? (Y/N) <N>: ")) ; (if (= (strcase ans nil) "Y") ; (progn ; ;IF THE PRINTING WAS FOR COLOR, COORDINATES IS ARRANGED FROM TOP TO BOTTOM ; (if (/= plottype 'colour) ; (setq cords (reverse cords))) ; (vlax-ldata-put $TAMIMI $CORDS cords) ; (print) ; (princ "\n*** COORDINATES HAVE BEEN SAVED ***") ; (print)) ; ) ;open the folder where the pdfs were saved (if (OR (= plottype 'pdf) (= plottype 'jpg)) (openFolder folder) ) ;request to print again in case of other variants (alert "Print a Copy of same project in other variants") (printSet) );progn ) ;(setvar 'filedia 1) ) ;progn (progn (print (strcat "\nNothing has been printed to " zprinter)) (princ) ) ) ) (PRINC (strcat "\n[" zprinter "], [" zpaper "], [" zstyle "]")) ; shows an alert to user ;(a2 zprinter zpaper zstyle plottype) ;******************************************************************************** ; if isHistory is requested the print will be sent directly to Prinset to choose ;******************************************************************************** (if (= :vlax-true isHistory) (printSet) (progn (if (not ss) (progn (setq ss (ssget blocksToSelect)) ) ) (doPrint) ) ) (setvar 'cmdecho cm) (princ) ) ; ******************************************************************* ; SORT-BLOCKS - blocks are sorted according to axis ; top-left blocks are sorted first ; ******************************************************************* (defun sortBlocks(blocks / c1 c2 offset) (setq offset 10) (setq blocks ;(apply 'ssadd (mapcar 'vlax-vla-object->ename (vl-sort (mapcar 'vlax-ename->vla-object blocks) '(lambda (ob1 ob2) (if (vlax-property-available-p ob1 'length) ;identifying polylines T (progn ; if not it's a block (if (vlax-property-available-p ob2 'length) nil (progn (setq c1 (vlax-get ob1 'insertionpoint) c2 (vlax-get ob2 'insertionpoint)) (setq differ (- (getMax (getY c1) (getY c2)) (getMin (getY c1) (getY c2)))) (print (strcat "differ " (rtos differ))) (if (>= differ offset) ; y axis diff by offset (progn (> (getY c1) (getY c2))) (progn (print "same row") (print (strcat "c1:" (rtos (car c1)) " c2:" (rtos (car c2)))) (and (< (getX c1) (getX c2)) ;(> (getY c1) (getY c2)) ) ) ) ) ) ) ;block is found ) ) ) ) ;) ) ;(setq blocks nil) ) (defun getX(cord /) (car cord)) (defun getY(cord /) (cadr cord)) (defun getMin(n1 n2 /) (min (abs n1) (abs n2)) ) (defun getMax(n1 n2 /) (max (abs n1) (abs n2)) ) (defun getDefualtPDFLocation(dwgname / cur_loc) (setq cur_loc (getvar 'dwgprefix) folder (strcat cur_loc dwgname " PDF")) (if (not (vl-file-directory-p folder)) ; no folder is found then, create one (progn (if (vl-mkdir folder) (setq loc folder) (setq loc "") ;default location ) ) ;if exists (progn (setq loc folder) ) ) ) (defun openFolder(folder /) ;(startApp (strcat "explorer /select " folder ", /e")) (startApp (strcat "explorer " "\"" folder "\"")) (princ) ) ; *************************************************************************** ; This function will store the history on every time the file is printed ; *************************************************************************** (defun mark_history(blocks_printed type / entry history_in_file) (setq entry (list (cons 'TIME (getvar 'date)) ;can get the date as we want (cons 'USER (getvar 'loginname)) (cons 'VARIENT type) (cons 'TOTAL (length blocks_printed)) (cons $CORDS blocks_printed) ) ) (if (/= nil (setq history_in_file (vlax-ldata-get $TAMIMI $HISTORY))) (progn ;insert this array to existing (setq history_in_file (cons entry history_in_file)) (vlax-ldata-put $TAMIMI $HISTORY history_in_file) ) (progn ;create new list (vlax-ldata-put $TAMIMI $HISTORY (list entry)) ) ) (princ entry) (princ "\n History is marked") ) (defun c:ld() (load ".\\MyLsp.lsp")) ; *************************************************************************** ; access the printing history ; *************************************************************************** (defun C:hpl(/ all_history view_center view_size view_point maxlength) (defun show_list(/ i entry str entries title) (setq i 1 maxlength 0 entries '() title (strcat "-= HISTORY : " (strcase (substr (drawingName) 1 (- (strlen (drawingName)) 4)) nil) " =-")) (if (/= nil (setq all_history (vlax-ldata-get $TAMIMI $HISTORY))) (progn ;(setq i (length all_history)) ;prepareing array of history (vl-catch-all-apply 'textscr) (foreach entry all_history (progn ;(princ (get $CORDS entry)) (setq str (strcat (itoa i) ". " (get 'VARIENT entry) "(" (itoa (get_length $CORDS entry)) ") - " (get 'USER entry) " " (getDateString (assoc 'TIME entry)) "\n")) (setq entries (cons str entries)) (if (> (strlen str) maxlength) (setq maxlength (strlen str))) (setq i (1+ i)) (princ) ) );foreach ;header (princ "\n\n") (horizontal_line) (header title) (header (strcat "Today:" (getDate))) (header (strcat "Number of pages printed : " (itoa (count_all all_history)))) (horizontal_line) ;list of entries (foreach line (reverse entries) (princ line)) (getInput) );progn if (princ "No History") );if ) (defun getInput(/ selection) (initget (+ 1 2 4)) (setq selection (getint (strcat "\nSelect an item : ")) selection (1- selection)) (if (AND (> selection -1) (/= nil (nth selection all_history))) (progn (doEntry (nth selection all_history) selection) ) (progn (princ "\nInvalid selection.") (getInput) ) ) (princ) ) (defun doEntry(entry index / ans cmdline) (terpri) (setq cmdline (strcat "-> " (itoa (1+ index)) ". " (get 'VARIENT entry) "(" (itoa (get_length $CORDS entry)) ") - " (get 'USER entry) " " (getDateString (assoc 'TIME entry)))) ;Print output (terpri) (princ (getLines (strlen cmdline) "*")) (terpri) (princ cmdline) (terpri) (princ (getLines (strlen cmdline) "*")) (initget "Back Print Delete Next") (setq ans (getreal "\nChoose an option [<= Back/Print/Delete/Next =>] <Esc>: ")) (cond ((= ans "Print") (ph_core (cdr (assoc $CORDS entry)))) ((= ans "Delete") (delete_entry index)) ((= ans "Back") (show_list)) ((= ans "Next") (progn (if (/= nil (nth (1+ index) all_history)) (doEntry (nth (1+ index) all_history) (1+ index)) (show_list)) )) ;default is to exit the function ((exit)) ) ) ;to-do: have to commit all_history (defun delete_entry(index / ind) (setq ind -1) (setq all_history (vl-remove-if (function (lambda (item) (= index (setq ind (1+ ind))) ) ) all_history)) ;commiting all changes (if (vlax-ldata-put $TAMIMI $HISTORY all_history) (princ "\nDeleted Successfully.") (princ "\nError!")) (show_list) ) ;get elements from the array (defun get(key array / rt) ;(princ (assoc key array)) (if (/= nil (setq rt (cdr (assoc key array)))) (vl-princ-to-string rt) "*" ) ) ;formats the date (defun getDateString(dt /) (setq dt (cdr dt)) ; (TIME . value) -> cdr -> value (coz it's a associative) (if (= (type dt) 'REAL) (progn (strcat (menucmd (strcat "m=$(edtime," (rtos dt) ",D-MON-YY (DDD) HH:MM AM/PM)")) (date_string dt)) ) dt ) ) ;get number of coordinates stored (defun get_length(key array / rt) ;(princ (assoc key array)) (if (/= nil (setq rt (cdr (assoc key array)))) (length rt) 0 ) ) ;print header text (defun header(txt /) (setq spanning_thrushold (/ (- maxlength (strlen txt)) 2)) (princ (strcat (getLines spanning_thrushold " ") txt)) (terpri) ) ;prints horizontal lines of * (defun horizontal_line(/) (princ (getLines maxlength "*")) (terpri) ) ;count papers in total so far (defun count_all(array /) (apply '+ (mapcar '(lambda (x) (length (cdr (assoc $CORDS x))) ) array ) ) ) ;print header patterns (defun getLines(len pat / tmp) (progn ;(setq tmp (cons "\n" tmp)) (repeat len (setq tmp (cons pat tmp))) ) (apply 'strcat tmp) ) (defun date_string(date_p / today ret) ;total days between 2 dates (setq today (splitdate_elements (getvar 'date))) (setq date_p (splitdate_elements date_p)) (cond ((= date_p today) " [Today] *" ) ((< (- today date_p) 2) " [Yesterday]" ) ((< (- today date_p) 8) " [This week]" ) ((< (- today date_p) 31) " [This Month]" ) ) ) (defun splitdate_elements(date / date_str date_elements_array) (setq date_str (menucmd (strcat "m=$(edtime," (rtos date) ",D-M-YYYY)"))) (setq date_elements_array (split date_str)) ;date will be as an ;(print date_elements_array) ;total (apply '+ (mapcar '(lambda (x y) (* x (atoi y)) ) '(1 30 365) date_elements_array) ) ) (defun split(str / arr pos) (setq arr (if (setq pos (vl-string-search "-" str)) (cons (substr str 1 pos) (split (substr str (+ 2 pos)))) (list str) ) ) ) ; (defun capture_zoom(/) (setq view_center (getvar 'VIEWCTR) view_size (getvar 'VIEWSIZE) view_point (trans '(0 0 1) 0 1)) ) (show_list) (princ) ) ;"(" (itoa (assoc 'TOTAL entry)) ") - " (assoc 'USER entry) " " (assoc 'TIME entry)))) ; ******************************************************************* ; Plotter : core function which helps to plot to printer ; ******************************************************************* ; a1 - printer ; a2 - paper ; a3 - style ; a4 - bl coordinates ; a5 - tr coordinates ; a6 - plot to file name ; a7 - orientation (defun plotter(a1 a2 a3 a4 a5 a6 /) ; never change this function ;(princ (strcat a6)) (print (list a4 a5)) (command "-plot" "y" "" a1 a2 "m" "l" "n" "w" a4 a5 "f" "c" "y" a3 "y" "" a6 "y" "y") ; command ) (defun plotterj(a1 a2 a3 a4 a5 a6 /) ; jpeg plotter ; never change this function ;(princ (strcat a6)) (command "-plot" "y" "" a1 a2 "l" "n" "w" a4 a5 "f" "c" "y" a3 "y" "" a6 "y" "y") ; command ) ; INCLUDED TO PRINT IN DIFFERENT ORIENTATION style_______ _____ coordinates paper_____ | | ______ plot name or pdf printer__ | | | | ______ orientation | | | | | | (defun plotter2(a1 a2 a3 a4 a5 a6 a7 /) ; never change this function ;(princ (strcat a6)) (command "-plot" "y" "" a1 a2 "m" a7 "n" "w" a4 a5 "f" "c" "y" a3 "y" "" a6 "y" "y") ; command ) ;************************************ ;NOTIFY USER ABOUT THE PRINT CAPABILITY ;**************************************** (setq temparrayref (vlax-ldata-get "TAMIMI" "COORDINATES")) (if (/= temparrayref nil) (print (strcat "This file supports printing from history! of " (itoa (length temparrayref)) " blocks to print"))) ;***************************************** ;PRINT USING COORDINATES SAVED IN THE FILE ;***************************************** (defun c:ph(/) (ph_core nil) ) (defun ph_core(_cords / cords i j blocks temp echo missing t_missing) (if (= nil _cords) (setq cords (vlax-ldata-get $TAMIMI $CORDS)) (progn (setq cords _cords) (vl-catch-all-apply 'graphscr) ) ) ;common variables (setq i 0 j i missing 0) (util:activateCmdecho) (if (/= cords nil) (progn (foreach pair cords (progn (setq i (1+ i)) ;counter increment ;array blocks is empty (if (= blocks nil) (progn (setq blocks (ssget "_C" (trans (car pair) 0 1) (trans (last pair) 0 1) blocksToSelect)) (if (= nil blocks) (progn (print "No blocks were found!") (1+ missing)) ) ;(print (strcat "Selection: " (itoa i) " ---- SET " (itoa (sslength blocks))))) ;(print) ) ;array blocks is not empty (progn (setq temp (ssget "_C" (trans (car pair) 0 1) (trans (last pair) 0 1) blocksToSelect)) ;(setq blocks (ssget "_W" '(19452.9 -36086.5 -1.0e-008) '(19490.2 -36058.9 1.0e-008) (list (cons 0 "INSERT")))) (if (or (= nil temp) (< (sslength temp) 0)) (progn (setq missing (1+ missing)) (print "Selection is empty") ) (progn (print (strcat "TEMP COUNT: " (itoa (sslength temp)))) (print (strcat "Selection: " (itoa i) " ---- OBJECTS COUNT " (itoa (sslength temp)))) (repeat (setq n (sslength temp)) (print (strcat "repeat # " (itoa n))) (setq obj (ssname temp (setq n (1- n)))) (if (= nil obj) (print "block is missing") (setq blocks (ssadd obj blocks)) ) ) ) ) ) ) ) ) ; check detected object whether selected correctly or not ;(command "erase" blocks "") (command "zoom" "_object" blocks "") (princ "\n*** Print Back Feature ***\n") (command "_.SELECT" blocks) ;(sssetfirst nil blocks) (setq pre_selection_length (sslength blocks)) ; no of blocks have been selected BEFORE user selection ;(princ "Select / remove blocks: ") (if (> missing 0) (setq t_missing (strcat "[" (itoa missing) " block/s not found]")) (setq t_missing "")) (princ (strcat "Select / remove blocks " t_missing ": ")) (while (> (getvar 'cmdactive) 0) (command pause) (setq blocks (ssget "_P" blocksToSelect)) ) (setq post_selection_length (sslength blocks)) ; no of blocks have been selected AFTER user selection (setq ans (getstring (strcat "\n*** Found " (itoa (sslength blocks)) " blocks, Continue (Y/N) <N>: "))) (cond ((= (strcase ans nil) "Y") (progn ; (if (> post_selection_length pre_selection_length) ; (progn ; (setq cont (getstring "\n::: Sort-Blocks? (Yes/No) <N>: ")) ; (if (= (strcase cont nil) "Y") ; (progn ; (setq blocks (sortBlocks (vl-remove-if 'listp (mapcar 'cadr (ssnamex blocks))))) ; sort blocks ; (print "Sorted")) ; ) ; ) ; ) (setq f_cpi 'xerox zstyle "for black.ctb" zprinter pXerox zpaper "A3 (297 x 420mm)") (p2 zprinter zpaper zstyle 'black blocks :vlax-true (if (OR (> post_selection_length pre_selection_length) (< post_selection_length pre_selection_length) ) :vlax-true :vlax-false)) ) ) );cond ) (progn (alert " * No saved coordinates have been found! *")) ) ;(setvar 'cmdecho echo) (util:restoreCmdecho) ) ; ******************************************************************* ; Rorate multiple objects aroud its base point ; ******************************************************************* (defun c:r2(/ sel o e rot osm *error* error_bak ce) (setq osm (getvar 'osmode) error_bak *error* ce (getvar 'cmdecho)) (setvar 'osmode 0) (setvar 'cmdecho 0) (defun *error* (msg /) ;ON ERROR (if (not (member msg '("Function cancelled"))) (print msg)) (setvar 'osmode osm) (setvar 'cmdecho ce) (setq *error* error_bak) ) ; backing up osmode varplpklpl1 (defun rotateObj(blocks angle / i entity) ;(print (strcat (itoa (sslength blocks)) "-" (itoa angle))) (setq i 0) (while (< i (sslength blocks)) (setq obj (ssname blocks i) entity (entget obj) i (1+ i)) (command "_rotate" obj "" (cdr (assoc 10 entity)) angle) );while ) ;restoring object snap mode value ;to-do : memory caching of angle (defun selectObj(/ blocks angle_input) (if (setq blocks (ssget '((0 . "INSERT")))) (progn ;setting global angle for memory (if (not g_angle) (setq g_angle 90)) (while (princ (strcat "\r\r>> Angle to rotate <" (itoa g_angle) "\\U+00B0>: ")) (if (not (setq angle_input (getint ""))) (setq angle_input g_angle) (setq g_angle angle_input)) (rotateObj blocks angle_input) );while );progn ) ) (selectObj) (setvar 'osmode osm) (princ) ) ; ******************************************************************* ; Converts multiple LINES into POLYLINES ; JOINS converted polylines, inorder to make them compatible with multiline command ; ******************************************************************* (defun c:F4(/ sset ans) (setq ans "Y") (if (setq sset (ssget (list (cons 0 "LINE")))) (command "_.PEDIT" "M" sset "" "Y" "J" "0.0" "") ; (progn ; (setq ans (strcase (getstring "\nJoin polylines (Yes/No) <Y>: ") nil)) ; (if (OR (eq ans "Y") (eq ans "")) ; (command "_.PEDIT" "M" sset "" "Y" "J" "0.0" "") ; (command "_.PEDIT" "M" sset "" "Y" "") ; ) ; ) ) (princ) ) ; ******************************************************************* ; Prints X Y Coordinates to the lable ; COMMAND : P1 ; ******************************************************************* (defun c:p1 (/ p x y ptcoord textloc) (while ;start while (setq p (getpoint "Pick Point: ") textloc (getpoint p "Pick Text Location")) (setq x (rtos (car p)) y (rtos (cadr p))) (setq ptcoord (strcat "x=" x ", " "y=" y)) (command "_leader" p textloc "" ptcoord "") (princ) ) ;end while ) ; ******************************************************************* ; Change MTEXT STEXT Text Continuously ; COMMAND : T4 ; ; changing the function to support nested texts ; ******************************************************************* (defun c:T4(/ usertext sel) ;(setq usertext (strcase (getstring "\nText to Replace: ") nil)) (princ "*** Source Text ***") (setq obj (vlax-ename->vla-object (ssname (ssget "_+.:E:S" '((0 . "*TEXT"))) 0))) (setq usertext (vlax-get obj 'TextString)) (princ "*** Select Text to Replace ***") (while (setq sel (ssget "_+.:E:S" '((0 . "*TEXT")))) (progn (if (> (sslength sel) 0) (progn (setq name (ssname sel 0)) (setq p (vlax-ename->vla-object name)) (vlax-put p 'TextString usertext) ) ) ) ) (defun pasteSingle(ename_text /) (setq p (vlax-ename->vla-object ename_text)) (vlax-put p 'TextString usertext) (princ) ) ;bl_def will be the output of ssnamex (defun pasteInBlock(bl_def /) (setq bs (car (nentselp bs (caddr bl_def)))) (if (/= nil bs) (pasteSingle bs) ) (princ) ) ) (defun c:pt(/ source_objects dest_objects) (print) (setq source_objects nil dest_objects nil limit_thrushold 2 lower_thrushold 0) (defun selectSourceObjects() (princ "\r*** Select Texts ***") (setq source_objects (ssget '((0 . "*TEXT")))) (if (> (sslength source_objects) lower_thrushold) (progn (setq source_objects (sort source_objects) ; sort top to bottom limit_thrushold (length source_objects)) (selectDestinationObjects) ) (selectSourceObjects)) ) (defun selectDestinationObjects() (princ "\r*** Select Texts to replace ***") (setq dest_objects (ssget '((0 . "*TEXT")))) (if (= (sslength dest_objects) limit_thrushold) (progn (setq dest_objects (sort dest_objects)) ; sort top to bottom (pastTexts) ) (selectDestinationObjects)) ) (defun sort(blocks /) (setq sorted_blocks (vl-sort (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex blocks))) ) (function (lambda (x y) ; logic to sort (> (cadr (vlax-get x 'insertionpoint)) (cadr (vlax-get y 'insertionpoint)) ) )) ) ) ) (defun deleteSource() (setq cont (getstring "\n::: Delete source texts ? (Yes/No) <Y>: ")) (if (not (= (strcase cont nil) "N")) (progn (foreach obj source_objects (vla-delete obj))) ) ) (defun pastTexts(/ i) (setq i 0) (repeat (length source_objects) (progn (vlax-put (nth i dest_objects) 'TextString (vlax-get (nth i source_objects) 'TextString)) (setq i (1+ i)) ) ) (deleteSource) (closeRefEdit) (princ) ) (defun closeRefEdit() (if (/= (getvar 'refeditname) "") (command "_.refclose" "_save")) ) (selectSourceObjects) ) ; ******************************************************************* ; Clear the saved data on vlax-ldata ; COMMAND : CL - CROSS-FENCE ; ******************************************************************* (defun c:clr(/) (defun getArray() (princ "\nSearching for Records...") (vlax-ldata-get $TAMIMI $CORDS) ) (if (getArray) (progn (princ "\nRecords found.") (setq cont (getstring "\n::: Delete coordinates from file ? (Yes/No) <Y>: ")) (if (not (= (strcase cont nil) "N")) (progn (vlax-ldata-delete $TAMIMI $CORDS) (princ "\nRecords has been cleared.") ) ) ) (princ "\nNo Records.") ) (princ) ) ; ******************************************************************* ; Draw Cross Lines ; COMMAND : CL - CROSS-FENCE ; ******************************************************************* (defun c:CF( / ent p1 p2 ar) (if (setq p1 (getpoint "\nRectanle Start: ")) (progn (setq p2 (getcorner p1 "\nRectangle End: ")) (command "rectangle" p1 p2) ;(setq cords (group2 (vlax-get ent 'coordinates))) (setq ent (vlax-ename->vla-object (entlast))) (setq ar (group2 (vlax-get ent 'coordinates))) (print ar) (vla-addline acSpace (vlax-3d-point (car ar)) (vlax-3d-point (caddr ar))) (vla-addline acSpace (vlax-3d-point (cadr ar)) (vlax-3d-point (cadddr ar))) (set 'an "") (if (= (setq an (strcase (getstring "\nDelete Rectangle [Y/N] <N>: ") nil)) "Y") (vla-delete ent)) ) ) (princ) ) (defun group2 ( l / r ) ;(print (itoa (length l))) (repeat (/ (length l) 2) ;(print l) (setq r (cons (trans (list (car l) (cadr l)) 0 1) r) l (cddr l) ) (print l) ) ;repeat (reverse r) ) (defun setClipText(str / html result) (if (= 'STR (type str)) (progn (setq html (vlax-create-object "htmlfile") result (vlax-invoke (vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData) 'setData "Text" str) ) (vlax-release-object html) str ) );end if ) (defun c:cpp(/) (setClipText (strcat (getvar "dwgprefix") (getvar "dwgname"))) ) ;ENTGET FUNCTION GIVES ARRAY OF THE ENTITY PROPERTIES (defun c:sn(/) (setvar 'cmdecho 1) (defun sortBlocks2(blocks / func getAxis p1 p2) ;(and (setq p1 (getpoint "\nPick first point: ")) (setq p2 (getpoint p1 "\nPick second point: ")) ;setting base axis (if (= (getX p1) (getX p2)) (setq getAxis getY) (setq getAxis getX)) (if (OR (AND (= getAxis getX) (< (getX p1) (getX p2))) (AND (= getAxis getY) (< (getY p1) (getY p2)))) (setq func <) (setq func >) ) (setq blocks ;(apply 'ssadd ;(mapcar 'vlax-vla-object->ename (vl-sort (mapcar 'vlax-ename->vla-object blocks) '(lambda (ob1 ob2) (setq c1 (vlax-get ob1 'insertionpoint) c2 (vlax-get ob2 'insertionpoint)) (func (getAxis c1) (getAxis c2)) ) ) ;) ;) ) ) (defun pasteMulti(/ ss sorted_blocks) (print "MultiMode") (setq ss (ssget '((0 . "INSERT") (2 . "BLOCK_STAIR_NO")))) (setq sorted_blocks (sortBlocks2 (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))) ;sorted_blocks (print (itoa (length sorted_blocks))) (foreach obj sorted_blocks (progn (setNumber obj)) ) (princ) (exit) ) (defun modeSingle(/ rtn) (while (princ) (initget "M N") (setq rtn (entsel "\nSelect Stair Attribute or [Multiple]:")) ; if redirect to multi then it will be exited from function (cond ((= rtn "M") (pasteMulti)) ((if (and (/= rtn nil) (setq ve (vlax-ename->vla-object (car rtn))) (= (vla-get-objectname ve) "AcDbBlockReference")) (progn (setNumber ve) ) (modeSingle) )) ) ) (princ) ) (defun setNumber(obj /) (mapcar '(lambda (at) (if (= (vla-get-tagstring at) "STAIR_NO") (progn (vla-put-TextString at (itoa *num*)) (setq *num* (1+ *num*))) ) ) ; applying fucntion to (vlax-invoke obj 'GetAttributes)) ) (defun getNumber(/) ; DEFAULT VALUE IF NOT SET (if (not *num*) (setq *num* 1)) (if (> (setq sn (getint (strcat "\nCounting From <" (itoa *num*) ">:"))) 0) (setq *num* sn) (princ (strcat " Invalid Number, Counting From " (itoa *num*))) ) (modeSingle) (princ) ) (getNumber) ) (defun c:vp() (if (not *act*) (progn (setq *act* 0))) (if (= *act* 1) (progn (ai_tiledvp 1 "_V") (setq *act* 0)) (progn (ai_tiledvp 2 "_V") (setq *act* 1) (princ "*** VIEWPORT ACTIVE")) ) (princ) ) (defun c:xh(/) (command "_xline" "_H") ) (defun c:xv(/) (command "_xline" "_V") ) ; DEBUG - IMPLEMENTING NEW MJJ ; WISH ME (defun c:MK ( / cm e1 e2 i1 i2 il m1 m2 o1 o2 p1 ss ml_start ml_end ml_cir_int ml_cross_line ml_cord cords) (setq acApp (vlax-get-acad-object)) (setq acDoc (vla-get-ActiveDocument acApp)) (setq acSpace (vla-get-ModelSpace acDoc)) ;(SETQ cords '()) (defun trimThisTree(p1 o1 o2 /) (setq m1 (group3 (vlax-get o1 'coordinates)) m2 (group3 (vlax-get o2 'coordinates))) (if (< (min (distance p1 (car m1)) (distance p1 (last m1))) (min (distance p1 (car m2)) (distance p1 (last m2))) ) (command "_.-mledit" "_OT" (list e1 (car il)) (list e2 (cadr il)) "") (command "_.-mledit" "_OT" (list e2 (car il)) (list e1 (cadr il)) "") ) ) (vla-StartUndoMark acDoc) (if (setq ss (ssget "_:L" '((0 . "MLINE")))) (progn (setq cm (getvar 'cmdecho)) (setvar 'cmdecho 0) (repeat (setq i1 (sslength ss)) (setq e1 (ssname ss (setq i1 (1- i1))) o1 (vlax-ename->vla-object e1) ; ml_start (car (group3 (vlax-get o1 'coordinates))) ; ml start coordinates ; ml_end (last (group3 (vlax-get o1 'coordinates))) ; ml_cord '() ; ml_cord (cons ml_start ml_cord) ; ml_cord (cons ml_end ml_cord) ) (repeat (setq i2 i1) (setq e2 (ssname ss (setq i2 (1- i2))) o2 (vlax-ename->vla-object e2) il (group3 (vlax-invoke o1 'intersectwith o2 acextendnone)) ) ;(princ il) (if (/= il nil) (progn (foreach point il (progn (if (not (member point cords)) (setq cords (cons point cords))) ) ) ) ) ;(princ (strcat "\nINTERSECT: " )) (princ il) ;(princ cords) ; (foreach cor ml_cord ; (progn ; (if (AND (/= il nil) (not (member cor il)) (>= (distance cor (car il)) 0.15)) ; (progn ; (setq tempcircle (vla-addcircle acSpace (vlax-3d-point (trans cor 0 1)) 0.1) ; ml_cir_int (group3 (vlax-invoke o1 'intersectwith tempcircle acextendnone)) ; ) ; (if ml_cir_int ; (setq ml_cross_line (vla-addline acSpace (vlax-3d-point (car ml_cir_int)) (vlax-3d-point (last ml_cir_int)))) ; ) ; ;(princ (car ml_cir_int)) ; ;(princ (last ml_cir_int)) ; (vla-delete tempcircle) ; ) ; ) ; ) ; ) (cond ( (= 1 (length il)) (command "_.-mledit" "_CJ" (list e1 (car il)) (list e2 (car il)) "") ) ( (= 4 (length il)) (print (distance (car il) (cadr il))) (if (> (distance (car il) (cadr il)) 0.3) (progn (trimThisTree (car il) o1 o2) ;(trimThisTree (car il) o1 o2) ; trims first pair (princ (cadr il))) (command "_.-mledit" "_OC" (list e1 (car il)) (list e2 (cadr il)) "") ) ) ( (= 2 (length il)) (setq p1 (car il) m1 (group3 (vlax-get o1 'coordinates)) m2 (group3 (vlax-get o2 'coordinates)) ) (if (< (min (distance p1 (car m1)) (distance p1 (last m1))) (min (distance p1 (car m2)) (distance p1 (last m2))) ) (command "_.-mledit" "_OT" (list e1 (car il)) (list e2 (cadr il)) "") (command "_.-mledit" "_OT" (list e2 (car il)) (list e1 (cadr il)) "") ) ) ) ) ) (setvar 'cmdecho cm) ; FILLING LINES ; checks each ml coordinates to elimate the corners which intersects with other mls (repeat (setq i1 (sslength ss)) (setq e1 (ssname ss (setq i1 (1- i1))) o1 (vlax-ename->vla-object e1) ml_start (car (group3 (vlax-get o1 'coordinates))) ; ml start coordinates ml_end (last (group3 (vlax-get o1 'coordinates))) ml_cord '() ml_cord (cons ml_start ml_cord) ml_cord (cons ml_end ml_cord) ) (foreach cor ml_cord ; MAX WOULD COME 2 POINTS (progn (if (AND (/= cor nil) (not (member cor cords))) (progn (setq tempcircle (vla-addcircle acSpace (vlax-3d-point (trans cor 0 1)) (/ (getvar 'CMLSCALE) 2)) ml_cir_int (group3 (vlax-invoke o1 'intersectwith tempcircle acextendnone)) ) (if ml_cir_int (setq ml_cross_line (vla-addline acSpace (vlax-3d-point (car ml_cir_int)) (vlax-3d-point (last ml_cir_int)))) ) ;(princ (car ml_cir_int)) ;(princ (last ml_cir_int)) (vla-delete tempcircle) ) ) ) ) ) ) ) (vla-EndUndoMark acDoc) (princ) ) ; ************************************************************ ; HANDLES REPLACING AREA AND PERIMETER LENGTH ; ************************************************************ (defun c:apt(/ i sel) (util:activateCmdecho) (setq sel (ssget "_+.:E:S")) ; selecting single entity (if (= (sslength sel) 1) (progn (command "_.AREA" "_Object" (ssname sel 0) "") (princ (strcat "AREA: " (rtos (getvar 'area) 2 2) "\n")) ; 2 decimal 2 no of precision (princ (strcat "LENGTH: " (rtos (getvar 'perimeter) 2 2) "\n")) ; 2 decimal 2 no of precision (setq i 1) (while (setq lst (ssget "_+.:E:S" (list '(0 . "TEXT,MTEXT")))) (setq obj (ssname lst 0)) (setq p (vlax-ename->vla-object obj)) (cond ((= i 1) (vla-put-TextString p (rtos (getvar 'area) 2 2)) ) ((= i 2) (vla-put-TextString p (strcat (rtos (getvar 'perimeter) 2 0) ".00 M")) ) (progn (exit)) ) (setq i (1+ i)) ) ) (princ "No object is selected!") ) (util:restoreCmdecho) ) ;erasing mlines (defun c:rl(/ wlines) (setq wlines (ssget '( (-4 . "<AND") (0 . "MLINE") (8 . "WAL") (-4 . "AND>")) )) (command "_.erase" wlines "") (princ) ) ; ************************************************************ ; UTILITY ZONE ; ************************************************************ (defun util:activateCmdecho(/) (setq *echo* (getvar 'cmdecho)) (setvar 'cmdecho 0) ) (defun util:restoreCmdecho(/) (setvar 'cmdecho *echo*) ; (if (not *echo*) ; (setvar 'cmdecho 1) ; (setvar 'cmdecho *echo*)) (princ) ) (defun drawingName(/) (getvar 'dwgname)) (defun drawingPath(/) (getvar 'dwgprefix)) (defun get_file_size(/ rtn) (setq file (strcat (drawingPath) (drawingName))) (setq rtn (/ (vl-file-size file) 1024)) ) (defun markLastPrint(/) (vlax-ldata-put "TAMIMI" "date" (getDate)) (princ (strcat "\nPrinted on " (getDate))) ) (defun getDate(/ date) (setq date (menucmd "m=$(edtime,$(getvar, date), d\",\" DDDD HH:MM AM/PM)")) ) (setq ind 0) (defun progress_ind(/ chars) (setq chars '("\r-" "\r\\" "\r|" "\r\/")) ;(repeat 40 (princ (nth ind chars)) (setq ind (rem (1+ ind) (length chars))) ;) (princ) ) ; ************************************************************ ; FILE INFO : DESCRIBE THE FILE ; ************************************************************ (defun c:fi(/) (princ) (defun init(/) ; get dialog definition and load dialog (setq dialog "fileinfo" ddef (load_dialog "./dialog.dcl")) (if (> ddef 0) ; have dialogs (progn (if (not (new_dialog dialog ddef)) (exit)) (bind) (start_dialog) (unload_dialog ddef) ) ) ) (defun bind(/) ; buttons (action_tile "key_close" "(done_dialog)") (action_tile "key_audit" "(done_dialog)") (bindInfo) (princ "bind...") ) (defun bindInfo(/) ; set data to variables (set_tile "key_opened" (menucmd "m=$(edtime,$(getvar, date), d\",\" DDDD HH:MM AM/PM)")) (set_tile "key_drawing" (drawingName)) (set_tile "key_location" (drawingPath)) (princ) ) (init) ) ;prompt user for input (defun getPrompt(msg / rt) (setq rt (strcase (getstring msg) nil)) ) ; ************************************************************ ; END OF FILE ; ************************************************************ (princ (strcat "\n\n**************************************************************************" "\n:: MyLsp.lsp | Version " MYVER " | \\U+00A9 Mohamedh Asrin " (menucmd "m=$(edtime,0,yyyy)") " Al-Tamimi Khafji ::" "\n :: Provides a bunch of useful AUTOCAD functions ::" "\n************************************************************************** " ;"\n \\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1" "\n \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2557 " "\n \\U+2588\\U+2588\\U+2554\\U+2550\\U+2550\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2588\\U+2554\\U+2550\\U+2550\\U+2550\\U+255D \\U+2588\\U+2588\\U+2554\\U+2550\\U+2550\\U+2588\\U+2588\\U+2551 \\U+2588\\U+2588\\U+2554\\U+2550\\U+255D \\U+2588\\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2551 " "\n \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2551 \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2554\\U+2550\\U+255D \\U+2588\\U+2588\\U+2551 \\U+2588\\U+2588\\U+2554\\U+2588\\U+2588\\U+2557\\U+2588\\U+2588\\U+2551 " "\n \\U+2588\\U+2588\\U+2554\\U+2550\\U+2550\\U+2588\\U+2588\\U+2551 \\U+255A\\U+2550\\U+2550\\U+2550\\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2554\\U+2550\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2551 \\U+2588\\U+2588\\U+2551\\U+255A\\U+2588\\U+2588\\U+2588\\U+2588\\U+2551 " "\n \\U+2588\\U+2588\\U+2551 \\U+2588\\U+2588\\U+2551 \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2554\\U+255D \\U+2588\\U+2588\\U+2551 \\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2588\\U+2557 \\U+2588\\U+2588\\U+2551 \\U+255A\\U+2588\\U+2588\\U+2588\\U+2551 " "\n \\U+255A\\U+2550\\U+255D \\U+255A\\U+2550\\U+255D \\U+255A\\U+2550\\U+2550\\U+2550\\U+2550\\U+2550\\U+255D \\U+255A\\U+2550\\U+255D \\U+255A\\U+2550\\U+255D \\U+255A\\U+2550\\U+2550\\U+2550\\U+2550\\U+2550\\U+255D \\U+255A\\U+2550\\U+255D \\U+255A\\U+2550\\U+2550\\U+255D " ;"\n \\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1\\U+25AB\\U+25A1" ) ) (princ) (print) (princ (strcat "FILE @ " (getDate))) (PRINT)
90,938
Common Lisp
.l
2,705
26.708318
422
0.512186
asrin475/Lisp-Tamimi
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
196598e8f63b1acda537b737d7a6f32d3337315923752442e4a146ce9cf4f443
20,033
[ -1 ]
20,051
sample_3.lisp
smaster0517_Tiny-Lisp/Lisp Codes/sample_3.lisp
(let((len 1)) (reduce (lambda (x y) (setq len (+ len 1)) ) '(csce 4430 is easy using lisp) )
122
Common Lisp
.lisp
7
12.285714
36
0.474138
smaster0517/Tiny-Lisp
2
1
1
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
f048a46c1d9458af6214bfe5cee7a8b52424b801f11adc9a7ce8eab8b2b96798
20,051
[ -1 ]
20,052
sample_7.lisp
smaster0517_Tiny-Lisp/Lisp Codes/sample_7.lisp
(defun funcc (mylist) (cond ((null mylist) mylist) ((and (eq (car mylist) (cadr mylist)) (eq (car mylist) (caddr mylist))) (funcc (cdr mylist))) ((eq (car mylist) (cadr mylist)) (cons (car mylist) (funcc (cddr mylist)))) (T (funcc (cdr mylist))) ) ) (funcc '(a b a a a c c))
286
Common Lisp
.lisp
9
29.666667
95
0.618705
smaster0517/Tiny-Lisp
2
1
1
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
a63000e2136b34f162db630ac28b443b2dd9e29fa62d217d3a91ddb5ca62f0ee
20,052
[ -1 ]
20,053
sample_8.lisp
smaster0517_Tiny-Lisp/Lisp Codes/sample_8.lisp
(defun funcd (mylist mycount) (cond ((null mylist) mylist) ((null (cdr mylist)) (list (list (+ mycount 1) (car mylist)))) ((eq (car mylist) (cadr mylist)) (funcd (cdr mylist) (+ mycount 1))) (T (cons (list (+ mycount 1) (car mylist)) (funcd (cdr mylist) 0))) ) ) (funcd '(a b a a a c c) 0)
306
Common Lisp
.lisp
9
31.333333
70
0.597315
smaster0517/Tiny-Lisp
2
1
1
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
aefc1cdf0cf19a54f372d704ab04d4b27a0911f0b6fe50928607e6124669c15c
20,053
[ -1 ]
20,054
sample_4.lisp
smaster0517_Tiny-Lisp/Lisp Codes/sample_4.lisp
(reduce (lambda (x y)(cond ((atom x) (list y x)) (t (cons y x)))) '(e s c t n u))
81
Common Lisp
.lisp
1
81
81
0.518519
smaster0517/Tiny-Lisp
2
1
1
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
babee9aa18e270f12812a337d4dde35d49e64cd5431cf44d4fd0888547cf4d03
20,054
[ -1 ]
20,055
sample_5.lisp
smaster0517_Tiny-Lisp/Lisp Codes/sample_5.lisp
(defun funca (mylist) (cond ((null mylist) mylist) ((eq (car mylist) (cadr mylist)) (funca (cdr mylist))) (T (cons (car mylist) (funca (cdr mylist)))) ) ) (funca '(a b a a a c c))
188
Common Lisp
.lisp
8
21.5
56
0.61326
smaster0517/Tiny-Lisp
2
1
1
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
1db35924b81ac1c5c952959ff727841cd86f63ca988604189c16e908e93e9ea8
20,055
[ -1 ]
20,056
sample_6.lisp
smaster0517_Tiny-Lisp/Lisp Codes/sample_6.lisp
(defun funcb (mylist) (cond ((null mylist) mylist) ((and (eq (car mylist) (cadr mylist)) (eq (car mylist) (caddr mylist))) (funcb (cdr mylist))) ((eq (car mylist) (cadr mylist)) (funcb (cddr mylist))) (T (cons (car mylist) (funcb (cdr mylist)))) ) ) (funcb '(a b a a a c c))
286
Common Lisp
.lisp
9
29.555556
95
0.620939
smaster0517/Tiny-Lisp
2
1
1
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
44eda335e16ac5d76e9e6374a2bdcef35208e24cef051226b813b753379bbf6f
20,056
[ -1 ]
20,080
PROJECT_LANG_1.lisp
seanpm2001_Learn-LISP/PROJECT_LANG_1.lisp
; Start of script ; Project language file 1 ; For: seanpm2001/Learn-Lisp ; About: ; I decided to make Lisp the main project language file for this project (Seanpm2001/Learn-Lisp) as Lisp is the language this project is dedicated to, because this project is about learning the Lisp programming language. It only makes sense to Lisp the official language for this project. It is getting its own project language file, starting here. (print "Project language file 1") (print "For: seanpm2001/Learn-Lisp") (print "About:") (print "I decided to make Lisp the main project language file for this project (Seanpm2001/Learn-Lisp) as Lisp is the language this project is dedicated to, because this project is about learning the Lisp programming language. It only makes sense to Lisp the official language for this project. It is getting its own project language file, starting here.") ; File info ; File type: Lisp source file (*.lsp *.lisp) ; File version: 1 (2022, Friday, November 4th at 12:55 am PST) ; Line count (including blank lines and compiler line): 19 ; End of script
1,075
Common Lisp
.lisp
14
75.5
356
0.783349
seanpm2001/Learn-LISP
2
1
0
GPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
70e33172a778d8620aef87c831eee692deafd1d0a60da84737eafbbd393a0451
20,080
[ -1 ]
20,139
package.lisp
lhope_cl-czmq/src/package.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-user) (defpackage :cl-czmq (:documentation "A re-binding of the C binding for the zmq transport layer (czmq).") (:use :cl) (:nicknames :czmq) (:export ;; czmq #:+czmq-version-major+ #:+czmq-version-minor+ #:+czmq-version-patch+ #:+czmq-version+) (:export ;; zsys #:zsys-set-retry ;; * #:zsys-retry ;; * #:with-zsys-retry ;; * #:zsys-errno ;; * #:zsys-strerror) ;; * (:export ;; zctx #:zctx-new #:zctx-destroy #:with-zctx ;;* #:zctx-shadow #:zctx-set-iothreads #:zctx-set-linger #:zctx-set-hwm #:zctx-hwm #:zctx-underlying #:zctx-interrupted #:zctx-test) (:export ;; zsockopt #:zsocket-type #:zsocket-sndhwm #:zsocket-rcvhwm #:zsocket-affinity #:zsocket-identity #:zsocket-rate #:zsocket-recovery-ivl #:zsocket-sndbuf #:zsocket-rcvbuf #:zsocket-linger #:zsocket-reconnect-ivl #:zsocket-reconnect-ivl-max #:zsocket-backlog #:zsocket-maxmsgsize #:zsocket-multicast-hops #:zsocket-rcvtimeo #:zsocket-sndtimeo #:zsocket-ipv4only #:zsocket-rcvmore #:zsocket-fd #:zsocket-events #:zsocket-last-endpoint #:zsocket-set-sndhwm #:zsocket-set-rcvhwm #:zsocket-set-affinity #:zsocket-set-subscribe #:zsocket-set-unsubscribe #:zsocket-set-identity #:zsocket-set-rate #:zsocket-set-recovery-ivl #:zsocket-set-sndbuf #:zsocket-set-rcvbuf #:zsocket-set-linger #:zsocket-set-reconnect-ivl #:zsocket-set-reconnect-ivl-max #:zsocket-set-backlog #:zsocket-set-maxmsgsize #:zsocket-set-multicast-hops #:zsocket-set-rcvtimeo #:zsocket-set-sndtimeo #:zsocket-set-ipv4only #:zsocket-set-delay-attach-on-connect #:zsocket-set-router-mandatory #:zsocket-set-router-raw #:zsocket-set-xpub-verbose #:zsocket-set-hwm #:zsockopt-test) (:export ;; zsocket #:+zsocket-dynfrom+ #:+zsocket-dynto+ #:zsocket-new #:zsocket-destroy #:with-zsockets ;; * #:zsocket-bind #:zsocket-connect #:zsocket-disconnect #:zsocket-poll #:zsocket-type-str #:zsocket-proxy #:zsocket-test) (:export ;; zframe #:zframe-new #:zframe-destroy #:zframe-recv #:zframe-recv-nowait #:zframe-send #:zframe-size #:zframe-data #:zframe-dup #:zframe-strhex #:zframe-strdup #:zframe-streq #:zframe-more #:zframe-eq #:zframe-print #:zframe-reset #:zframe-test) (:export ;; zstr #:zstr-recv #:zstr-recv-nowait #:zstr-send #:zstr-sendm #:zstr-test) (:export ;; zmsg #:zmsg-new #:zmsg-destroy #:zmsg-recv #:zmsg-send #:zmsg-size #:zmsg-content-size #:zmsg-push #:zmsg-pop #:zmsg-add #:zmsg-pushmem #:zmsg-addmem #:zmsg-pushstr #:zmsg-addstr #:zmsg-popstr #:zmsg-wrap #:zmsg-unwrap #:zmsg-remove #:zmsg-first #:zmsg-next #:zmsg-last #:zmsg-encode #:zmsg-decode #:zmsg-dup #:zmsg-dump #:zmsg-test) (:export ;; zbeacon #:zbeacon-new #:zbeacon-destroy #:zbeacon-hostname #:zbeacon-set-interval #:zbeacon-noecho #:zbeacon-publish #:zbeacon-silence #:zbeacon-subscribe #:zbeacon-unsubscribe #:zbeacon-pipe #:zbeacon-test) (:export ;; zthread #:zthread-new #:zthread-fork #:zthread-test) (:export ;; zpollset (lisp binding only) #:zpollset-new ;; * #:zpollset-destroy ;; * #:with-zpollset ;; * #:zpollset-events ;; * #:zpollset-pollin ;; * #:zpollset-pollout ;; * #:zpollset-pollerr ;; * #:zpollset-poll) ;; * (:export ;; zloop ;; core api #:zloop-new #:zloop-destroy #:with-zloop #:zloop-poller #:zloop-poller-end #:zloop-timer #:zloop-timer-end #:zloop-set-verbose #:zloop-start #:zloop-test) (:export ;; zlist #:zlist-new #:zlist-destroy #:zlist-first #:zlist-last #:zlist-head #:zlist-tail #:zlist-next #:zlist-append #:zlist-push #:zlist-pop #:zlist-remove #:zlist-dup #:zlist-size #:zlist-sort #:zlist-test) (:export ;; zclock #:zclock-sleep #:zclock-time #:zclock-log #:zclock-test) (:export ;; zhash #:zhash-new #:zhash-destroy #:zhash-insert #:zhash-update #:zhash-delete #:zhash-lookup #:zhash-rename #:zhash-freefn #:zhash-size #:zhash-dup #:zhash-keys #:zhash-foreach #:zhash-save #:zhash-load #:zhash-test))
5,282
Common Lisp
.lisp
230
19.230435
86
0.662363
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
1a13c3aba6fe044ef08901936aad97b3f2e1a3e08527bf4843d2ad94b8cd964d
20,139
[ -1 ]
20,140
zpollset.lisp
lhope_cl-czmq/src/zpollset.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defconstant +zmq-poll-msec+ ZMQ_POLL_MSEC) ;; MY OWN ADDITIONS. ;; really a zmq_pollitem_t (cffi:defcstruct zpoller (socket :pointer) (fd :int) (events :short) (revents :short)) (defun zpollset-new (&rest socket/fd-events-list) "Creates a zpollset for use with zloop. socket/fd-events-list is a list of (zsocket/fd . events). zsocket/fd is a zsocket or an integer file descriptor. Events is a list of one or more of :zmq-pollin, :zmq-pollout or :zmq-pollerr." (let ((count (length socket/fd-events-list))) (cffi:foreign-alloc '(:struct zpoller) :count count :initial-contents (loop for (socket/fd . events) in socket/fd-events-list for bitfield = (bitfield-options 'event-types events) collect (if (integerp socket/fd) `(socket ,(cffi:null-pointer) fd ,socket/fd events ,bitfield revents 0) `(socket ,socket/fd fd 0 events ,bitfield revents 0)))))) (defun zpollset-destroy (zpollset) "Destroy the zpollset." (unless (cffi:null-pointer-p zpollset) (cffi:foreign-free zpollset))) (defmacro with-zpollset ((zpollset &rest socket/fd-events-list) &body body) "Create and bind a zpollset and execute body in that scope. Cleans up the zpollset afterwards." `(let ((,zpollset (zpollset-new ,@(loop for socket/fd-events in socket/fd-events-list ;; force evaluation collect `(list ,@socket/fd-events))))) (unwind-protect (progn ,@body) (zpollset-destroy ,zpollset)))) (defun zpollset-events (zpollset &optional (index 0)) "Query the zpollset for triggered events." (let ((zpoller (cffi:mem-aref zpollset '(:struct zpoller) index))) (cffi:foreign-bitfield-symbols 'event-types (getf zpoller 'revents)))) ;; Too many typos of :zmq-pollin!! (defun zpollset-pollin (zpollset &optional (index 0)) (member :zmq-pollin (zpollset-events zpollset index))) (defun zpollset-pollout (zpollset &optional (index 0)) (member :zmq-pollout (zpollset-events zpollset index))) (defun zpollset-pollerr (zpollset &optional (index 0)) (member :zmq-pollerr (zpollset-events zpollset index))) (defun zpollset-poll (zpollset count timeout) "Call zmq_poll on the zpollset. count is the number of zpollers in the zpollset we wish to poll. If timeout is positive, wait that long and then return. If it is -1, wait indefinitely. Returns nil if the poll was interrupted, otherwise returns the number of events triggered, which may be zero." (as-rc (cffi:foreign-funcall "zmq_poll" :pointer zpollset :int count :long (if (plusp timeout) (* timeout +zmq-poll-msec+) timeout) :int)))
3,512
Common Lisp
.lisp
78
41.948718
76
0.7315
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
6c0720ca990365741e1dc13c4dbb35a8cfc183826b7c717c0eedd533a5d4309e
20,140
[ -1 ]
20,141
zsys.lisp
lhope_cl-czmq/src/zsys.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; The zsys class provides a portable wrapper for miscellaneous functions ;; that we want to wrap but which don't fit into any of the existing ;; classes. (in-package :cl-czmq) (defvar *zsys-retry* nil "This variable is used to set the default behavior for recv retries. Lisp has the issue that background threads can be interrupted for garbage collecting at any time. We want to ignore these interruptions. However the foreground thread is interrupted by user. We don't want to ignore these! So we introduce this variable, and default it to nil. zthread-new and zthread-fork bind it to t. Either way, these bindings can be overridden in individual *-recv functions.") (defun zsys-set-retry (retry) "Set default recv retry to the given value. Note that this is rebound within zthread-new and zthread-fork." (setf *zsys-retry* retry)) (defun zsys-retry () "Returns the current default recv retry." *zsys-retry*) (defmacro with-zsys-retry ((retry) &body body) "Binds the default recv retry." `(let ((*zsys-retry* ,retry)) ,@body)) (defun zsys-errno () (let ((errno (cffi:foreign-funcall "zmq_errno" :int))) (values #+allegro ;; workaround for allegro interrupting with errno=0 (if (zerop errno) :eok (cffi:foreign-enum-keyword 'error-code errno)) #-allegro (cffi:foreign-enum-keyword 'error-code errno) errno))) (defun zsys-strerror () (let ((errno (cffi:foreign-funcall "zmq_errno" :int))) (format nil "~a (~D=~a)" (cffi:foreign-funcall "zmq_strerror" :int errno :string) errno (cffi:foreign-enum-keyword 'error-code errno))))
2,490
Common Lisp
.lisp
56
42.107143
74
0.742374
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
5b7ff0836e49049e8ca56040daa7735f9eaf73d3c3b779de5a5ebd66ad796a54
20,141
[ -1 ]
20,142
zstr.lisp
lhope_cl-czmq/src/zstr.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defun %zstr-recv (socket) (with-freed-string (cffi:foreign-funcall "zstr_recv" :pointer socket :pointer))) ;; retrying zstr-recv (defun zstr-recv (socket &optional (retry *zsys-retry*)) (loop for str = (%zstr-recv socket) when #+allegro (or str (let ((errno (zsys-errno))) ;; allegro interrupts with :eok sometimes. Always ;; continue in this case. (unless (eql errno :eok) (or (not retry) (not (eql errno :eintr)))))) #-allegro (or str (not retry) (not (eql (zsys-errno) :eintr))) return str)) (defun zstr-recv-nowait (socket) (with-freed-string (cffi:foreign-funcall "zstr_recv_nowait" :pointer socket :pointer))) ;; Uses zframe to get around the 255 buffer limitation of czmq's zstr_send. (defun zstr-send (socket fmt &rest args) (let ((frame (zframe-new (apply #'format nil fmt args)))) (zframe-send frame socket))) ;; Uses zframe to get around the 255 buffer limitation of czmq's zstr_send. (defun zstr-sendm (socket fmt &rest args) (let ((frame (zframe-new (apply #'format nil fmt args)))) (zframe-send frame socket :zframe-more))) ;; -------------------------------------------------------------------------- ;; Selftest (defun zstr-test (verbose) (declare (ignore verbose)) (format t " * zstr: ") ;; @selftest (let* ((ctx (assert* (zctx-new))) (output (assert* (zsocket-new ctx :zmq-pair))) (input (assert* (zsocket-new ctx :zmq-pair)))) (zsocket-bind output "inproc://zstr.test") (zsocket-connect input "inproc://zstr.test") ;; Send ten strings, five strings with MORE flag and then END (dotimes (string-nbr 10) (zstr-send output "this is string ~d" string-nbr)) (dotimes (string-nbr 5) (zstr-sendm output "this is string ~d" string-nbr)) (zstr-send output "END") ;; Read and count until we receive END (loop for string-nbr from 0 for string = (zstr-recv input) until (string= string "END") finally (assert (= string-nbr 15))) (zctx-destroy ctx)) ;; @end (format t "OK~%") 0)
2,995
Common Lisp
.lisp
74
36.810811
78
0.668501
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
8ffeb59056c43ff59cf8f40b86c0435bf3be72efb249e92b74f33ce7fd7ade09
20,142
[ -1 ]
20,143
zbeacon.lisp
lhope_cl-czmq/src/zbeacon.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) ;; Create a new beacon on a certain UDP port (defun zbeacon-new (port-nbr) (as-pointer (zbeacon_new port-nbr))) ;; Destroy a beacon (defun zbeacon-destroy (zbeacon) "Returns the new value of zbeacon (should be null pointer)" (with-foreign-box (&zbeacon zbeacon) (zbeacon_destroy &zbeacon) (as-pointer (unbox &zbeacon :pointer)))) ;; Return our own IP address as printable string ;; (note this is not copied, so no need to free. (defun zbeacon-hostname (zbeacon) (zbeacon_hostname zbeacon)) ;; Set broadcast interval in milliseconds (default is 1000 msec) (defun zbeacon-set-interval (zbeacon interval) (zbeacon_set_interval zbeacon interval) (values)) ;; Filter out any beacon that looks exactly like ours (defun zbeacon-noecho (zbeacon) (zbeacon_noecho zbeacon) (values)) ;; Start broadcasting beacon to peers at the specified interval (defun zbeacon-publish (zbeacon transmit) (with-foreign-bytes (bytes size transmit) (zbeacon_publish zbeacon bytes size)) (values)) ;; Stop broadcasting beacons (defun zbeacon-silence (zbeacon) (zbeacon_silence zbeacon) (values)) ;; Start listening to other peers; zero-sized filter (or null) means get everything (defun zbeacon-subscribe (zbeacon filter) (if filter (with-foreign-bytes (bytes size filter) (zbeacon_subscribe zbeacon bytes size)) (zbeacon_subscribe zbeacon (cffi:null-pointer) 0)) (values)) ;; Stop listening to other peers (defun zbeacon-unsubscribe (zbeacon) (zbeacon_unsubscribe zbeacon) (values)) ;; Get beacon pipe, for polling or receiving messages (defun zbeacon-pipe (zbeacon) (as-pointer (zbeacon_pipe zbeacon))) ;; -------------------------------------------------------------------------- ;; Self test of this class (defun zbeacon-test (verbose) (declare (ignore verbose)) (format t " * zbeacon: ") ;; Basic test: create a service and announce it (let* ((ctx (zctx-new)) ;; Create a service socket and bind to an ephemeral port (service (zsocket-new ctx :zmq-pub)) (port-nbr (zsocket-bind service "tcp://*:*")) ;; Create beacon to broadcast our service (announcement (make-array 2 :element-type '(unsigned-byte 8) :initial-contents (list (logand (ash port-nbr -8) #xff) (logand port-nbr #xff)))) (service-beacon (zbeacon-new 9999))) (zbeacon-set-interval service-beacon 100) (zbeacon-publish service-beacon announcement) ;; Create beacon to lookup service (let ((client-beacon (zbeacon_new 9999))) (zbeacon-subscribe client-beacon nil) ;; Wait for at most 1/2 second if there's no broadcast networking (zsocket-set-rcvtimeo (zbeacon-pipe client-beacon) 500) (let ((ipaddress (zstr-recv (zbeacon-pipe client-beacon)))) (assert ip-address) (let* ((content (zframe-recv (zbeacon-pipe client-beacon))) (zframe-data (zframe-data content)) (received-port (+ (ash (aref zframe-data 0) 8) (aref zframe-data 1)))) (assert (= received-port port-nbr)))) (zbeacon-destroy client-beacon)) (zbeacon-destroy service-beacon) (zctx-destroy ctx)) ;; @selftest (let ((node1 (zbeacon-new 5670)) (node2 (zbeacon-new 5670)) (node3 (zbeacon-new 5670))) (assert (zbeacon-hostname node1)) (assert (zbeacon-hostname node2)) (assert (zbeacon-hostname node3)) (zbeacon-set-interval node1 250) (zbeacon-set-interval node2 250) (zbeacon-set-interval node3 250) (zbeacon-noecho node1) (zbeacon-publish node1 "NODE/1") (zbeacon-publish node2 "NODE/2") (zbeacon-publish node3 "GARBAGE") (zbeacon-subscribe node1 "NODE") ;; Poll on API pipe and on UDP socket (with-zpollset (pollitems ((zbeacon-pipe node1) :zmq-pollin) ((zbeacon-pipe node2) :zmq-pollin) ((zbeacon-pipe node3) :zmq-pollin)) (loop with stop-at = (+ (zclock-time) 1000) while (< (zclock-time) stop-at) do (let ((timeout (- stop-at (zclock-time)))) (when (< timeout 0) (setf timeout 0)) ;; fudging the call to zmq_poll. We should be using zloop. (when (= -1 (cffi:foreign-funcall "zmq_poll" :pointer pollitems :int 3 :long (* timeout ZMQ_POLL_MSEC) :int)) (loop-finish)))) ;; We cannot get messages on nodes 2 and 3 (assert (not (member :zmq-pollin (zpollset-events pollitems 1)))) (assert (not (member :zmq-pollin (zpollset-events pollitems 2)))) ;; If we get a message on node 1, it must be NODE/2 (when (assert* (member :zmq-pollin (zpollset-events pollitems 0))) (let ((ipaddress (zstr-recv (zbeacon-pipe node1))) (beacon (zstr-recv (zbeacon-pipe node1)))) (declare (ignore ipaddress)) (assert (string= beacon "NODE/2"))))) ;; Stop listening (zbeacon-unsubscribe node1) ;; Stop all node broadcasts (zbeacon-silence node1) (zbeacon-silence node2) (zbeacon-silence node3) ;; Destroy the test nodes (zbeacon-destroy node1) (zbeacon-destroy node2) (zbeacon-destroy node3)) ;; @end (format t "OK~%") 0)
5,951
Common Lisp
.lisp
146
36.869863
115
0.693253
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
c462927f5ec4be925ded009e029003ac76373e55fb911063df10b3e44c2b0f4b
20,143
[ -1 ]
20,144
zsockopt.lisp
lhope_cl-czmq/src/zsockopt.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defmacro zsocket-getter (type) (let ((c-name (intern (format nil "~:@(zsocket_~A~)" (substitute #\_ #\- (string type))))) (l-name (intern (format nil "~:@(zsocket-~A~)" (substitute #\- #\_ (string type)))))) `(defun ,l-name (zocket) (,c-name zocket)))) (zsocket-getter type) (zsocket-getter sndhwm) (zsocket-getter rcvhwm) (zsocket-getter affinity) ;; Returns freshly allocated string, free when done (defun zsocket-identity (zocket) (with-freed-string (cffi:foreign-funcall "zsocket_identity" :pointer zocket :pointer))) (zsocket-getter rate) (zsocket-getter recovery-ivl) (zsocket-getter sndbuf) (zsocket-getter rcvbuf) (zsocket-getter linger) (zsocket-getter reconnect-ivl) (zsocket-getter reconnect-ivl-max) (zsocket-getter backlog) (zsocket-getter maxmsgsize) (zsocket-getter multicast-hops) (zsocket-getter rcvtimeo) (zsocket-getter sndtimeo) (zsocket-getter ipv4only) (zsocket-getter rcvmore) (zsocket-getter fd) (zsocket-getter events) ;; Returns freshly allocated string, free when done (defun zsocket-last-endpoint (zocket) (with-freed-string (cffi:foreign-funcall "zsocket_last_endpoint" :pointer zocket :pointer))) ;; Set socket options (defmacro zsocket-setter (type) (let ((c-name (intern (format nil "~:@(zsocket_set_~A~)" (substitute #\_ #\- (string type))))) (l-name (intern (format nil "~:@(zsocket-set-~A~)" (substitute #\- #\_ (string type)))))) `(defun ,l-name (zocket ,type) (,c-name zocket ,type) (values)))) (zsocket-setter sndhwm) (zsocket-setter rcvhwm) (zsocket-setter affinity) ;; unlike the rest, these take char* input. Should be fine... (zsocket-setter subscribe) (zsocket-setter unsubscribe) (zsocket-setter identity) (zsocket-setter rate) (zsocket-setter recovery-ivl) (zsocket-setter sndbuf) (zsocket-setter rcvbuf) (zsocket-setter linger) (zsocket-setter reconnect-ivl) (zsocket-setter reconnect-ivl-max) (zsocket-setter backlog) (zsocket-setter maxmsgsize) (zsocket-setter multicast-hops) (zsocket-setter rcvtimeo) (zsocket-setter sndtimeo) (zsocket-setter ipv4only) (zsocket-setter delay-attach-on-connect) (zsocket-setter router-mandatory) (zsocket-setter router-raw) (zsocket-setter xpub-verbose) ;; Emulation of widely-used 2.x socket options (zsocket-setter hwm) ;; -------------------------------------------------------------------------- ;; Selftest (defun zsockopt-test (verbose) (declare (ignore verbose)) (format t " * zsockopt: ") ;; @selftest (let ((ctx (assert* (zctx-new)))) ;;#if (ZMQ_VERSION_MAJOR == 3) (macrolet ((with-zocket (type &body body) `(let ((zocket (assert* (zsocket-new ctx ,type)))) ,@body (zsocket-destroy ctx zocket)))) (with-zocket :zmq-sub (zsocket-type zocket)) (with-zocket :zmq-pub (zsocket-set-sndhwm zocket 1) (assert (= (zsocket-sndhwm zocket) 1)) (zsocket-sndhwm zocket)) (with-zocket :zmq-sub (zsocket-set-rcvhwm zocket 1) (assert (= (zsocket-rcvhwm zocket) 1)) (zsocket-rcvhwm zocket)) (with-zocket :zmq-sub (zsocket-set-affinity zocket 1) (assert (= (zsocket-affinity zocket) 1)) (zsocket-affinity zocket)) (with-zocket :zmq-sub (zsocket-set-subscribe zocket "test")) (with-zocket :zmq-sub (zsocket-set-unsubscribe zocket "test")) (with-zocket :zmq-dealer (zsocket-set-identity zocket "test") (assert (zsocket-identity zocket))) (with-zocket :zmq-sub (zsocket-set-rate zocket 1) (assert (= (zsocket-rate zocket) 1)) (zsocket-rate zocket)) (with-zocket :zmq-sub (zsocket-set-recovery-ivl zocket 1) (assert (= (zsocket-recovery-ivl zocket) 1)) (zsocket-recovery-ivl zocket)) (with-zocket :zmq-pub (zsocket-set-sndbuf zocket 1) (assert (= (zsocket-sndbuf zocket) 1)) (zsocket-sndbuf zocket)) (with-zocket :zmq-sub (zsocket-set-rcvbuf zocket 1) (assert (= (zsocket-rcvbuf zocket) 1)) (zsocket-rcvbuf zocket)) (with-zocket :zmq-sub (zsocket-set-linger zocket 1) (assert (= (zsocket-linger zocket) 1)) (zsocket-linger zocket)) (with-zocket :zmq-sub (zsocket-set-reconnect-ivl zocket 1) (assert (= (zsocket-reconnect-ivl zocket) 1)) (zsocket-reconnect-ivl zocket)) (with-zocket :zmq-sub (zsocket-set-reconnect-ivl-max zocket 1) (assert (= (zsocket-reconnect-ivl-max zocket) 1)) (zsocket-reconnect-ivl-max zocket)) (with-zocket :zmq-sub (zsocket-set-backlog zocket 1) (assert (= (zsocket-backlog zocket) 1)) (zsocket-backlog zocket)) (with-zocket :zmq-sub (zsocket-set-maxmsgsize zocket 1) (assert (= (zsocket-maxmsgsize zocket) 1)) (zsocket-maxmsgsize zocket)) (with-zocket :zmq-sub (zsocket-set-multicast-hops zocket 1) (assert (= (zsocket-multicast-hops zocket) 1)) (zsocket-multicast-hops zocket)) (with-zocket :zmq-sub (zsocket-set-rcvtimeo zocket 1) (assert (= (zsocket-rcvtimeo zocket) 1)) (zsocket-rcvtimeo zocket)) (with-zocket :zmq-sub (zsocket-set-sndtimeo zocket 1) (assert (= (zsocket-sndtimeo zocket) 1)) (zsocket-sndtimeo zocket)) (with-zocket :zmq-sub (zsocket-set-ipv4only zocket 1) (assert (= (zsocket-ipv4only zocket) 1)) (zsocket-ipv4only zocket)) (with-zocket :zmq-pub (zsocket-set-delay-attach-on-connect zocket 1)) (with-zocket :zmq-router (zsocket-set-router-mandatory zocket 1)) (with-zocket :zmq-router (zsocket-set-router-raw zocket 1)) (with-zocket :zmq-xpub (zsocket-set-xpub-verbose zocket 1)) (with-zocket :zmq-sub (zsocket-rcvmore zocket)) (with-zocket :zmq-sub (zsocket-fd zocket)) (with-zocket :zmq-sub (zsocket-events zocket)) (with-zocket :zmq-sub (assert (zsocket-last-endpoint zocket))) (with-zocket :zmq-sub (zsocket-set-hwm zocket 1))) (zctx-destroy ctx)) ;; @end (format t "OK~%") 0)
6,649
Common Lisp
.lisp
193
31.709845
78
0.711291
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
0f9f81c917dd3178e619e74730607c95989047b8dbd1e39d17344d3791a8b879
20,144
[ -1 ]
20,145
zhash.lisp
lhope_cl-czmq/src/zhash.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; @header ;; Expandable hash table container ;; @discuss ;; Implements the zhash api, but uses a lisp 'equal hash table as its backend. ;; Uses a special nil hash key to store an equal hash of free functions. ;; It doesn't support autofree as garbage collection is appropriate in that case. ;; @end (in-package :cl-czmq) ;; Hash table performance parameters (defconstant +initial-size+ 255) ;; Initial size in items (defconstant +load-factor+ 75) ;; Percent loading before splitting (defconstant +growth-factor+ 200) ;; Increase in % after splitting ;; -------------------------------------------------------------------------- ;; Local helper function ;; Lookup item in hash table, returns item or NULL ;;static item_t * ;;s_item_lookup (zhash_t *self, const char *key) ;; => (gethash key zhash) ;; -------------------------------------------------------------------------- ;; Local helper functions for managing free-fns (defun %zhash-set-free (zhash key free-fn) (assert key) (let ((key->free (or (gethash nil zhash) (setf (gethash nil zhash) (make-hash-table :test 'equal))))) (setf (gethash key key->free) free-fn))) (defun %zhash-get-free (zhash key) (let ((key->free (gethash nil zhash))) (when key->free (gethash key key->free)))) (defun %zhash-rem-free (zhash key) (let ((key->free (gethash nil zhash))) (when key->free (remhash key key->free) (when (zerop (hash-table-count key->free)) (remhash nil zhash))))) ;; -------------------------------------------------------------------------- ;; Local helper function ;; Destroy item in hash table. (defun %item-destroy (zhash key hard) (when hard (let ((free (%zhash-get-free zhash key))) (when free (funcall free (gethash key zhash))))) (%zhash-rem-free zhash key) (remhash key zhash)) ;; -------------------------------------------------------------------------- ;; Hash table constructor (defun zhash-new () (make-hash-table :test 'equal :size +initial-size+ :rehash-size (/ +growth-factor+ 100.0) :rehash-threshold (/ +load-factor+ 100.0))) ;; -------------------------------------------------------------------------- ;; Hash table destructor (defun zhash-destroy (zhash) "Only necessary to call if items have free-fns." (when (gethash nil zhash) ;; there are free-fns. (loop for key being the hash-key of zhash when key do (%item-destroy zhash key t))) (clrhash zhash)) ;; -------------------------------------------------------------------------- ;; Insert item into hash table with specified key and item ;; If key is already present returns nil and leaves existing item unchanged ;; Returns t on success. (defun zhash-insert (zhash key value) (assert key) (unless (gethash key zhash) (setf (gethash key zhash) value) t)) ;; -------------------------------------------------------------------------- ;; Update item into hash table with specified key and item. ;; If key is already present, destroys old item and inserts new one. ;; Use free_fn method to ensure deallocator is properly called on item. (defun zhash-update (zhash key value) (assert key) (when (gethash key zhash) (%item-destroy zhash key t)) (zhash-insert zhash key value)) ;; -------------------------------------------------------------------------- ;; Remove an item specified by key from the hash table. If there was no such ;; item, this function does nothing. (defun zhash-delete (zhash key) (assert key) (%item-destroy zhash key t)) ;; -------------------------------------------------------------------------- ;; Look for item in hash table and return its item, or NULL (defun zhash-lookup (zhash key) (assert key) (gethash key zhash)) ;; -------------------------------------------------------------------------- ;; Reindexes an item from an old key to a new key. If there was no such ;; item, does nothing. If the new key already exists, deletes old item. (defun zhash-rename (zhash old-key new-key) (assert old-key) (assert new-key) (let ((val (gethash old-key zhash))) (unless val (return-from zhash-rename)) (cond ((gethash new-key zhash) (%item-destroy zhash old-key t) nil) (t (let ((free-fn (%zhash-get-free zhash old-key))) (when free-fn (%zhash-set-free zhash new-key free-fn)) (%item-destroy zhash old-key nil) (zhash-insert zhash new-key val)))))) ;; -------------------------------------------------------------------------- ;; Set a free function for the specified hash table item. When the item is ;; destroyed, the free function, if any, is called on that item. ;; Use this when hash items are dynamically allocated, to ensure that ;; you don't have memory leaks. You can pass 'free' or NULL as a free_fn. ;; Returns the item, or nil if there is no such item. (defun zhash-freefn (zhash key free-fn) (assert key) (let ((item (gethash key zhash))) (when item (%zhash-set-free zhash key free-fn) item))) ;; -------------------------------------------------------------------------- ;; Return size of hash table (defun zhash-size (zhash) (let ((count (hash-table-count zhash))) (if (gethash nil zhash) (1- count) count))) ;; -------------------------------------------------------------------------- ;; Make copy of hash table ;; Does not copy items themselves. Rebuilds new table so may be slow on ;; very large tables. NOTE: only works with item values that are strings ;; since there's no other way to know how to duplicate the item value. (defun zhash-dup (zhash) (loop with copy = (zhash-new) for key being the hash-key of zhash using (hash-value value) when key do (zhash-insert copy key value) finally (return copy))) ;; -------------------------------------------------------------------------- ;; Return keys for items in table (as a zlist) (defun zhash-keys (zhash) (loop with keys = (zlist-new) for key being the hash-key of zhash when key do (zlist-append keys key) finally (return keys))) ;; -------------------------------------------------------------------------- ;;; Apply function to each item in the hash table. Items are iterated in no ;; defined order. Stops if callback function returns non-nil and returns ;; final return code from callback function (nil = success). (defun zhash-foreach (zhash callback &rest args) (loop for key being the hash-key of zhash using (hash-value value) when key do (let ((result (apply callback key value args))) (when result (return result))))) ;; -------------------------------------------------------------------------- ;; Save hash table to a text file in name=value format ;; Hash values must be printable strings; keys may not contain '=' character ;; Returns t if OK, else nil if a file error occurred (defun zhash-save (zhash filename &key (if-exists :error)) (ignore-errors (with-open-file (stream filename :direction :output :if-exists if-exists) (loop for key being the hash-key of zhash using (hash-value value) when key do (format stream "~A=~A~%" key value) finally (return t))))) ;; -------------------------------------------------------------------------- ;; Load hash table from a text file in name=value format; hash table must ;; already exist. Hash values must printable strings; keys may not contain ;; '=' character. Returns t if OK, else nil if a file was not readable. (defun zhash-load (zhash filename) (ignore-errors (with-open-file (stream filename :direction :input) (loop for line = (read-line stream nil nil) while line do (let ((equals (position #\= line))) (unless equals (return-from zhash-load)) ;; bail with error signal. (let ((key (subseq line 0 equals)) (value (subseq line (1+ equals)))) (zhash-update zhash key value))) finally (return t))))) #|| // -------------------------------------------------------------------------- // Set hash for automatic value destruction void zhash_autofree (zhash_t *self) { assert (self); self->autofree = true; } ||# ;; -------------------------------------------------------------------------- ;; Runs selftest of class ;; TODO: add unit test for free_fn, foreach ;; (defun test-foreach (key value zhash) (declare (ignore value)) (assert (zhash-lookup zhash key)) nil) (defun test-foreach-error (key value zhash) (declare (ignore key value zhash)) t) (defun zhash-test (verbose) (declare (ignore verbose)) (format t " * zhash: ") ;; @selftest (let ((hash (zhash-new))) (assert hash) (assert (zerop (zhash-size hash))) ;; Insert some items (assert (zhash-insert hash "DEADBEEF" "dead beef")) (assert (zhash-insert hash "ABADCAFE" "a bad cafe")) (assert (zhash-insert hash "C0DEDBAD" "coded bad")) (assert (zhash-insert hash "DEADF00D" "dead food")) (assert (= (zhash-size hash) 4)) ;; Look for existing items (assert (string= (zhash-lookup hash "DEADBEEF") "dead beef")) (assert (string= (zhash-lookup hash "ABADCAFE") "a bad cafe")) (assert (string= (zhash-lookup hash "C0DEDBAD") "coded bad")) (assert (string= (zhash-lookup hash "DEADF00D") "dead food")) ;; Look for non-existent items (assert (null (zhash-lookup hash "foo"))) ;; Try to insert duplicate items (assert (null (zhash-insert hash "DEADBEEF" "foo"))) (assert (string= (zhash-lookup hash "DEADBEEF") "dead beef")) ;; Rename an item (assert (zhash-rename hash "DEADBEEF" "LIVEBEEF")) (assert (null (zhash-rename hash "WHATBEEF" "LIVEBEEF"))) ;; Test keys method (let ((keys (zhash-keys hash))) (assert (= (zlist-size keys) 4))) ;; Test dup method (let ((copy (zhash-dup hash))) (assert (= (zhash-size copy) 4)) (assert (string= (zhash-lookup copy "LIVEBEEF") "dead beef"))) ;; Test foreach (assert (null (zhash-foreach hash #'test-foreach hash))) (assert (zhash-foreach hash #'test-foreach-error hash)) ;; Test save and load (zhash-save hash ".cache") (let ((copy (zhash-new))) (zhash-load copy ".cache") (let ((item (zhash-lookup copy "LIVEBEEF"))) (assert item) (assert (string= item "dead beef")))) (delete-file ".cache") ;; Delete an item (zhash-delete hash "LIVEBEEF") (assert (null (zhash-lookup hash "LIVEBEEF"))) (assert (= (zhash-size hash) 3)) ;; Check that the queue is robust against random usage (let ((*random-state* (make-random-state t))) (loop with testmax = 200 with testset = (make-array testmax :initial-element (cons nil nil)) for testnbr = (random testmax) repeat 25000 do (cond ((cdr (aref testset testnbr)) ;; exists (let ((item (zhash-lookup hash (car (aref testset testnbr))))) (assert item) (zhash-delete hash (car (aref testset testnbr))) (setf (cdr (aref testset testnbr)) nil))) (t (setf (aref testset testnbr) (cons (format nil "~x-~x" (random #x10000) (random #x10000)) nil)) ;; exists (when (zhash-insert hash (car (aref testset testnbr)) "") (setf (cdr (aref testset testnbr)) t))))) ;; Test 10K lookups (loop repeat 10000 do (zhash-lookup hash "DEADBEEFABADCAFE")) ; Destructor should be safe to call twice (zhash-destroy hash) (zhash-destroy hash) (assert (zerop (zhash-size hash))))) ;; @end (format t "OK~%"))
12,452
Common Lisp
.lisp
299
38.020067
83
0.598544
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
d5531a702edef01b6874e3feae7480584be1b36c7ff28289ee7d3e0c99cb7f09
20,145
[ -1 ]
20,146
czmq.lisp
lhope_cl-czmq/src/czmq.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defconstant +czmq-version-major+ CZMQ_VERSION_MAJOR) (defconstant +czmq-version-minor+ CZMQ_VERSION_MINOR) (defconstant +czmq-version-patch+ CZMQ_VERSION_PATCH) (defconstant +czmq-version+ CZMQ_VERSION)
1,123
Common Lisp
.lisp
27
40.111111
71
0.768103
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
6e9b3b52f67d8ecb570ca09fbf6f369779a0ba79c8f9b65e016b642dac85a6a7
20,146
[ -1 ]
20,147
ffi-utils.lisp
lhope_cl-czmq/src/ffi-utils.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defun bitfield-options (bitfield-name options) (unless (listp options) (setf options (list options))) (cffi:foreign-bitfield-value bitfield-name options)) (defmacro unbox (var &optional (type :pointer)) `(cffi:mem-aref ,var ,type)) (defmacro with-foreign-box ((var foreign &optional (type :pointer)) &body body) "Binds var to a type* box of one element, and sets that element to foreign." (let ((g!type (gensym))) `(let ((,g!type ,type)) (cffi:with-foreign-object (,var ,g!type) (setf (cffi:mem-aref ,var ,g!type) ,foreign) ,@body)))) (defmacro as-rc (&body body) "c commonly uses negative int values as error markers. Converts negative int values returned by body to nil." (let ((g!rc (gensym))) `(let ((,g!rc (progn ,@body))) (unless (minusp ,g!rc) ,g!rc)))) (defmacro as-bool (&body body) "Convert a c boolean (0 false, otherwise true) to lisp" (let ((g!bool (gensym))) `(let ((,g!bool (progn ,@body))) (unless (zerop ,g!bool) ,g!bool)))) (defmacro as-pointer (&body body) (let ((g!pointer (gensym))) `(let ((,g!pointer (progn ,@body))) (unless (cffi:null-pointer-p ,g!pointer) ,g!pointer)))) (defmacro with-foreign-bytes ((bytes-var size-var data &optional (string-encoding cffi:*default-foreign-encoding*)) &body body) "If data is a string, uses with-foreign-string. If a (simple-array (unsigned-byte 8), uses with-pointer-to-vector-data. If a vector of unsigned-bytes, copies that vector using with-foreign-object." (let ((g!data (gensym)) (g!func (gensym)) (g!var (gensym)) (g!size (gensym))) `(let ((,g!data ,data) (,g!func (lambda (,bytes-var ,size-var) ,@body))) (etypecase ,g!data (string (cffi:with-foreign-string ((,g!var ,g!size) ,g!data :encoding ,string-encoding :null-terminated-p nil) (funcall ,g!func ,g!var ,g!size))) ((simple-array (unsigned-byte 8)) ;; here we're making an assumption that the c byte is 8 bits. (cffi:with-pointer-to-vector-data (,g!var ,g!data) (let ((,g!size (length ,g!data))) (funcall ,g!func ,g!var ,g!size)))) (vector (let ((,g!size (length ,g!data))) (cffi:with-foreign-object (,g!var :uchar ,g!size) (dotimes (i ,g!size) (setf (cffi:mem-aref ,g!var :uchar i) (aref ,g!data i))) (funcall ,g!func ,g!var ,g!size)))))))) (defmacro with-freed-string (&body body) (let ((g!cstring (gensym))) `(let ((,g!cstring (cffi:null-pointer))) (unwind-protect (cffi:foreign-string-to-lisp (setf ,g!cstring (progn ,@body))) (unless (cffi:null-pointer-p ,g!cstring) (cffi:foreign-free ,g!cstring)))))) ;; should work on sbcl at least (defmacro assert* (test &rest assert-args) "Like assert, except if test succeeds, returns it." (let ((g!test (gensym))) `(let ((,g!test ,test)) (assert ,g!test ,@assert-args) ,g!test)))
3,774
Common Lisp
.lisp
87
39.873563
115
0.675279
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
6e50ca550f38f04d10f9891d449f4f7a6c3965127bd7dad4b60bc7b7aa0eaeda
20,147
[ -1 ]
20,148
zloop.lisp
lhope_cl-czmq/src/zloop.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; This is a direct port of czmq/src/zloop.c which is ;; Copyright (c) 1991-2013 iMatix Corporation <www.imatix.com> ;; Copyright other contributors as noted in the AUTHORS file. ;; The zloop class provides an event-driven reactor pattern. The reactor ;; handles zmq_pollitem_t items (pollers or writers, sockets or fds), and ;; once-off or repeated timers. Its resolution is 1 msec. It uses a tickless ;; timer to reduce CPU interrupts in inactive processes. (in-package :cl-czmq) ;; Structure of our class (defstruct %zloop pollers ;; List of poll items timers ;; List of timers poll-size ;; Size of poll set pollset ;; zmq_poll set pollact ;; Lisp array of oollers for this poll set dirty ;; True if pollset needs rebuilding verbose ;; True if verbose tracing wanted zombies ;; List of timers to kill ) ;; Pollers and timers are held as small structures of their own (defstruct %poller item ;; zmq_pollitem_t handler ;; zloop_fn args ;; void *arg - a list of args to apply with the handler ignore-errors ;; bool errors ;; int - If too many errors, kill poller ) (defstruct %timer delay ;; size_t times ;; size_t handler ;; zloop_fn args ;; void *arg - a list of args to apply with the handler when ;; int64_t when - Clock time when alarm goes off ) (defun %item-copy (from-ptr &optional to-ptr) (assert (cffi:pointerp from-ptr)) (unless to-ptr (setf to-ptr (cffi:foreign-alloc '(:struct zpoller)))) (assert (cffi:pointerp from-ptr)) (cffi:foreign-funcall "memcpy" :pointer to-ptr :pointer from-ptr size_t (cffi:foreign-type-size '(:struct zpoller)) :pointer) to-ptr) (defun %poller-new (item handler args) (cffi:with-foreign-slots ((events) item (:struct zpoller)) (make-%poller :item (%item-copy item) :handler handler :args args :ignore-errors (and (member :zmq-ignrerr (cffi:foreign-bitfield-symbols 'event-types events)) t)))) (defun %timer-new (delay times handler args) (make-%timer :delay delay :times times :handler handler :args args :when -1)) ;; Indicates a new timer (defun %rebuild-pollset (zloop) "We hold an array of pollers that matches the pollset, so we can register/cancel pollers orthogonally to executing the pollset activity on pollers. Returns t on success, nil on failure." (when (%zloop-pollset zloop) (cffi:foreign-free (%zloop-pollset zloop))) (setf (%zloop-poll-size zloop) (length (%zloop-pollers zloop))) ;; copy the poll list as a vector (setf (%zloop-pollact zloop) (coerce (%zloop-pollers zloop) 'vector)) ;; make the pollset which should mirror the items in the pollers. Copy by value. (setf (%zloop-pollset zloop) (loop with item-size = (cffi:foreign-type-size '(:struct zpoller)) with pollset = (cffi:foreign-alloc '(:struct zpoller) :count (%zloop-poll-size zloop)) for item-nbr from 0 for poller across (%zloop-pollact zloop) for item = (cffi:inc-pointer pollset (* item-size item-nbr)) do (%item-copy (%poller-item poller) item) finally (return pollset))) (setf (%zloop-dirty zloop) nil) t) (defun s-tickless-timer (zloop) ;; Calculate tickless timer, up to 1 hour (let ((tickless (+ (zclock-time) (* 1000 3600)))) (dolist (timer (%zloop-timers zloop)) (when (= -1 (%timer-when timer)) (setf (%timer-when timer) (+ (%timer-delay timer) (zclock-time)))) (setf tickless (min tickless (%timer-when timer)))) (let ((timeout (max 0 (- tickless (zclock-time))))) (when (%zloop-verbose zloop) (zclock-log "I: zloop: polling for ~D msec" timeout)) timeout))) (defun %ptr-addr (ptr) (format nil "~8,'0x" (cffi:pointer-address ptr))) ;; -------------------------------------------------------------------------- ;; Constructor (defun zloop-new () (make-%zloop)) ;; -------------------------------------------------------------------------- ;; Destructor (defun zloop-destroy (self) (assert self) (when (%zloop-pollset self) (cffi:foreign-free (%zloop-pollset self))) (dolist (poller (%zloop-pollers self)) (let ((item (%poller-item poller))) (cffi:foreign-free item))) nil) (defmacro with-zloop ((zloop) &body body) `(let ((,zloop (zloop-new))) (unwind-protect (progn ,@body) (zloop-destroy ,zloop)))) ;; -------------------------------------------------------------------------- ;; Register pollitem with the reactor. When the pollitem is ready, will call ;; the handler, passing the arg. Returns 0 if OK, -1 if there was an error. ;; If you register the pollitem more than once, each instance will invoke its ;; corresponding handler. (defun zloop-poller (self item handler &rest args) (cffi:with-foreign-slots ((socket fd) item (:struct zpoller)) (when (and (cffi:null-pointer-p socket) (zerop fd)) (return-from zloop-poller)) (unless (cffi:null-pointer-p socket) (when (string= (zsocket-type-str socket) "UNKNOWN") (return-from zloop-poller))) (let ((poller (%poller-new item handler args))) (when poller (push poller (%zloop-pollers self)) (setf (%zloop-dirty self) t) (when (%zloop-verbose self) (zclock-log "I: zloop: register ~A poller (~A, ~d)" (if (cffi:null-pointer-p socket) "FD" (zsocket-type-str socket)) (%ptr-addr socket) fd)) t)))) ;; -------------------------------------------------------------------------- ;; Cancel a pollitem from the reactor, specified by socket or FD. If both ;; are specified, uses only socket. If multiple poll items exist for same ;; socket/FD, cancels ALL of them. (defun zloop-poller-end (self item) (assert self) (cffi:with-foreign-slots ((socket fd) item (:struct zpoller)) (assert (or (not (cffi:null-pointer-p socket)) (not (zerop fd)))) (let ((item->socket socket) (item->fd fd)) (flet ((poller-match-p (poller) (cffi:with-foreign-slots ((socket fd) (%poller-item poller) (:struct zpoller)) (when (or (and (not (cffi:null-pointer-p item->socket)) (cffi:pointer-eq item->socket socket)) (and (not (zerop item->fd)) (= item->fd fd))) (cffi:foreign-free (%poller-item poller)) (setf (%zloop-dirty self) t) t)))) (setf (%zloop-pollers self) (delete-if #'poller-match-p (%zloop-pollers self))))) (when (%zloop-verbose self) (zclock-log "I: zloop: cancel ~s poller (~a, ~d)" (if (cffi:null-pointer-p socket) "FD" (zsocket-type-str socket)) (%ptr-addr socket) fd)))) ;; -------------------------------------------------------------------------- ;; Register a timer that expires after some delay and repeats some number of ;; times. At each expiry, will call the handler, passing the arg. To ;; run a timer forever, use 0 times. Returns t if OK, nil if there was an ;; error. (defun zloop-timer (self delay times handler &rest args) (assert self) (let ((timer (%timer-new delay times handler args))) (unless timer (return-from zloop-timer)) (push timer (%zloop-timers self)) (when (%zloop-verbose self) (zclock-log "I: zloop: register timer delay=~d times=~d" delay times)) t)) ;; -------------------------------------------------------------------------- ;; Cancel all timers for a specific argument (as provided in zloop_timer) ;; Returns 0 on success. (defun zloop-timer-end (self &rest args) (assert self) ;;(assert args) ;; really? ;; We cannot touch self->timers because we may be executing that ;; from inside the poll loop. So, we hold the arg on the zombie ;; list, and process that list when we're done executing timers. (push args (%zloop-zombies self)) (when (%zloop-verbose self) (zclock-log "I: zloop: cancel timer"))) ;; -------------------------------------------------------------------------- ;; Set verbose tracing of reactor on/off (defun zloop-set-verbose (self verbose) (setf (%zloop-verbose self) verbose)) ;; -------------------------------------------------------------------------- ;; Start the reactor. Takes control of the thread and returns when the 0MQ ;; context is terminated or the process is interrupted, or any event handler ;; returns nil. Event handlers may register new sockets and timers, and ;; cancel sockets. Returns 0 if interrupted, nil if canceled by a ;; handler, positive on internal error (defun zloop-start (self) (assert self) ;; Recalculate all timers now (dolist (timer (%zloop-timers self)) (setf (%timer-when timer) (+ (zclock-time) (%timer-delay timer)))) ;; Main reactor loop (loop with rc = 0 until (zctx-interrupted) do (when (%zloop-dirty self) ;; If s_rebuild_pollset() fails, break out of the loop and ;; return its error (unless (%rebuild-pollset self) (setf rc nil) (loop-finish))) (when (or (null (zpollset-poll (%zloop-pollset self) (%zloop-poll-size self) ;; zpollset-poll takes care of +zmq-poll-msec+ (s-tickless-timer self))) (zctx-interrupted)) (when (%zloop-verbose self) (zclock-log "I: zloop: interrupted - ~s" (zsys-strerror))) (setf rc 0) (loop-finish)) ;; Context has been shut down. ;; Handle any timers that have now expired (loop with to-remove for timer in (%zloop-timers self) for when = (%timer-when timer) do (when (and (/= -1 when) (>= (zclock-time) when)) (when (%zloop-verbose self) (zclock-log "I: zloop: call timer handler")) (unless (setf rc (apply (%timer-handler timer) self nil (%timer-args timer))) (loop-finish)) ;; Timer handler signaled break (if (and (plusp (%timer-times timer)) (zerop (decf (%timer-times timer)))) (push timer to-remove) (setf (%timer-when timer) (+ (%timer-delay timer) (zclock-time))))) finally (setf (%zloop-timers self) (nset-difference (%zloop-timers self) to-remove))) ;; Handle any pollers that are ready (loop with item-size = (cffi:foreign-type-size '(:struct zpoller)) for item-nbr below (%zloop-poll-size self) for poller = (aref (%zloop-pollact self) item-nbr) for item = (cffi:inc-pointer (%zloop-pollset self) (* item-size item-nbr)) do (cffi:with-foreign-slots ((socket fd revents) item (:struct zpoller)) (assert (cffi:pointer-eq socket (cffi:foreign-slot-value (%poller-item poller) '(:struct zpoller) 'socket))) (cond ((and (member :zmq-pollerr (zpollset-events item)) (not (%poller-ignore-errors poller))) (when (%zloop-verbose self) (zclock-log "I: zloop: can't poll %a socket (~A, ~d): ~A" (if (cffi:null-pointer-p socket) "FD" (zsocket-type-str socket)) (%ptr-addr socket) fd (zsys-strerror))) ;; Give handler one chance to handle error, then kill ;; poller because it'll disrupt the reactor otherwise. (unless (zerop (%poller-errors poller)) (zloop-poller-end self (%poller-item poller)) (setf revents 0)) (incf (%poller-errors poller))) (t (setf (%poller-errors poller) 0) ;; A non-error happened )) (unless (zerop revents) (when (%zloop-verbose self) (zclock-log "I: zloop: call ~a socket handler (~A, ~d)" (if (cffi:null-pointer-p socket) "FD" (zsocket-type-str socket)) (%ptr-addr socket) fd)) (setf rc (apply (%poller-handler poller) self item (%poller-args poller))) (unless rc (loop-finish)) ;; Poller handler signaled break ;; If the poller handler calls zloop_poller_end on poller other than itself ;; we need to force rebuild in order to avoid reading from freed memory in the handler (when (%zloop-dirty self) (when (%zloop-verbose self) (zclock-log "I: zloop: pollers canceled, forcing rebuild")) (loop-finish))))) ;; Now handle any timer zombies ;; This is going to be slow if we have many zombies (flet ((args-equal (args1 args2) (and (= (length args1) (length args2)) (loop for arg1 in args2 for arg2 in args2 unless (or (equal arg1 arg2) (and (cffi:pointerp arg1) (cffi:pointerp arg2) (cffi:pointer-eq arg1 arg2))) return nil finally (return t))))) (dolist (zombie-args (%zloop-zombies self)) (setf (%zloop-timers self) (delete-if (lambda (timer) (args-equal zombie-args (%timer-args timer))) (%zloop-timers self))))) (unless rc (loop-finish)) finally (return rc))) ;; -------------------------------------------------------------------------- ;; Selftest (defun s-timer-event (loop item output) (declare (ignore loop item)) (zstr-send output "PING") t) (defun s-socket-event (loop item) (declare (ignore loop item)) nil) (defun zloop-test (verbose) (format t " * zloop: ") (with-zctx (ctx) (assert ctx) (with-zsockets ctx ((output :zmq-pair) (input :zmq-pair)) (assert output) (zsocket-bind output "inproc://zloop.test") (assert input) (zsocket-connect input "inproc://zloop.test") (with-zloop (loop) (assert loop) (zloop-set-verbose loop verbose) ;; After 10 msecs, send a ping message to output (zloop-timer loop 10 1 #'s-timer-event output) ;; When we get the ping message, end the reactor (with-zpollset (poll-input (input :zmq-pollin)) (assert (zloop-poller loop poll-input #'s-socket-event))) (zloop-start loop)))) ;; @end (format t "OK~%"))
14,562
Common Lisp
.lisp
362
35.707182
102
0.632477
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
7053ed34ffd35b1f32095dcb078266befb6fb0f348e7eca42f42e1ae1eb2e98d
20,148
[ -1 ]
20,149
zlist.lisp
lhope_cl-czmq/src/zlist.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; @header ;; Provides a generic container implementing a fast singly-linked list. You ;; can use this to construct multi-dimensional lists, and other structures ;; together with other generic containers like zhash. (in-package :cl-czmq) ;; --------------------------------------------------------------------- ;; Structure of our class (defstruct %zlist head ;; First item in list, if any tail ;; Last item in list, if any cursor ;; Current cursors for iteration size) ;; Number of items in list ;; -------------------------------------------------------------------------- ;; List constructor (defun zlist-new () (make-%zlist :size 0)) ;; -------------------------------------------------------------------------- ;; List destructor (defun zlist-destroy (zlist) (declare (ignore zlist)) ;; no-op nil) ;; -------------------------------------------------------------------------- ;; Return the item at the head of list. If the list is empty, returns NULL. ;; Leaves cursor pointing at the head item, or NULL if the list is empty. (defun zlist-first (zlist) (assert zlist) (setf (%zlist-cursor zlist) (%zlist-head zlist)) (when (%zlist-cursor zlist) (car (%zlist-cursor zlist)))) ;; -------------------------------------------------------------------------- ;; Return the item at the tail of list. If the list is empty, returns NULL. ;; Leaves cursor pointing at the tail item, or NULL if the list is empty. (defun zlist-last (zlist) (assert zlist) (setf (%zlist-cursor zlist) (%zlist-tail zlist)) (when (%zlist-cursor zlist) (car (%zlist-cursor zlist)))) ;; -------------------------------------------------------------------------- ;; Return the item at the head of list. If the list is empty, returns NULL. ;; Leaves cursor as-is. (defun zlist-head (zlist) (assert zlist) (car (%zlist-head zlist))) ;; -------------------------------------------------------------------------- ;; Return the item at the tail of list. If the list is empty, returns NULL. ;; Leaves cursor as-is. (defun zlist-tail (zlist) (assert zlist) (car (%zlist-tail zlist))) ;; -------------------------------------------------------------------------- ;; Return the next item. If the list is empty, returns NULL. To move to ;; the start of the list call zlist_first (). Advances the cursor. (defun zlist-next (zlist) (assert zlist) (setf (%zlist-cursor zlist) (if (%zlist-cursor zlist) (cdr (%zlist-cursor zlist)) (%zlist-head zlist))) (car (%zlist-cursor zlist))) ;; -------------------------------------------------------------------------- ;; Add item to the end of the list (defun zlist-append (zlist item) (let ((node (list item))) (if (%zlist-tail zlist) (setf (cdr (%zlist-tail zlist)) node) (setf (%zlist-head zlist) node)) (setf (%zlist-tail zlist) node) (incf (%zlist-size zlist)) (setf (%zlist-cursor zlist) nil) nil)) ;; -------------------------------------------------------------------------- ;; Insert item at the beginning of the list (defun zlist-push (zlist item) (let ((node (list item))) (setf (cdr node) (%zlist-head zlist) (%zlist-head zlist) node) (unless (%zlist-tail zlist) (setf (%zlist-tail zlist) node)) (incf (%zlist-size zlist)) (setf (%zlist-cursor zlist) nil)) t) ;; -------------------------------------------------------------------------- ;; Remove item from the beginning of the list, returns NULL if none (defun zlist-pop (zlist) (let ((node (%zlist-head zlist)) item) (when node (setf item (car node) (%zlist-head zlist) (cdr node)) (when (eq (%zlist-tail zlist) node) (setf (%zlist-tail zlist) nil)) (decf (%zlist-size zlist)) (setf (%zlist-cursor zlist) nil)) item)) ;; -------------------------------------------------------------------------- ;; Remove the item from the list, if present. Safe to call on items that ;; are not in the list. Maintains cursor. (defun zlist-remove (zlist item &key (key #'identity) (test #'eql)) (loop with prev with item-key = (funcall key item) for node on (%zlist-head zlist) for node-item-key = (funcall key (car node)) until (funcall test item-key node-item-key) do (setf prev node) finally (when node (if prev (setf (cdr prev) (cdr node)) (setf (%zlist-head zlist) (cdr node))) (unless (cdr node) (setf (%zlist-tail zlist) prev)) (when (eq (%zlist-cursor zlist) node) (setf (%zlist-cursor zlist) prev)) (decf (%zlist-size zlist))))) ;; -------------------------------------------------------------------------- ;; Make copy of itself (defun zlist-dup (zlist) (unless zlist (return-from zlist-dup nil)) (let ((copy (zlist-new))) (dolist (item (%zlist-head zlist)) (zlist-append copy item)))) ;; -------------------------------------------------------------------------- ;; Return the number of items in the list (defun zlist-size (zlist) (%zlist-size zlist)) ;; -------------------------------------------------------------------------- ;; Sort list. This version defers to lisp sort and sets cursor to ;; nil. NOTE: the compare uses the reverse logic of the C zlisp ;; implementation. Lisp's sort algorithm returns t iff ele1 is less ;; than ele2. czmq's zlist_sort returns t iff ele1 is GREATER THAN ;; ele2. (defun zlist-sort (zlist compare &key key) (setf (%zlist-head zlist) (sort (%zlist-head zlist) compare :key key) (%zlist-tail zlist) (last (%zlist-head zlist)) (%zlist-cursor zlist) nil)) ;; -------------------------------------------------------------------------- ;; Runs selftest of class (defun zlist-test (verbose) (declare (ignore verbose)) (format t " * zlist: "); ;; @selftest (let ((list (zlist-new))) (assert list) (assert (zerop (zlist-size list))) ;; Three items we'll use as test data ;; List items are void *, not particularly strings (let ((cheese "boursin") (bread "baguette") (wine "bordeaux")) (zlist-append list cheese) (assert (= (zlist-size list) 1)) (zlist-append list bread) (assert (= (zlist-size list) 2)) (zlist-append list wine) (assert (= (zlist-size list) 3)) (assert (eq (zlist-head list) cheese)) (assert (eq (zlist-next list) cheese)) (assert (eq (zlist-first list) cheese)) (assert (eq (zlist-tail list) wine)) (assert (eq (zlist-next list) bread)) (assert (eq (zlist-first list) cheese)) (assert (eq (zlist-next list) bread)) (assert (eq (zlist-next list) wine)) (assert (eq (zlist-next list) nil)) ;; After we reach end of list, next wraps around (assert (eq (zlist-next list) cheese)) (assert (= (zlist-size list) 3)) (zlist-remove list wine) (assert (= (zlist-size list) 2)) (assert (eq (zlist-first list) cheese)) (zlist-remove list cheese) (assert (= (zlist-size list) 1)) (assert (eq (zlist-first list) bread)) (zlist-remove list bread) (assert (zerop (zlist-size list))) (zlist-append list cheese) (zlist-append list bread) (assert (eq (zlist-last list) bread)) (zlist-remove list bread) (assert (eq (zlist-last list) cheese)) (zlist-remove list cheese) (assert (null (zlist-last list))) (zlist-push list cheese) (assert (= (zlist-size list) 1)) (assert (eq (zlist-first list) cheese)) (zlist-push list bread) (assert (= (zlist-size list) 2)) (assert (eq (zlist-first list) bread)) (zlist-append list wine) (assert (= (zlist-size list) 3)) (assert (eq (zlist-first list) bread)) (zlist-sort list #'string<) (let ((item (zlist-pop list))) (assert (eq item bread))) (let ((item (zlist-pop list))) (assert (eq item wine))) (let ((item (zlist-pop list))) (assert (eq item cheese))) (assert (zerop (zlist-size list))) ;; Destructor should be safe to call twice ;; (especially since its a no-op) (zlist-destroy list) (zlist-destroy list) ;;assert (list == NULL); ;;// @end (format t "OK~%"))))
9,117
Common Lisp
.lisp
230
35.704348
78
0.568694
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
da6c19172612d6bf0865d2f2f31b345e9b7fa0f1ed04f6a581cc07818409b308
20,149
[ -1 ]
20,150
zctx.lisp
lhope_cl-czmq/src/zctx.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defun zctx-new () (zctx_new)) (defun zctx-destroy (zctx) (with-foreign-box (&zctx zctx) (zctx_destroy &zctx) (as-pointer (unbox &zctx :pointer)))) (defmacro with-zctx ((zctx) &body body) `(let ((,zctx (zctx-new))) (unwind-protect (progn ,@body) (zctx-destroy ,zctx)))) (defun zctx-shadow (zctx) (as-pointer (zctx_shadow zctx))) (defun zctx-set-iothreads (zctx iothreads) (zctx_set_iothreads zctx iothreads)) (defun zctx-set-linger (zctx linger) (zctx_set_linger zctx linger)) (defun zctx-set-hwm (zctx hwm) (zctx_set_hwm zctx hwm)) (defun zctx-hwm (zctx) (zctx_hwm zctx)) (defun zctx-underlying (zctx) (as-pointer (zctx_underlying zctx))) (defun zctx-interrupted () (not (zerop zctx_interrupted))) ;;CZMQ_EXPORT int ;; zctx_test (bool verbose); (defun zctx-test (verbose) (declare (ignore verbose)) (format t " * zctx: "); ;; @selftest ;; Create and destroy a context without using it (let ((ctx (assert* (zctx-new)))) (assert (null (zctx-destroy ctx)))) ;; Create a context with many busy sockets, destroy it (let ((ctx (assert* (zctx-new)))) (zctx-set-iothreads ctx 1) (zctx-set-linger ctx 5) ;; 5 msecs ;; using zsocket-new instead of zctx__socket_new (let ((s1 (zsocket-new ctx :zmq-pair)) (s2 (zsocket-new ctx :zmq-xreq)) (s3 (zsocket-new ctx :zmq-req)) (s4 (zsocket-new ctx :zmq-rep)) (s5 (zsocket-new ctx :zmq-pub)) (s6 (zsocket-new ctx :zmq-sub))) (zsocket-connect s1 "tcp://127.0.0.1:5555") (zsocket-connect s2 "tcp://127.0.0.1:5555") (zsocket-connect s3 "tcp://127.0.0.1:5555") (zsocket-connect s4 "tcp://127.0.0.1:5555") (zsocket-connect s5 "tcp://127.0.0.1:5555") (zsocket-connect s6 "tcp://127.0.0.1:5555") (assert (zctx-underlying ctx)) (zctx-destroy ctx)) ;; @end (format t "OK~%") 0))
2,782
Common Lisp
.lisp
75
33.84
71
0.683135
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
b3002c395a09fdd666a0296040af3b71aff74df25be0d90a72fd2d73a6d51736
20,150
[ -1 ]
20,151
zframe.lisp
lhope_cl-czmq/src/zframe.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defun zframe-new (data) (with-foreign-bytes (bytes size data) ;; copies bytes. (zframe_new bytes size))) #+ignore ;; not in 1.4.1 (defun zframe-new-empty () (zframe_new_empty)) (defun zframe-destroy (zframe) "Returns the new value of zframe (should be null pointer)" (with-foreign-box (&zframe zframe) (zframe_destroy &zframe) (as-pointer (unbox &zframe :pointer)))) (defun %zframe-recv (socket) (as-pointer (zframe_recv socket))) ;; retrying zframe-recv (defun zframe-recv (socket &optional (retry *zsys-retry*)) (loop for frame = (%zframe-recv socket) when #+allegro (or frame (let ((errno (zsys-errno))) ;; allegro interrupts with :eok sometimes. Always ;; continue in this case. (unless (eql errno :eok) (or (not retry) (not (eql errno :eintr)))))) #-allegro (or frame (not retry) (not (eql (zsys-errno) :eintr))) return frame)) (defun zframe-recv-nowait (socket) (as-pointer (zframe_recv_nowait socket))) (defun zframe-send (zframe socket &rest zframe-options) ;; note this destroys frame. (with-foreign-box (&zframe zframe) (values (as-rc (zframe_send &zframe socket (bitfield-options 'zframe-options zframe-options))) (as-pointer (unbox &zframe))))) (defun zframe-size (zframe) (zframe_size zframe)) (defun zframe-data (zframe) (let* ((bytes (zframe_data zframe)) (size (zframe-size zframe)) (data (make-array size :element-type '(unsigned-byte 8)))) (dotimes (i size data) (setf (aref data i) (cffi:mem-aref bytes :uchar i))))) (defun zframe-dup (zframe) (zframe_dup zframe)) (defun zframe-strhex (zframe) (with-freed-string (cffi:foreign-funcall "zframe_strhex" :pointer zframe :pointer))) (defun zframe-strdup (zframe) ;; done this way to free the foreign string. (with-freed-string (cffi:foreign-funcall "zframe_strdup" :pointer zframe :pointer))) (defun zframe-streq (zframe string) (as-bool (zframe_streq zframe string))) (defun zframe-more (zframe) (as-bool (zframe_more zframe))) #+ignore ;; not in 1.4.1 (defun zframe-set-more (zframe more) (zframe_set_more zframe (if more 1 0))) (defun zframe-eq (zframe-1 zframe-2) (as-bool (zframe_eq (or zframe-1 (cffi:null-pointer)) (or zframe-2 (cffi:null-pointer))))) ;; no easy way to convert lisp streams to FILE *. ;;// Print contents of the frame to FILE stream. ;;CZMQ_EXPORT void ;; zframe_print_to_stream (zframe_t *self, const char *prefix, FILE *file); (defun zframe-print (zframe prefix) (zframe_print zframe prefix)) (defun zframe-reset (zframe data) (with-foreign-bytes (bytes size data) ;; copies bytes. (zframe_reset zframe bytes size))) ;; // Callback function for zframe_free_fn method ;; // DEPRECATED - will be removed for next stable release ;; typedef void (zframe_free_fn) (void *data, void *arg); ;; // Create a zero-copy frame ;; // DEPRECATED - will be removed for next stable release ;; CZMQ_EXPORT zframe_t * ;; zframe_new_zero_copy (void *data, size_t size, ;; zframe_free_fn *free_fn, void *arg); ;; // Return frame zero copy indicator (1 or 0) ;; // DEPRECATED - will be removed for next stable release ;; CZMQ_EXPORT int ;; zframe_zero_copy (zframe_t *self); ;; // Set the free callback for frame ;; // DEPRECATED - will be removed at next stable release ;; CZMQ_EXPORT void ;; zframe_freefn (zframe_t *self, zframe_free_fn *free_fn, void *arg); ;; -------------------------------------------------------------------------- ;; Selftest (defun zframe-test (verbose) (declare (ignore verbose)) (format t " * zframe: ") ;; @selftest (let* ((ctx (assert* (zctx-new))) (output (assert* (zsocket-new ctx :zmq-pair))) (input (assert* (zsocket-new ctx :zmq-pair)))) (zsocket-bind output "inproc://zframe.test") (zsocket-connect input "inproc://zframe.test") ;; Send five different frames, test ZFRAME_MORE (dotimes (frame-nbr 5) (let ((frame (zframe-new "Hello"))) (assert (zerop (zframe-send frame output :zframe-more))))) ;; Send same frame five times, test ZFRAME_REUSE (let ((frame (assert* (zframe-new "Hello")))) (dotimes (frame-nbr 5) (assert (zerop (zframe-send frame output :zframe-more :zframe-reuse)))) (assert frame) (let ((copy (zframe-dup frame))) (assert (zframe-eq frame copy)) (setf frame (zframe-destroy frame)) (assert (not (zframe-eq frame copy))) (assert (= (zframe-size copy) 5)) (zframe-destroy copy) (assert (not (zframe-eq frame copy))))) ;; Send END frame (let ((frame (assert* (zframe-new "NOT")))) (zframe-reset frame "END") (let ((string (zframe-strhex frame))) (assert (string= string "454E44"))) (let ((string (zframe-strdup frame))) (assert (string= string "END"))) (assert (zerop (zframe-send frame output)))) ;; Read and count until we receive END (loop for frame-nbr from 0 for frame = (zframe-recv input) do (when (zframe-streq frame "END") (zframe-destroy frame) (loop-finish)) (assert (zframe-more frame)) (zframe-destroy frame) finally (assert (= frame-nbr 10)) (assert (null (zframe-recv-nowait input)))) #|| not relevant tests // Test zero copy char *buffer = (char *) malloc (1024); int i; for (i = 0; i < 1024; i++) buffer [i] = 'A'; frame = zframe_new_zero_copy (buffer, 1024, s_test_free_cb, NULL); zframe_t *frame_copy = zframe_dup (frame); assert (zframe_zero_copy (frame) == 1); assert (zframe_zero_copy (frame_copy) == 0); zframe_destroy (&frame); zframe_destroy (&frame_copy); frame = zframe_new ("callback", 8); zframe-freefn (frame, s_test_free_frame_cb, NULL); zframe_destroy (&frame); ||# (zctx-destroy ctx)) ;; @end (format t "OK~%") 0)
6,780
Common Lisp
.lisp
173
35.624277
98
0.666971
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
86ea20ced6f5149a6cdb0be76509baba9697db71809014fa1242c5befc4f9080
20,151
[ -1 ]
20,152
grovel.lisp
lhope_cl-czmq/src/grovel.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (include "zmq.h") (include "czmq.h") (in-package :cl-czmq) ;; czmq defs. (ctype size_t "size_t") (ctype ssize_t "ssize_t") (ctype bool "bool") (ctype mode_t "mode_t") (bitfield zframe-options ((:zframe-more "ZFRAME_MORE")) ((:zframe-reuse "ZFRAME_REUSE")) ((:zframe-dontwait "ZFRAME_DONTWAIT"))) ;; zmq defs. ;; need pollitem, constants from zmq.h (?) (constantenum error-code ;; Standard error codes ((:einval "EINVAL")) ((:enodev "ENODEV")) ((:eintr "EINTR")) ((:efault "EFAULT")) ((:enomem "ENOMEM")) ((:eagain "EAGAIN")) ((:emfile "EMFILE")) ((:enotsup "ENOTSUP")) ((:eprotonosupport "EPROTONOSUPPORT")) ((:enobufs "ENOBUFS")) ((:enetdown "ENETDOWN")) ((:eaddrinuse "EADDRINUSE")) ((:eaddrnotavail "EADDRNOTAVAIL")) ((:econnrefused "ECONNREFUSED")) ((:einprogress "EINPROGRESS")) ((:enotsock "ENOTSOCK")) ;; ZMQ native error codes ((:efsm "EFSM")) ((:enocompatproto "ENOCOMPATPROTO")) ((:eterm "ETERM")) ((:emthread "EMTHREAD"))) (bitfield event-types ((:zmq-pollin "ZMQ_POLLIN")) ((:zmq-pollout "ZMQ_POLLOUT")) ((:zmq-pollerr "ZMQ_POLLERR")) ((:zmq-ignerr "ZMQ_IGNERR"))) (constantenum socket-type ((:zmq-pair "ZMQ_PAIR")) ((:zmq-pub "ZMQ_PUB")) ((:zmq-sub "ZMQ_SUB")) ((:zmq-req "ZMQ_REQ")) ((:zmq-rep "ZMQ_REP")) ((:zmq-dealer "ZMQ_DEALER")) ((:zmq-router "ZMQ_ROUTER")) ((:zmq-pull "ZMQ_PULL")) ((:zmq-push "ZMQ_PUSH")) ((:zmq-xpub "ZMQ_XPUB")) ((:zmq-xsub "ZMQ_XSUB")) ((:zmq-xreq "ZMQ_XREQ")) ((:zmq-xrep "ZMQ_XREP")) ((:zmq-upstream "ZMQ_UPSTREAM")) ((:zmq-downstream "ZMQ_DOWNSTREAM")))
2,954
Common Lisp
.lisp
76
30.381579
71
0.566051
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
e1ad0cd92a2744267aff0a5b8e278ff4da30b5474f666401b2d860232444922c
20,152
[ -1 ]
20,153
ffi.lisp
lhope_cl-czmq/src/ffi.lisp
;;; This file was automatically generated by SWIG (http://www.swig.org). ;;; Version 2.0.10 ;;; ;;; Do not make changes to this file unless you know what you are doing--modify ;;; the SWIG interface file instead. ;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (cffi:define-foreign-library libczmq (t (:default "libczmq"))) (cffi:use-foreign-library libczmq) (cl:defconstant CZMQ_VERSION_MAJOR 1) (cl:defconstant CZMQ_VERSION_MINOR 4) (cl:defconstant CZMQ_VERSION_PATCH 0) (cl:defconstant CZMQ_VERSION (cl:* 1 (cl:+ 10000 4) (cl:+ 100 0))) (cffi:defcfun ("safe_malloc" safe_malloc) :pointer (size size_t) (file :string) (line :unsigned-int) (func :string)) (cl:defconstant ZMQ_POLL_MSEC 1) (cffi:defcfun ("zbeacon_new" zbeacon_new) :pointer (port_nbr :int)) (cffi:defcfun ("zbeacon_destroy" zbeacon_destroy) :void (self_p :pointer)) (cffi:defcfun ("zbeacon_hostname" zbeacon_hostname) :string (self :pointer)) (cffi:defcfun ("zbeacon_set_interval" zbeacon_set_interval) :void (self :pointer) (interval :int)) (cffi:defcfun ("zbeacon_noecho" zbeacon_noecho) :void (self :pointer)) (cffi:defcfun ("zbeacon_publish" zbeacon_publish) :void (self :pointer) (transmit :pointer) (size size_t)) (cffi:defcfun ("zbeacon_silence" zbeacon_silence) :void (self :pointer)) (cffi:defcfun ("zbeacon_subscribe" zbeacon_subscribe) :void (self :pointer) (filter :pointer) (size size_t)) (cffi:defcfun ("zbeacon_unsubscribe" zbeacon_unsubscribe) :void (self :pointer)) (cffi:defcfun ("zbeacon_pipe" zbeacon_pipe) :pointer (self :pointer)) (cffi:defcfun ("zbeacon_test" zbeacon_test) :void (verbose bool)) (cffi:defcfun ("zclock_sleep" zclock_sleep) :void (msecs :int)) (cffi:defcfun ("zclock_log" zclock_log) :void (format :string) &rest) (cffi:defcfun ("zclock_test" zclock_test) :int (verbose bool)) (cffi:defcfun ("zctx_new" zctx_new) :pointer) (cffi:defcfun ("zctx_destroy" zctx_destroy) :void (self_p :pointer)) (cffi:defcfun ("zctx_shadow" zctx_shadow) :pointer (self :pointer)) (cffi:defcfun ("zctx_set_iothreads" zctx_set_iothreads) :void (self :pointer) (iothreads :int)) (cffi:defcfun ("zctx_set_linger" zctx_set_linger) :void (self :pointer) (linger :int)) (cffi:defcfun ("zctx_set_hwm" zctx_set_hwm) :void (self :pointer) (hwm :int)) (cffi:defcfun ("zctx_hwm" zctx_hwm) :int (self :pointer)) (cffi:defcfun ("zctx_underlying" zctx_underlying) :pointer (self :pointer)) (cffi:defcfun ("zctx_test" zctx_test) :int (verbose bool)) (cffi:defcvar ("zctx_interrupted" zctx_interrupted) :int) (cffi:defcfun ("zctx__socket_new" zctx__socket_new) :pointer (self :pointer) (type :int)) (cffi:defcfun ("zctx__socket_destroy" zctx__socket_destroy) :void (self :pointer) (socket :pointer)) (cffi:defcfun ("zfile_exists" zfile_exists) bool (filename :string)) (cffi:defcfun ("zfile_size" zfile_size) ssize_t (filename :string)) (cffi:defcfun ("zfile_mode" zfile_mode) mode_t (filename :string)) (cffi:defcfun ("zfile_delete" zfile_delete) :int (filename :string)) (cffi:defcfun ("zfile_stable" zfile_stable) bool (filename :string)) (cffi:defcfun ("zfile_mkdir" zfile_mkdir) :int (pathname :string)) (cffi:defcfun ("zfile_rmdir" zfile_rmdir) :int (pathname :string)) (cffi:defcfun ("zfile_test" zfile_test) :int (verbose bool)) (cl:defconstant ZFRAME_MORE 1) (cl:defconstant ZFRAME_REUSE 2) (cl:defconstant ZFRAME_DONTWAIT 4) (cffi:defcfun ("zframe_new" zframe_new) :pointer (data :pointer) (size size_t)) (cffi:defcfun ("zframe_new_zero_copy" zframe_new_zero_copy) :pointer (data :pointer) (size size_t) (free_fn :pointer) (arg :pointer)) (cffi:defcfun ("zframe_destroy" zframe_destroy) :void (self_p :pointer)) (cffi:defcfun ("zframe_recv" zframe_recv) :pointer (socket :pointer)) (cffi:defcfun ("zframe_recv_nowait" zframe_recv_nowait) :pointer (socket :pointer)) (cffi:defcfun ("zframe_send" zframe_send) :int (self_p :pointer) (socket :pointer) (flags :int)) (cffi:defcfun ("zframe_size" zframe_size) size_t (self :pointer)) (cffi:defcfun ("zframe_data" zframe_data) :pointer (self :pointer)) (cffi:defcfun ("zframe_dup" zframe_dup) :pointer (self :pointer)) (cffi:defcfun ("zframe_strhex" zframe_strhex) :string (self :pointer)) (cffi:defcfun ("zframe_strdup" zframe_strdup) :string (self :pointer)) (cffi:defcfun ("zframe_streq" zframe_streq) bool (self :pointer) (string :string)) (cffi:defcfun ("zframe_zero_copy" zframe_zero_copy) :int (self :pointer)) (cffi:defcfun ("zframe_more" zframe_more) :int (self :pointer)) (cffi:defcfun ("zframe_eq" zframe_eq) bool (self :pointer) (other :pointer)) (cffi:defcfun ("zframe_print" zframe_print) :void (self :pointer) (prefix :string)) (cffi:defcfun ("zframe_reset" zframe_reset) :void (self :pointer) (data :pointer) (size size_t)) (cffi:defcfun ("zframe_freefn" zframe_freefn) :void (self :pointer) (free_fn :pointer) (arg :pointer)) (cffi:defcfun ("zframe_test" zframe_test) :int (verbose bool)) (cffi:defcfun ("zhash_new" zhash_new) :pointer) (cffi:defcfun ("zhash_destroy" zhash_destroy) :void (self_p :pointer)) (cffi:defcfun ("zhash_insert" zhash_insert) :int (self :pointer) (key :string) (item :pointer)) (cffi:defcfun ("zhash_update" zhash_update) :void (self :pointer) (key :string) (item :pointer)) (cffi:defcfun ("zhash_delete" zhash_delete) :void (self :pointer) (key :string)) (cffi:defcfun ("zhash_lookup" zhash_lookup) :pointer (self :pointer) (key :string)) (cffi:defcfun ("zhash_rename" zhash_rename) :int (self :pointer) (old_key :string) (new_key :string)) (cffi:defcfun ("zhash_freefn" zhash_freefn) :pointer (self :pointer) (key :string) (free_fn :pointer)) (cffi:defcfun ("zhash_size" zhash_size) size_t (self :pointer)) (cffi:defcfun ("zhash_dup" zhash_dup) :pointer (self :pointer)) (cffi:defcfun ("zhash_keys" zhash_keys) :pointer (self :pointer)) (cffi:defcfun ("zhash_foreach" zhash_foreach) :int (self :pointer) (callback :pointer) (argument :pointer)) (cffi:defcfun ("zhash_save" zhash_save) :int (self :pointer) (filename :string)) (cffi:defcfun ("zhash_load" zhash_load) :int (self :pointer) (filename :string)) (cffi:defcfun ("zhash_autofree" zhash_autofree) :void (self :pointer)) (cffi:defcfun ("zhash_test" zhash_test) :void (verbose :int)) (cffi:defcfun ("zlist_new" zlist_new) :pointer) (cffi:defcfun ("zlist_destroy" zlist_destroy) :void (self_p :pointer)) (cffi:defcfun ("zlist_first" zlist_first) :pointer (self :pointer)) (cffi:defcfun ("zlist_last" zlist_last) :pointer (self :pointer)) (cffi:defcfun ("zlist_head" zlist_head) :pointer (self :pointer)) (cffi:defcfun ("zlist_tail" zlist_tail) :pointer (self :pointer)) (cffi:defcfun ("zlist_next" zlist_next) :pointer (self :pointer)) (cffi:defcfun ("zlist_append" zlist_append) :int (self :pointer) (item :pointer)) (cffi:defcfun ("zlist_push" zlist_push) :int (self :pointer) (item :pointer)) (cffi:defcfun ("zlist_pop" zlist_pop) :pointer (self :pointer)) (cffi:defcfun ("zlist_remove" zlist_remove) :void (self :pointer) (item :pointer)) (cffi:defcfun ("zlist_dup" zlist_dup) :pointer (self :pointer)) (cffi:defcfun ("zlist_copy" zlist_copy) :pointer (self :pointer)) (cffi:defcfun ("zlist_size" zlist_size) size_t (self :pointer)) (cffi:defcfun ("zlist_sort" zlist_sort) :void (self :pointer) (compare :pointer)) (cffi:defcfun ("zlist_autofree" zlist_autofree) :void (self :pointer)) (cffi:defcfun ("zlist_test" zlist_test) :void (verbose :int)) (cffi:defcfun ("zloop_new" zloop_new) :pointer) (cffi:defcfun ("zloop_destroy" zloop_destroy) :void (self_p :pointer)) (cffi:defcfun ("zloop_poller" zloop_poller) :int (self :pointer) (item :pointer) (handler :pointer) (arg :pointer)) (cffi:defcfun ("zloop_poller_end" zloop_poller_end) :void (self :pointer) (item :pointer)) (cffi:defcfun ("zloop_timer" zloop_timer) :int (self :pointer) (delay size_t) (times size_t) (handler :pointer) (arg :pointer)) (cffi:defcfun ("zloop_timer_end" zloop_timer_end) :int (self :pointer) (arg :pointer)) (cffi:defcfun ("zloop_set_verbose" zloop_set_verbose) :void (self :pointer) (verbose bool)) (cffi:defcfun ("zloop_start" zloop_start) :int (self :pointer)) (cffi:defcfun ("zloop_test" zloop_test) :void (verbose bool)) (cl:defconstant ZMQ_IGNERR 8) (cffi:defcfun ("zmsg_new" zmsg_new) :pointer) (cffi:defcfun ("zmsg_destroy" zmsg_destroy) :void (self_p :pointer)) (cffi:defcfun ("zmsg_recv" zmsg_recv) :pointer (socket :pointer)) (cffi:defcfun ("zmsg_send" zmsg_send) :int (self_p :pointer) (socket :pointer)) (cffi:defcfun ("zmsg_size" zmsg_size) size_t (self :pointer)) (cffi:defcfun ("zmsg_content_size" zmsg_content_size) size_t (self :pointer)) (cffi:defcfun ("zmsg_push" zmsg_push) :int (self :pointer) (frame :pointer)) (cffi:defcfun ("zmsg_pop" zmsg_pop) :pointer (self :pointer)) (cffi:defcfun ("zmsg_add" zmsg_add) :int (self :pointer) (frame :pointer)) (cffi:defcfun ("zmsg_pushmem" zmsg_pushmem) :int (self :pointer) (src :pointer) (size size_t)) (cffi:defcfun ("zmsg_addmem" zmsg_addmem) :int (self :pointer) (src :pointer) (size size_t)) (cffi:defcfun ("zmsg_pushstr" zmsg_pushstr) :int (self :pointer) (format :string) &rest) (cffi:defcfun ("zmsg_addstr" zmsg_addstr) :int (self :pointer) (format :string) &rest) (cffi:defcfun ("zmsg_popstr" zmsg_popstr) :string (self :pointer)) (cffi:defcfun ("zmsg_wrap" zmsg_wrap) :void (self :pointer) (frame :pointer)) (cffi:defcfun ("zmsg_unwrap" zmsg_unwrap) :pointer (self :pointer)) (cffi:defcfun ("zmsg_remove" zmsg_remove) :void (self :pointer) (frame :pointer)) (cffi:defcfun ("zmsg_first" zmsg_first) :pointer (self :pointer)) (cffi:defcfun ("zmsg_next" zmsg_next) :pointer (self :pointer)) (cffi:defcfun ("zmsg_last" zmsg_last) :pointer (self :pointer)) (cffi:defcfun ("zmsg_save" zmsg_save) :int (self :pointer) (file :pointer)) (cffi:defcfun ("zmsg_load" zmsg_load) :pointer (self :pointer) (file :pointer)) (cffi:defcfun ("zmsg_encode" zmsg_encode) size_t (self :pointer) (buffer :pointer)) (cffi:defcfun ("zmsg_decode" zmsg_decode) :pointer (buffer :pointer) (buffer_size size_t)) (cffi:defcfun ("zmsg_dup" zmsg_dup) :pointer (self :pointer)) (cffi:defcfun ("zmsg_dump" zmsg_dump) :void (self :pointer)) (cffi:defcfun ("zmsg_test" zmsg_test) :int (verbose bool)) (cffi:defcfun ("zmutex_new" zmutex_new) :pointer) (cffi:defcfun ("zmutex_destroy" zmutex_destroy) :void (self_p :pointer)) (cffi:defcfun ("zmutex_lock" zmutex_lock) :void (self :pointer)) (cffi:defcfun ("zmutex_unlock" zmutex_unlock) :void (self :pointer)) (cffi:defcfun ("zmutex_test" zmutex_test) :int (verbose bool)) (cl:defconstant ZSOCKET_DYNFROM #xc000) (cl:defconstant ZSOCKET_DYNTO #xffff) (cffi:defcfun ("zsocket_new" zsocket_new) :pointer (self :pointer) (type :int)) (cffi:defcfun ("zsocket_destroy" zsocket_destroy) :void (self :pointer) (socket :pointer)) (cffi:defcfun ("zsocket_bind" zsocket_bind) :int (socket :pointer) (format :string) &rest) (cffi:defcfun ("zsocket_connect" zsocket_connect) :int (socket :pointer) (format :string) &rest) (cffi:defcfun ("zsocket_disconnect" zsocket_disconnect) :int (socket :pointer) (format :string) &rest) (cffi:defcfun ("zsocket_poll" zsocket_poll) bool (socket :pointer) (msecs :int)) (cffi:defcfun ("zsocket_type_str" zsocket_type_str) :string (socket :pointer)) (cffi:defcfun ("zsocket_test" zsocket_test) :int (verbose bool)) (cffi:defcfun ("zsocket_type" zsocket_type) :int (zocket :pointer)) (cffi:defcfun ("zsocket_sndhwm" zsocket_sndhwm) :int (zocket :pointer)) (cffi:defcfun ("zsocket_rcvhwm" zsocket_rcvhwm) :int (zocket :pointer)) (cffi:defcfun ("zsocket_affinity" zsocket_affinity) :int (zocket :pointer)) (cffi:defcfun ("zsocket_identity" zsocket_identity) :string (zocket :pointer)) (cffi:defcfun ("zsocket_rate" zsocket_rate) :int (zocket :pointer)) (cffi:defcfun ("zsocket_recovery_ivl" zsocket_recovery_ivl) :int (zocket :pointer)) (cffi:defcfun ("zsocket_sndbuf" zsocket_sndbuf) :int (zocket :pointer)) (cffi:defcfun ("zsocket_rcvbuf" zsocket_rcvbuf) :int (zocket :pointer)) (cffi:defcfun ("zsocket_linger" zsocket_linger) :int (zocket :pointer)) (cffi:defcfun ("zsocket_reconnect_ivl" zsocket_reconnect_ivl) :int (zocket :pointer)) (cffi:defcfun ("zsocket_reconnect_ivl_max" zsocket_reconnect_ivl_max) :int (zocket :pointer)) (cffi:defcfun ("zsocket_backlog" zsocket_backlog) :int (zocket :pointer)) (cffi:defcfun ("zsocket_maxmsgsize" zsocket_maxmsgsize) :int (zocket :pointer)) (cffi:defcfun ("zsocket_multicast_hops" zsocket_multicast_hops) :int (zocket :pointer)) (cffi:defcfun ("zsocket_rcvtimeo" zsocket_rcvtimeo) :int (zocket :pointer)) (cffi:defcfun ("zsocket_sndtimeo" zsocket_sndtimeo) :int (zocket :pointer)) (cffi:defcfun ("zsocket_ipv4only" zsocket_ipv4only) :int (zocket :pointer)) (cffi:defcfun ("zsocket_rcvmore" zsocket_rcvmore) :int (zocket :pointer)) (cffi:defcfun ("zsocket_fd" zsocket_fd) :int (zocket :pointer)) (cffi:defcfun ("zsocket_events" zsocket_events) :int (zocket :pointer)) (cffi:defcfun ("zsocket_last_endpoint" zsocket_last_endpoint) :string (zocket :pointer)) (cffi:defcfun ("zsocket_set_sndhwm" zsocket_set_sndhwm) :void (zocket :pointer) (sndhwm :int)) (cffi:defcfun ("zsocket_set_rcvhwm" zsocket_set_rcvhwm) :void (zocket :pointer) (rcvhwm :int)) (cffi:defcfun ("zsocket_set_affinity" zsocket_set_affinity) :void (zocket :pointer) (affinity :int)) (cffi:defcfun ("zsocket_set_subscribe" zsocket_set_subscribe) :void (zocket :pointer) (subscribe :string)) (cffi:defcfun ("zsocket_set_unsubscribe" zsocket_set_unsubscribe) :void (zocket :pointer) (unsubscribe :string)) (cffi:defcfun ("zsocket_set_identity" zsocket_set_identity) :void (zocket :pointer) (identity :string)) (cffi:defcfun ("zsocket_set_rate" zsocket_set_rate) :void (zocket :pointer) (rate :int)) (cffi:defcfun ("zsocket_set_recovery_ivl" zsocket_set_recovery_ivl) :void (zocket :pointer) (recovery_ivl :int)) (cffi:defcfun ("zsocket_set_sndbuf" zsocket_set_sndbuf) :void (zocket :pointer) (sndbuf :int)) (cffi:defcfun ("zsocket_set_rcvbuf" zsocket_set_rcvbuf) :void (zocket :pointer) (rcvbuf :int)) (cffi:defcfun ("zsocket_set_linger" zsocket_set_linger) :void (zocket :pointer) (linger :int)) (cffi:defcfun ("zsocket_set_reconnect_ivl" zsocket_set_reconnect_ivl) :void (zocket :pointer) (reconnect_ivl :int)) (cffi:defcfun ("zsocket_set_reconnect_ivl_max" zsocket_set_reconnect_ivl_max) :void (zocket :pointer) (reconnect_ivl_max :int)) (cffi:defcfun ("zsocket_set_backlog" zsocket_set_backlog) :void (zocket :pointer) (backlog :int)) (cffi:defcfun ("zsocket_set_maxmsgsize" zsocket_set_maxmsgsize) :void (zocket :pointer) (maxmsgsize :int)) (cffi:defcfun ("zsocket_set_multicast_hops" zsocket_set_multicast_hops) :void (zocket :pointer) (multicast_hops :int)) (cffi:defcfun ("zsocket_set_rcvtimeo" zsocket_set_rcvtimeo) :void (zocket :pointer) (rcvtimeo :int)) (cffi:defcfun ("zsocket_set_sndtimeo" zsocket_set_sndtimeo) :void (zocket :pointer) (sndtimeo :int)) (cffi:defcfun ("zsocket_set_ipv4only" zsocket_set_ipv4only) :void (zocket :pointer) (ipv4only :int)) (cffi:defcfun ("zsocket_set_delay_attach_on_connect" zsocket_set_delay_attach_on_connect) :void (zocket :pointer) (delay_attach_on_connect :int)) (cffi:defcfun ("zsocket_set_router_mandatory" zsocket_set_router_mandatory) :void (zocket :pointer) (router_mandatory :int)) (cffi:defcfun ("zsocket_set_router_raw" zsocket_set_router_raw) :void (zocket :pointer) (router_raw :int)) (cffi:defcfun ("zsocket_set_xpub_verbose" zsocket_set_xpub_verbose) :void (zocket :pointer) (xpub_verbose :int)) (cffi:defcfun ("zsocket_set_hwm" zsocket_set_hwm) :void (zocket :pointer) (hwm :int)) (cffi:defcfun ("zsockopt_test" zsockopt_test) :int (verbose bool)) (cffi:defcfun ("zstr_recv" zstr_recv) :string (socket :pointer)) (cffi:defcfun ("zstr_recv_nowait" zstr_recv_nowait) :string (socket :pointer)) (cffi:defcfun ("zstr_send" zstr_send) :int (socket :pointer) (format :string) &rest) (cffi:defcfun ("zstr_sendm" zstr_sendm) :int (socket :pointer) (format :string) &rest) (cffi:defcfun ("zstr_test" zstr_test) :int (verbose bool)) (cffi:defcfun ("zstr_sendf" zstr_sendf) :int (socket :pointer) (format :string) &rest) (cffi:defcfun ("zstr_sendfm" zstr_sendfm) :int (socket :pointer) (format :string) &rest) (cffi:defcfun ("zsys_handler_set" zsys_handler_set) :void (handler_fn :pointer)) (cffi:defcfun ("zsys_handler_reset" zsys_handler_reset) :void) (cffi:defcfun ("zsys_test" zsys_test) :int (verbose bool)) (cffi:defcfun ("zthread_new" zthread_new) :int (thread_fn :pointer) (args :pointer)) (cffi:defcfun ("zthread_fork" zthread_fork) :pointer (ctx :pointer) (thread_fn :pointer) (args :pointer)) (cffi:defcfun ("zthread_test" zthread_test) :int (verbose bool))
18,125
Common Lisp
.lisp
539
31.09462
95
0.720281
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
ca090f16d2d0000ae44b801f6c449f6f0bbd35b0e2287e025b767dd02cfd09a2
20,153
[ -1 ]
20,154
zsocket.lisp
lhope_cl-czmq/src/zsocket.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defconstant +zsocket-dynfrom+ ZSOCKET_DYNFROM) (defconstant +zsocket-dynto+ ZSOCKET_DYNTO) ;;// Callback function for zero-copy methods ;;typedef void (zsocket_free_fn) (void *data, void *arg); (defun zsocket-new (zctx type) (zsocket_new zctx (cffi:foreign-enum-value 'socket-type type))) (defun zsocket-destroy (zctx socket) (zsocket_destroy zctx socket)) (defmacro with-zsockets (zctx (&rest var-type-list) &body body) (let ((g!zctx (gensym))) `(let ((,g!zctx ,zctx)) (let (,@(loop for (var type) in var-type-list collect `(,var (zsocket-new ,g!zctx ,type)))) (unwind-protect (progn ,@body) ,@(loop for (var) in var-type-list collect `(zsocket-destroy ,g!zctx ,var))))))) (defun zsocket-bind (socket fmt &rest args) "Returns the bound port or nil." (as-rc (zsocket_bind socket "%s" :string (apply #'format nil fmt args)))) (defun zsocket-connect (socket fmt &rest args) (as-rc (zsocket_connect socket "%s" :string (apply #'format nil fmt args)))) (defun zsocket-disconnect (socket fmt &rest args) (as-rc (zsocket_disconnect socket "%s" :string (apply #'format nil fmt args)))) (defun zsocket-poll (socket msecs) (as-bool (zsocket_poll socket msecs))) (defun zsocket-type-str (socket) (zsocket_type_str socket)) ;; need zmq_proxy somewhere. Here seems best. ;; always returns nil. (defun zsocket-proxy (frontend backend &optional capture) (as-rc (cffi:foreign-funcall "zmq_proxy" :pointer frontend :pointer backend :pointer (or capture (cffi:null-pointer)) :int))) #+ignore ;; not in 1.4.1 (defun zsocket-sendmem (socket data &rest zframe-options) "If data is a string, uses with-foreign-string. If a (simple-array (unsigned-byte 8), uses with-pointer-to-vector-data. If a vector of unsigned-bytes, copies that vector using with-foreign-object. zsocket_sendmem makes a copy of the data internally, so only the second option escapes multiple memory copy." ;; with-foreign-data could support a list too. (with-foreign-bytes (bytes size data) (as-rc (zsocket_sendmem socket bytes size (bitfield-options 'zframe-options zframe-options))))) ;;CZMQ_EXPORT int ;; zsocket_sendmem_zero_copy (void *socket, void *data, size_t size, ;; zsocket_free_fn *free_fn, ;; void *hint, int flags); (defun zsocket-test (verbose) (declare (ignore verbose)) (format t " * zsocket: ") ;; @selftest (let ((ctx (assert* (zctx-new)))) ;; Create a detached thread, let it run (let ((interf "*") (domain "localhost") (service 5560) (writer (assert* (zsocket-new ctx :ZMQ-PUSH))) (reader (assert* (zsocket-new ctx :ZMQ-PULL)))) (assert (string= (zsocket-type-str writer) "PUSH")) (assert (string= (zsocket-type-str reader) "PULL")) (assert (eql service (zsocket-bind writer "tcp://~a:~d" interf service))) (assert (zerop (zsocket-connect reader "tcp://~a:~d" domain service))) (zstr-send writer "HELLO") (let ((message (zstr-recv reader))) (assert message) (assert (string= message "HELLO"))) (let ((port (zsocket-bind writer "tcp://~a:*" interf))) (assert (and (>= port +zsocket-dynfrom+) (<= port +zsocket-dynto+)))) (assert (not (zsocket-poll writer 100))) ;; deliberate typo (?) (assert (not (zsocket-connect reader "txp://~a:~d" domain service))) (zsocket-destroy ctx writer)) (zctx-destroy ctx)) ;; @end (format t "OK~%") 0)
4,366
Common Lisp
.lisp
96
42.510417
127
0.694464
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
9a413cc02c888976779a553290b8b979e3961602dceba56924b2905bd7aa7928
20,154
[ -1 ]
20,155
zmsg.lisp
lhope_cl-czmq/src/zmsg.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (in-package :cl-czmq) (defun zmsg-new () (zmsg_new)) (defun zmsg-destroy (zmsg) (with-foreign-box (&zmsg zmsg) (zmsg_destroy &zmsg) (as-pointer (unbox &zmsg :pointer)))) (defun %zmsg-recv (socket) (as-pointer (zmsg_recv socket))) ;; retrying zmsg-recv (defun zmsg-recv (socket &optional (retry *zsys-retry*)) (loop for msg = (%zmsg-recv socket) when #+allegro (or msg (let ((errno (zsys-errno))) ;; allegro interrupts with :eok sometimes. Always ;; continue in this case. (unless (eql errno :eok) (or (not retry) (not (eql errno :eintr)))))) #-allegro (or msg (not retry) (not (eql (zsys-errno) :eintr))) when (or msg (not retry) (not (eql (zsys-errno) :eintr))) return msg)) (defun zmsg-send (zmsg socket) (with-foreign-box (&zmsg zmsg) (values (as-rc (zmsg_send &zmsg socket)) (as-pointer (unbox &zmsg :pointer))))) (defun zmsg-size (zmsg) (zmsg_size zmsg)) (defun zmsg-content-size (zmsg) (zmsg_content_size zmsg)) (defun zmsg-push (zmsg zframe) (as-rc (zmsg_push zmsg zframe))) (defun zmsg-pop (zmsg) (as-pointer (zmsg_pop zmsg))) (defun zmsg-add (zmsg zframe) (as-rc (zmsg_add zmsg zframe))) (defun zmsg-pushmem (zmsg data) (with-foreign-bytes (bytes size data) (as-rc (zmsg_pushmem zmsg bytes size)))) (defun zmsg-addmem (zmsg data) (with-foreign-bytes (bytes size data) (as-rc (zmsg_addmem zmsg bytes size)))) (defun zmsg-pushstr (zmsg fmt &rest args) (as-rc (zmsg_pushstr zmsg "%s" :string (apply #'format nil fmt args)))) (defun zmsg-addstr (zmsg fmt &rest args) (as-rc (zmsg_addstr zmsg "%s" :string (apply #'format nil fmt args)))) (defun zmsg-popstr (zmsg) (with-freed-string (cffi:foreign-funcall "zmsg_popstr" :pointer zmsg :pointer))) (defun zmsg-wrap (zmsg zframe) (zmsg_wrap zmsg zframe)) ;; 2013-07-14: issue with c implementation asserts on zframe_size <= 1 (defun zmsg-unwrap (zmsg) (as-pointer (zmsg_unwrap zmsg))) (defun zmsg-remove (zmsg zframe) (zmsg_remove zmsg zframe)) (defun zmsg-first (zmsg) (as-pointer (zmsg_first zmsg))) (defun zmsg-next (zmsg) (as-pointer (zmsg_next zmsg))) (defun zmsg-last (zmsg) (as-pointer (zmsg_last zmsg))) ;; TODO implement lispily. ;;// Save message to an open file, return 0 if OK, else -1. ;;CZMQ_EXPORT int ;; zmsg_save (zmsg_t *self, FILE *file); ;; TODO implement lispily ;;// Load/append an open file into message, create new message if ;;// null message provided. ;;CZMQ_EXPORT zmsg_t * ;; zmsg_load (zmsg_t *self, FILE *file); (defun zmsg-encode (zmsg) (cffi:with-foreign-object (uchar** :pointer) ;; nullify for unwind-protect safety. (setf (cffi:mem-aref uchar** :pointer) (cffi:null-pointer)) (unwind-protect (loop with size = (zmsg_encode zmsg uchar**) ;; allocates uchar* with uchar* = (cffi:mem-aref uchar** :pointer) with bytes = (make-array size :element-type 'unsigned-byte) for i below size do (setf (aref bytes i) (cffi:mem-aref uchar* :uchar i)) finally (return bytes)) (let ((uchar* (cffi:mem-aref uchar** :pointer))) (unless (cffi:null-pointer-p uchar*) (cffi:foreign-free uchar*)))))) ;; the with-foreign-object frees uchar** (defun zmsg-decode (bytes) (with-foreign-bytes (buffer size bytes) (as-pointer (zmsg_decode buffer size)))) (defun zmsg-dup (zmsg) (as-pointer (zmsg_dup zmsg))) ;; // Print message to FILE stream, for debugging ;; CZMQ_EXPORT void ;; zmsg_dump_to_stream (zmsg_t *self, FILE *file); ;; Print message to stderr, for debugging (defun zmsg-dump (zmsg) (zmsg_dump zmsg)) ;; // Push block of memory as new frame to end of message. ;; // The frame is constructed using zero-copy. ;; // Returns 0 on success, -1 on error. ;; // DEPRECATED - will be removed for next stable release ;; CZMQ_EXPORT int ;; zmsg_addmem_zero_copy (zmsg_t *self, void *src, size_t size, zframe_free_fn *free_fn, void *arg); ;; -------------------------------------------------------------------------- ;; Selftest (defun zmsg-test (verbose) (format t " * zmsg: ") ;; @selftest (let* ((ctx (assert* (zctx-new))) (output (assert* (zsocket-new ctx :zmq-pair))) (input (assert* (zsocket-new ctx :zmq-pair)))) (zsocket-bind output "inproc://zmsg.test") (zsocket_connect input "inproc://zmsg.test") ;; Test send and receive of single-frame message (let* ((msg (assert* (zmsg-new))) (frame (assert* (zframe-new "Hello")))) (zmsg-push msg frame) (assert (= (zmsg-size msg) 1)) (assert (= (zmsg-content-size msg) 5)) (multiple-value-bind (rc msg) (zmsg-send msg output) (assert (null msg)) (assert (zerop rc)))) (let ((msg (assert* (zmsg-recv input)))) (assert (= (zmsg-size msg) 1)) (assert (= (zmsg-content-size msg) 5)) (zmsg-destroy msg)) ;; Test send and receive of multi-frame message (let ((msg (assert* (zmsg-new)))) (assert (zerop (zmsg-addmem msg "Frame0"))) (assert (zerop (zmsg-addmem msg "Frame1"))) (assert (zerop (zmsg-addmem msg "Frame2"))) (assert (zerop (zmsg-addmem msg "Frame3"))) (assert (zerop (zmsg-addmem msg "Frame4"))) (assert (zerop (zmsg-addmem msg "Frame5"))) (assert (zerop (zmsg-addmem msg "Frame6"))) (assert (zerop (zmsg-addmem msg "Frame7"))) (assert (zerop (zmsg-addmem msg "Frame8"))) (assert (zerop (zmsg-addmem msg "Frame9"))) (let ((copy (assert* (zmsg-dup msg)))) (assert (zerop (zmsg-send copy output)))) (assert (zerop (zmsg-send msg output)))) (let ((copy (assert* (zmsg-recv input)))) (assert (= (zmsg-size copy) 10)) (assert (= (zmsg-content-size copy) 60)) (zmsg-destroy copy)) (let ((msg (assert* (zmsg-recv input)))) (assert (= (zmsg-size msg) 10)) (assert (= (zmsg-content-size msg) 60)) (when verbose (zmsg-dump msg)) ;; Save to a file, read back #|| FILE *file = fopen ("zmsg.test", "w"); assert (file); rc = zmsg_save (msg, file); assert (rc == 0); fclose (file); file = fopen ("zmsg.test", "r"); rc = zmsg_save (msg, file); assert (rc == -1); fclose (file); zmsg_destroy (&msg); file = fopen ("zmsg.test", "r"); msg = zmsg_load (NULL, file); assert (msg); fclose (file); remove ("zmsg.test"); assert (zmsg_size (msg) == 10); assert (zmsg_content_size (msg) == 60); ||# ;; Remove all frames except first and last (dotimes (frame_nbr 8) (zmsg-first msg) (let ((frame (zmsg-next msg))) (zmsg-remove msg frame) (zframe-destroy frame))) ;; Test message frame manipulation (assert (= (zmsg-size msg) 2)) (let ((frame (zmsg-last msg))) (assert (zframe-streq frame "Frame9"))) (assert (= (zmsg-content-size msg) 12)) (let ((frame (assert* (zframe-new "Address")))) (zmsg-wrap msg frame)) (assert (= (zmsg-size msg) 4)) (assert (zerop (zmsg-addstr msg "Body"))) (assert (= (zmsg-size msg) 5)) (let ((frame (zmsg-unwrap msg))) (zframe-destroy frame)) (assert (= (zmsg_size msg) 3)) (let ((body (zmsg-popstr msg))) (assert (string= body "Frame0"))) (zmsg-destroy msg)) ;; Test encoding/decoding (let ((msg (assert* (zmsg_new)))) (flet ((blank (size) (make-array size :element-type '(unsigned-byte 8) :initial-element 0))) (assert (zerop (zmsg-addmem msg (blank 0)))) (assert (zerop (zmsg-addmem msg (blank 1)))) (assert (zerop (zmsg-addmem msg (blank 253)))) (assert (zerop (zmsg-addmem msg (blank 254)))) (assert (zerop (zmsg-addmem msg (blank 255)))) (assert (zerop (zmsg-addmem msg (blank 256)))) (assert (zerop (zmsg-addmem msg (blank 65535)))) (assert (zerop (zmsg-addmem msg (blank 65536)))) (assert (zerop (zmsg-addmem msg (blank 65537))))) (assert (= (zmsg-size msg) 9)) (let ((buffer (zmsg-encode msg))) (zmsg-destroy msg) (setf msg (assert* (zmsg-decode buffer))) (zmsg-destroy msg))) ;; Now try methods on an empty message (let ((msg (assert* (zmsg-new)))) (assert (zerop (zmsg-size msg))) (assert (null (zmsg-first msg))) (assert (null (zmsg-last msg))) (assert (null (zmsg-next msg))) (assert (null (zmsg-pop msg))) (zmsg-destroy msg)) (zctx-destroy ctx)) ;; @end (format t "OK~%") 0)
9,299
Common Lisp
.lisp
245
33.795918
104
0.639352
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
763b86c54ce77ddc54e3fe5e69d24d2e3ca1752fa5a46857fe5e8b1c109911ae
20,155
[ -1 ]
20,156
zthread.lisp
lhope_cl-czmq/src/zthread.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; This is a direct port of czmq/src/zthread.c which is ;; Copyright (c) 1991-2013 iMatix Corporation <www.imatix.com> ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; @header ;; The zthread class wraps OS thread creation. It creates detached threads ;; that look like normal OS threads, or attached threads that share the ;; caller's 0MQ context, and get an inproc pipe to talk back to the parent ;; thread. Detached threads create their own 0MQ contexts as needed. ;; @discuss ;; We have several use cases for multiple threads. One is to simulate many ;; processes, so we can test 0MQ designs and flows more easily. Another is ;; to create APIs that can send and receive 0MQ messages in the background. ;; zthread solves these two use cases separately, using the zthread_new ;; and zthead_fork methods respectively. These methods wrap the native ;; system calls needed to start threads, so your code can remain fully ; portable. ;; Detached threads follow the POSIX pthreads API; they accept a void * ;; argument and return a void * result (always NULL in our case). ;; Attached thread receive a void * argument, a zctx_t context, and a pipe ;; socket. The pipe socket is a PAIR socket that is connected back to the ;; caller. When you call zthread_fork, it returns you a PAIR socket that ;; is the other end of this pipe. Thus attached threads can talk back to ;; their parent threads over the pipe. We use this very heavily when making ;; so-called "asynchronous" APIs, which you can see in the Guide examples ;; like 'clone'. ;; To recap some rules about threading: do not share sockets between ;; threads or your code will crash. You can migrate a socket from one ;; thread to a child thread, if you stop using it in the parent thread ;; immediately after creating the child thread. If you want to connect ;; sockets over inproc:// they must share the same 0MQ context, i.e. be ;; attached threads. You should always use zthread_fork to create an ;; attached thread; it is not sufficient to pass a zctx_t structure to ;; a detached thread (this will crash). ;; If you want to communicate over ipc:// or tcp:// you may be sharing ;; the same context, or use separate contexts. Thus, every detached thread ;; usually starts by creating its own zctx_t instance. (in-package :cl-czmq) ;; -------------------------------------------------------------------------- ;; Create a detached thread. A detached thread operates autonomously ;; and is used to simulate a separate process. It gets no ctx, and no ;; pipe. Returns the resultant thread. (defun zthread-new (thread-fn &rest args) (bordeaux-threads:make-thread (lambda () (with-zsys-retry (t) (apply thread-fn args))))) ;; -------------------------------------------------------------------------- ;; Create an attached thread. An attached thread gets a ctx and a PAIR ;; pipe back to its parent. It must monitor its pipe, and exit if the ;; pipe becomes unreadable. Returns pipe, or nil if there was an error. ;; On success, returns the thread as a second value. ;; ;; Note the thread-fn has different argument order from czmq's zthread-fork - ;; (thread-fn ctx pipe &rest args) rather than (thread-fn args ctx pipe). (defun zthread-fork (ctx thread-fn &rest args) ;; Create our end of the pipe (let* ((pipe (zsocket-new ctx :zmq-pair)) (name (format nil "inproc://zctx-pipe-0x~8,'0x" (cffi:pointer-address pipe)))) (if pipe (zsocket-bind pipe name) (return-from zthread-fork)) ;; Prepare argument shim for child thread (let* ((shim->ctx (or (zctx-shadow ctx) (return-from zthread-fork))) (shim->pipe (or (zsocket-new shim->ctx :zmq-pair) (return-from zthread-fork)))) ;; Connect child pipe to our pipe (zsocket-connect shim->pipe name) (values pipe (bordeaux-threads:make-thread (lambda () (with-zsys-retry (t) (apply thread-fn shim->ctx shim->pipe args) (zctx-destroy shim->ctx))) :name name))))) ;; -------------------------------------------------------------------------- ;; Selftest (defun s-test-detached (&rest args) (declare (ignore args)) ;; Create a socket to check it'll be automatically deleted (with-zctx (ctx) (assert ctx) (assert (zsocket-new ctx :zmq-push)))) (defun s-test-attached (ctx pipe &rest args) (declare (ignore args)) ;; Create a socket to check it'll be automatically deleted (zsocket-new ctx :ZMQ-PUSH) ;; Wait for our parent to ping us, and pong back (zstr-recv pipe) (zstr-send pipe "pong")) (defun zthread-test (verbose) (declare (ignore verbose)) (format t " * zthread: ") ;; @selftest (with-zctx (ctx) (assert ctx) ;; Create a detached thread, let it run (assert (zthread-new #'s-test-detached)) ;; Create an attached thread, check it's safely alive (let ((pipe (zthread-fork ctx #'s-test-attached))) (assert pipe) (zstr-send pipe "ping") (let ((pong (zstr-recv pipe))) (assert (string= pong "pong"))))) (format t "OK~%") 0)
6,050
Common Lisp
.lisp
125
45.64
80
0.684469
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
501c0aa5f8459167544d81c8aef2a4a132f8b6807807fe19262f11ae0b3cb0a2
20,156
[ -1 ]
20,157
zclock.lisp
lhope_cl-czmq/src/zclock.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. ;; @header ;; The zclock class provides essential sleep and system time functions, used ;; to slow down threads for testing, and calculate timers for polling. Wraps ;; the non-portable system calls in a simple portable API. ;; @discuss ;; The Win32 Sleep() call defaults to 16ms resolution unless the system timer ;; resolution is increased with a call to timeBeginPeriod() permitting 1ms ;; granularity. ;; @end (in-package :cl-czmq) ;; -------------------------------------------------------------------------- ;; Sleep for a number of milliseconds #-allegro (defun zclock-sleep (msecs) (zclock_sleep msecs)) ;; alternate zclock-sleep implementation for allegro. #+allegro (setf (sys::thread-control :clock-event-delta) 0) #+allegro (defun zclock-sleep (msecs) (sleep (* 0.001 msecs))) ;; -------------------------------------------------------------------------- ;; Return current system clock as milliseconds #-allegro (defun zclock-time () (cffi:foreign-funcall "zclock_time" :int64)) #+allegro (defconstant +milli-multiplier+ (/ 1000 internal-time-units-per-second)) #+allegro (defun zclock-time () "Note - this is not a real time, it is for use just as comparison with itself." (floor (* (get-internal-real-time) +milli-multiplier+))) ;; -------------------------------------------------------------------------- ;; Print formatted string to stdout, prefixed by date/time and ;; terminated with a newline. (let (dst tz) (defun zclock-log (fmt &rest args) (unless tz (destructuring-bind (dst1 tz1) (nthcdr 7 (multiple-value-list (decode-universal-time (get-universal-time)))) (setf dst dst1 tz tz1))) (flet ((iso-8601-time () (multiple-value-bind (second minute hour date month year) (decode-universal-time (get-universal-time) (- tz (if dst 1 0))) (format nil "~D-~2,'0D-~2,'0D ~D:~2,'0D:~2,'0D" year month date hour minute second)))) (format t "~A " (iso-8601-time))) (apply #'format t fmt args) (fresh-line))) (defun zclock-test (verbose) (declare (ignore verbose)) (format t " * zclock: ") ;; @selftest (let ((start (zclock-time))) (zclock-sleep 10) (assert (>= (- (zclock-time) start) 10)) ;; @end (format t "OK~%")) 0)
3,137
Common Lisp
.lisp
78
37.769231
81
0.661301
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
29b4a8ee8a3ca29254d161d230cc1530d6f2cd91c890983075eac8a5c3844ffb
20,157
[ -1 ]
20,158
test.lisp
lhope_cl-czmq/tests/test.lisp
;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (ql:quickload "cl-czmq") (use-package :cl-czmq) (zctx-test t) (zclock-test t) (zsocket-test t) (zsockopt-test t) (zframe-test t) (zstr-test t) (zmsg-test t) (zloop-test t) (zbeacon-test t) (zthread-test t) (zlist-test t) (zhash-test t)
1,123
Common Lisp
.lisp
32
34
71
0.755515
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
9bad31022853036d45f112545a3a52ecbe185606a0e56220b11773e4b574925d
20,158
[ -1 ]
20,159
cl-czmq.asd
lhope_cl-czmq/cl-czmq.asd
;;;; -*- Mode: LISP -*- ;; Copyright (c) 2013, Lucas Hope <[email protected]>. ;; Copyright other contributors as noted in the AUTHORS file. ;; ;; This file is part of cl-czmq - a re-binding of the C binding for ;; the zmq transport layer (czmq). ;; ;; This file is licensed under the terms of the LLGPL. ;; ;; This library is free software; you can redistribute it and/or modify ;; it under the terms of the Lisp Lesser General Public License version ;; 3, which consists of the GNU Lesser General Public License, either ;; version 3 or (at your option) any later version, as published by the ;; Free Software Foundation, and the Franz preamble. ;; ;; This library is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; Lesser General Public License for more details. (cl:eval-when (:load-toplevel :execute) (asdf:operate 'asdf:load-op 'cffi-grovel)) (asdf:defsystem :cl-czmq :name "cl-czmq" :version "0.1.0" :author "Lucas Hope <[email protected]>" :license "LLGPL" :maintainer "Lucas Hope <[email protected]" :description "A re-binding of the C binding for the zmq transport layer (czmq)." :depends-on (:cffi :bordeaux-threads) :components ((:module "src" :serial t :components ((:file "package") (cffi-grovel:grovel-file "grovel") (:file "ffi") (:file "ffi-utils") (:file "czmq") (:file "zsys") (:file "zctx") (:file "zsocket") (:file "zsockopt") (:file "zframe") (:file "zstr") (:file "zmsg") (:file "zpollset") (:file "zclock") (:file "zloop") (:file "zbeacon") (:file "zthread") (:file "zlist") (:file "zhash")))))
1,874
Common Lisp
.asd
50
32.42
82
0.644896
lhope/cl-czmq
2
3
0
LGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
1f755e026bb6c83eef0cf717c8b44f8298b4418f35e094c195a41d6dd6d5cdbc
20,159
[ -1 ]
20,197
binary-sbcl.lisp
alessiostalla_portofino-cli-lisp/src/binary-sbcl.lisp
(when cl+ssl::*ssl-global-context* (cl+ssl:ssl-ctx-free cl+ssl::*ssl-global-context*) (setf cl+ssl::*ssl-global-context* nil)) (map nil #'cffi:close-foreign-library (cffi:list-foreign-libraries))
201
Common Lisp
.lisp
4
48
68
0.72449
alessiostalla/portofino-cli-lisp
2
0
1
AGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
b2d9e89b84ab8e6d1e6983117423c1d26b7ed5d7f49f237b80485d77d300ed2b
20,197
[ -1 ]
20,198
portofino.lisp
alessiostalla_portofino-cli-lisp/src/portofino.lisp
(in-package :portofino) (defun latest-portofino-version () (let* ((drakma:*text-content-types* '(("application" . "json"))) (resp (drakma:http-request "http://search.maven.org/solrsearch/select" :parameters '(("q" . "g:com.manydesigns AND a:portofino") ("start" . "0") ("rows" . "1")))) (json (with-input-from-string (s resp) (json:decode-json s)))) (cdr (find-if (lambda (x) (and (listp x) (eq (car x) :latest-version))) (cadr (find-if (lambda (x) (and (listp x) (eq (car x) :docs))) (find-if (lambda (x) (eq (car x) :response)) json))))))) (defvar *maven-command* "mvn") (defparameter *latest-portofino-version* (or (ignore-errors (latest-portofino-version)) "5.3.4")) (defvar *default-connection-timeout* 10) (defvar *default-portofino-url* "http://localhost:8080") (defvar *portofino-version-6* (semver:read-version-from-string "6.0.0")) (defun archetype-name (kw version) (let ((version (semver:read-version-from-string version))) (cond ((eq kw :service) "portofino-service-full-archetype") ((eq kw :minimal) "portofino-service-minimal-archetype") ((and (version< version *portofino-version-6*) (eq kw :webapp)) "portofino-war-archetype") (t (error "Not a known application type: ~A" type))))) (defun check-maven-installation () (uiop:run-program `(,*maven-command* "-version"))) (defun create-application (name package &key (type :service) (version "1.0.0-SNAPSHOT") (portofino-version *latest-portofino-version*)) (check-maven-installation) (uiop:run-program `(,*maven-command* "archetype:generate" "-DinteractiveMode=false" "-DarchetypeGroupId=com.manydesigns" ,(format nil "-DarchetypeArtifactId=~A" (archetype-name type portofino-version)) ,(format nil "-DarchetypeVersion=~A" portofino-version) ,(format nil "-DgroupId=~A" package) ,(format nil "-DartifactId=~A" name) ,(format nil "-Dversion=~A" version) ,(format nil "-Dpackage=~A" package)) :output t :error-output t)) (defun sanitize-base-url (url) (loop :while (and (> (length url) 0) (char= (aref url (1- (length url))) #\/)) :do (setf url (subseq url 0 (1- (length url))))) url) (defun resource-url (base-url path) (format nil "~A/~A" (sanitize-base-url base-url) path)) (defun maybe-decode (content) (typecase content (string content) (vector (flexi-streams:octets-to-string content)) (t content))) (defun decode-severity (sev-str) (cond ((equal sev-str "info") :info) ((equal sev-str "warning") :warning) ((equal sev-str "error") :error) (t :unknown))) (defmacro with-http-request ((method url (&optional (text (gensym "TEXT")) (status (gensym "STATUS")) (headers (gensym "HEADERS"))) &rest args) &body body) (let ((portofino-messages (gensym "MESSAGES"))) `(multiple-value-bind (,text ,status ,headers) (drakma:http-request ,url :method ,method ,@args :connection-timeout *default-connection-timeout*) (let ((,portofino-messages (drakma:header-value :x-portofino-message ,headers))) (when ,headers (let ((,portofino-messages (split-sequence #\, ,portofino-messages))) (dolist (msg ,portofino-messages) (let ((pos (position #\: msg))) (when pos (signal 'log-message-received :severity (decode-severity (subseq msg 0 pos)) :message (string-trim " " (subseq msg (1+ pos))))))))) (if (and (>= ,status 200) (< ,status 300)) (progn ,@body) (cond ((= ,status 401) (error 'authentication-required :url url)) ((= ,status 403) (error 'not-authorized :url url)) ((= ,status 404) (error 'not-found :url url)) (t (error "Request failed: ~S, ~A ~A, message: ~S" ,status ,method ,url (maybe-decode ,text))))))))) (defun login (username password &key (url *default-portofino-url*)) (unless (and username password) (error "Username and password are required.")) (let ((drakma:*text-content-types* '(("application" . "json"))) (url (resource-url url ":auth"))) (with-http-request (:post url (text) :parameters `(("username" . ,username) ("password" . ,password))) (json:decode-json-from-string text)))) (defun resolve-directory (base &rest path) (merge-pathnames (make-pathname :directory (append (pathname-directory base) path)) base)) (defun resolve-file (base &rest path) (merge-pathnames (make-pathname :name (car (last path))) (apply #'resolve-directory base (butlast path)))) (define-condition http-error (error) ((url :initarg :url :reader http-error-url))) (define-condition authentication-required (http-error) ()) (define-condition not-authorized (http-error) ()) (define-condition not-found (http-error) ()) (define-condition log-message-received (condition) ((severity :initarg :severity :reader log-message-severity) (message :initarg :message :reader log-message))) (defun authorization-header (token) `("Authorization" . ,(format nil "Bearer ~A" token))) (defun action-types (&key (url *default-portofino-url*) token) (let ((drakma:*text-content-types* '(("application" . "json"))) (url (resource-url url "portofino-upstairs/actions/:types"))) (with-http-request (:get url (text) :additional-headers (list (authorization-header token))) (let ((json:*json-identifier-name-to-lisp* #'identity)) (json:decode-json-from-string text))))) (defun create-action (type action-path &key (url *default-portofino-url*) token) (let ((url (resource-url url (format nil "portofino-upstairs/actions/~A" action-path)))) (with-http-request (:post url (text) :content type :additional-headers (list (authorization-header token))) text))) (defun delete-action (action-path &key (url *default-portofino-url*) token) (let ((url (resource-url url (format nil "portofino-upstairs/actions/~A" action-path)))) (with-http-request (:delete url () :additional-headers (list (authorization-header token))) t))) (defun copy-or-move-action (from to &key (url *default-portofino-url*) token (copy t)) (let ((url (resource-url url (format nil "portofino-upstairs/actions/~A" to)))) (with-http-request (:post url (text) :content-type (if copy "application/vnd.com.manydesigns.portofino.action-copy" "application/vnd.com.manydesigns.portofino.action-move") :content from :additional-headers (list (authorization-header token))) text))) (defun synchronize-database (name &key (url *default-portofino-url*) token) (let ((url (resource-url url (format nil "portofino-upstairs/database/connections/~A/:synchronize" name)))) (with-http-request (:post url () :additional-headers (list (authorization-header token))) t))) (defun db-descriptor (name driver url username password dialect jndi-resource) (cl-json:encode-json-to-string (remove-if #'null (list (cons 'database-name name) (cons 'driver driver) (cons 'url url) (cons 'username username) (cons 'password password) (cons 'hibernate-dialect dialect) (cons 'jndi-resource jndi-resource)) :key #'cdr))) (defun create-database (name &key (url *default-portofino-url*) token driver jdbc-url username password dialect jndi-resource schemas) (unless (and (or jdbc-url jndi-resource) (or (null jdbc-url) (null jndi-resource))) (error "Exactly one of jdbc-url and jndi-resource is required")) (let ((url (resource-url url "portofino-upstairs/database/connections"))) (with-http-request (:post url () :content-type "application/json" :content (db-descriptor name driver jdbc-url username password dialect jndi-resource) :additional-headers (list (authorization-header token))) t))) (defun remove-database (name &key (url *default-portofino-url*) token) (let ((url (resource-url url (format nil "portofino-upstairs/database/connections/~A" name)))) (with-http-request (:delete url () :additional-headers (list (authorization-header token))) t))) (defun update-database (name &key (url *default-portofino-url*) token driver jdbc-url username password dialect jndi-resource schemas) (if (and jdbc-url jndi-resource) (error "Please provide either a jdbc-url or a jndi-resource, not both")) (let ((url (resource-url url (format nil "portofino-upstairs/database/connections/~A" name)))) (with-http-request (:put url () :content-type "application/json" :content (db-descriptor name driver jdbc-url username password dialect jndi-resource) :additional-headers (list (authorization-header token))) t))) (defun add-database-schema (db-name schema-name schema-physical-name &key (url *default-portofino-url*) token) (let ((url (resource-url url (format nil "portofino-upstairs/database/connections/~A/~A" db-name schema-name)))) (with-http-request (:post url () :content schema-physical-name :additional-headers (list (authorization-header token))) t)))
9,155
Common Lisp
.lisp
179
45.458101
135
0.670691
alessiostalla/portofino-cli-lisp
2
0
1
AGPL-3.0
9/19/2024, 11:28:00 AM (Europe/Amsterdam)
63f7b740e3ae5784d3562b4b0f59ea563758d2fe6269f20dd9f066ebc1ec585a
20,198
[ -1 ]