1.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2+++ b/.hgignore Sun Apr 30 22:01:32 2023 -0400
1.3@@ -0,0 +1,4 @@
1.4+out/.*
1.5+.*Cargo.lock$
1.6+.*target/.*
1.7+.*[.]fasl$
1.8\ No newline at end of file
2.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2+++ b/Cargo.toml Sun Apr 30 22:01:32 2023 -0400
2.3@@ -0,0 +1,16 @@
2.4+[package]
2.5+name = "cl-demo-rs"
2.6+version = "0.1.0"
2.7+edition = "2021"
2.8+build = "build.rs"
2.9+[lib]
2.10+path = "lib.rs"
2.11+crate-type = ["cdylib"]
2.12+[workspace]
2.13+members = ["cfg","obj"]
2.14+[dependencies]
2.15+libc = "0.2"
2.16+obj = {version = "0.1.0",path = "obj"}
2.17+cfg = {version = "0.1.0",path = "cfg"}
2.18+[build-dependencies]
2.19+cbindgen = "0.20"
2.20\ No newline at end of file
4.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2+++ b/build.rs Sun Apr 30 22:01:32 2023 -0400
4.3@@ -0,0 +1,18 @@
4.4+use std::env;
4.5+use std::fs::create_dir;
4.6+use std::path::PathBuf;
4.7+fn main() {
4.8+ let crate_dir: PathBuf = env::var("CARGO_MANIFEST_DIR")
4.9+ .expect("CARGO_MANIFEST_DIR env var is not defined")
4.10+ .into();
4.11+ let mpk_py = "build.py";
4.12+ let config = cbindgen::Config::from_file("cbindgen.toml")
4.13+ .expect("Unable to find cbindgen.toml configuration file");
4.14+ let build_dir = crate_dir.join("build/");
4.15+ if !build_dir.exists() {
4.16+ create_dir(&build_dir).unwrap();
4.17+ }
4.18+ cbindgen::generate_with_config(&crate_dir, config)
4.19+ .unwrap()
4.20+ .write_to_file(build_dir.join("mpk_ffi.h"));
4.21+}
5.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2+++ b/cbindgen.toml Sun Apr 30 22:01:32 2023 -0400
5.3@@ -0,0 +1,11 @@
5.4+include_guard = "mpk_ffi_h"
5.5+autogen_warning = "/* DO NOT TOUCH */"
5.6+include_version = true
5.7+language = "C"
5.8+cpp_compat = true
5.9+line_length = 88
5.10+
5.11+[parse]
5.12+parse_deps = true
5.13+include = ["mpk_config", "mpk_hash"]
5.14+extra_bindings = ["mpk_hash", "mpk_config"]
6.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2+++ b/cfg/Cargo.toml Sun Apr 30 22:01:32 2023 -0400
6.3@@ -0,0 +1,6 @@
6.4+[package]
6.5+name = "cfg"
6.6+version = "0.1.0"
6.7+edition = "2021"
6.8+[dependencies]
6.9+serde_dhall = "0.12.1"
6.10\ No newline at end of file
7.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2+++ b/cfg/src/lib.rs Sun Apr 30 22:01:32 2023 -0400
7.3@@ -0,0 +1,14 @@
7.4+pub fn add(left: usize, right: usize) -> usize {
7.5+ left + right
7.6+}
7.7+
7.8+#[cfg(test)]
7.9+mod tests {
7.10+ use super::*;
7.11+
7.12+ #[test]
7.13+ fn it_works() {
7.14+ let result = add(2, 2);
7.15+ assert_eq!(result, 4);
7.16+ }
7.17+}
8.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2+++ b/cl-demo.asd Sun Apr 30 22:01:32 2023 -0400
8.3@@ -0,0 +1,37 @@
8.4+(asdf:defsystem "cl-demo"
8.5+ :version "1.0.0"
8.6+ :author "ellis <ellis@rwest.io>"
8.7+ :maintainer "ellis <ellis@rwest.io>"
8.8+ :description ""
8.9+ :homepage "https://rwest.io/p/cl-demo"
8.10+ :bug-tracker "https://gitlab.rwest.io/ellis/cl-demo/issues"
8.11+ :source-control (:hg "https://gitlab.rwest.io/ellis/cl-demo")
8.12+ :license "WTFPL"
8.13+ :depends-on (:bordeaux-threads
8.14+ #+(or ccl sbcl)
8.15+ :clack
8.16+ :caveman2
8.17+ :clog
8.18+ :cl-rocksdb
8.19+ :verbose
8.20+ :alexandria
8.21+ :cl-ppcre
8.22+ :cffi
8.23+ :clingon)
8.24+ :serial T
8.25+ :components ((:file "pkg")
8.26+ (:file "tk")
8.27+ (:file "db")
8.28+ (:file "ui")
8.29+ (:file "demo"))
8.30+ ;; :in-order-to ((test-op (test-op "cl-demo/tests")))
8.31+ ;; :defsystem-depends-on (:deploy)
8.32+ ;; :build-operation "deploy"
8.33+ :build-pathname "cl-demo"
8.34+ :entry-point "cl-demo:main")
8.35+
8.36+;; (asdf:defsystem "cl-demo:tests"
8.37+ ;; :depends-on ("cl-demo" "fiveam")
8.38+ ;; :components ((:file "tests"))
8.39+ ;; :perform (test-op (o c) (symbol-call :fiveam '#:run! :cl-demo))
8.40+ ;; )
9.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
9.2+++ b/db.lisp Sun Apr 30 22:01:32 2023 -0400
9.3@@ -0,0 +1,2 @@
9.4+(in-package :cl-demo)
9.5+
10.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
10.2+++ b/demo.lisp Sun Apr 30 22:01:32 2023 -0400
10.3@@ -0,0 +1,38 @@
10.4+;; demo.lisp
10.5+(in-package :cl-demo)
10.6+
10.7+(defparameter demo-path (merge-pathnames "cl-demo" (uiop:temporary-directory)))
10.8+
10.9+(defvar db-path (merge-pathnames "db" demo-path))
10.10+
10.11+(defun cli-opts ()
10.12+ "Returns the top-level CLI options."
10.13+ (list
10.14+ (cli:make-option
10.15+ :string
10.16+ :description "demo app to run"
10.17+ :short-name #\x
10.18+ :long-name "app"
10.19+ :initial-value "client"
10.20+ :env-vars '("DEMO_APP")
10.21+ :key :app)))
10.22+
10.23+(defun cli-handler (cmd)
10.24+ "Handler for the `demo' command."
10.25+ (let ((app (cli:getopt cmd :app)))
10.26+ (format t "running app: ~A!~%" app)))
10.27+
10.28+(defun cli-cmd ()
10.29+ "Our demo command."
10.30+ (cli:make-command
10.31+ :name "demo"
10.32+ :description "A collection of demos"
10.33+ :version "1.0.0"
10.34+ :authors '("ellis <ellis@rwest.io>")
10.35+ :license "WTFPL"
10.36+ :options (demo/opts)
10.37+ :handler #'demo/handler))
10.38+
10.39+(defun main ()
10.40+ "A demo of some common-lisp functionality."
10.41+ (cli:run (demo/cmd)))
12.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
12.2+++ b/ffi/mpk_ffi.h Sun Apr 30 22:01:32 2023 -0400
12.3@@ -0,0 +1,13 @@
12.4+#ifndef mpk_ffi_h
12.5+#define mpk_ffi_h
12.6+
12.7+/* Generated with cbindgen:0.20.0 */
12.8+
12.9+/* DO NOT TOUCH */
12.10+
12.11+#include <stdarg.h>
12.12+#include <stdbool.h>
12.13+#include <stdint.h>
12.14+#include <stdlib.h>
12.15+
12.16+#endif /* mpk_ffi_h */
13.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
13.2+++ b/lib.rs Sun Apr 30 22:01:32 2023 -0400
13.3@@ -0,0 +1,1 @@
13.4+//! cl-demo-rs
14.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
14.2+++ b/makefile Sun Apr 30 22:01:32 2023 -0400
14.3@@ -0,0 +1,10 @@
14.4+L ?= sbcl
14.5+O ?= /tmp/cl-demo
14.6+.PHONY:build
14.7+$(O):;mkdir -p $@
14.8+clean:;rm -rf out *.fasl;cargo clean
14.9+build:;ros/build.ros
14.10+docs:;ros/docs.ros
14.11+test:;ros/test.ros
14.12+pack:;ros/pack.ros
14.13+ci:clean build docs test pack;
15.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
15.2+++ b/obj/Cargo.toml Sun Apr 30 22:01:32 2023 -0400
15.3@@ -0,0 +1,8 @@
15.4+[package]
15.5+name = "obj"
15.6+version = "0.1.0"
15.7+edition = "2021"
15.8+
15.9+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
15.10+
15.11+[dependencies]
16.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
16.2+++ b/obj/src/lib.rs Sun Apr 30 22:01:32 2023 -0400
16.3@@ -0,0 +1,14 @@
16.4+pub fn add(left: usize, right: usize) -> usize {
16.5+ left + right
16.6+}
16.7+
16.8+#[cfg(test)]
16.9+mod tests {
16.10+ use super::*;
16.11+
16.12+ #[test]
16.13+ fn it_works() {
16.14+ let result = add(2, 2);
16.15+ assert_eq!(result, 4);
16.16+ }
16.17+}
17.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
17.2+++ b/pkg.lisp Sun Apr 30 22:01:32 2023 -0400
17.3@@ -0,0 +1,35 @@
17.4+#|
17.5+cl-demo
17.6+
17.7+> (cl-demo:main)
17.8+|#
17.9+
17.10+(defpackage #:cl-demo
17.11+ (:use #:cl)
17.12+ (:local-nicknames
17.13+ (#:rdb #:cl-rocksdb)
17.14+ (#:v #:org.shirakumo.verbose)
17.15+ (#:bt #:bordeaux-threads)
17.16+ (#:cli #:clingon))
17.17+ ;; db.lisp
17.18+ (:export
17.19+ ;; #:make-db
17.20+ ;; #:with-db
17.21+ ;; #:db
17.22+ )
17.23+ ;; demo.lisp
17.24+ (:export
17.25+ #:main
17.26+ #:demo-path
17.27+ #:db-path
17.28+ #:cli-opts
17.29+ #:cli-handler
17.30+ #:cli-cmd)
17.31+ ;; ui.lisp
17.32+ (:export
17.33+ #:on-new-window
17.34+ #:start-ui)
17.35+ ;; tk.lisp
17.36+ (:export
17.37+ #:random-id
17.38+ #:scan-dir))
18.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
18.2+++ b/readme.org Sun Apr 30 22:01:32 2023 -0400
18.3@@ -0,0 +1,8 @@
18.4+#+TITTLE: cl-demo
18.5+
18.6+This is a demo software suite which showcases the power of Common Lisp and Rust.
18.7+
18.8+* Make
18.9+* Run
18.10+* Play
18.11+* Config
19.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
19.2+++ b/ros/build.ros Sun Apr 30 22:01:32 2023 -0400
19.3@@ -0,0 +1,20 @@
19.4+#!/bin/sh
19.5+#|-*- mode:lisp -*-|#
19.6+#|
19.7+exec ros -Q -- $0 "$@"
19.8+|#
19.9+(progn ;;init forms
19.10+ (ros:ensure-asdf)
19.11+ #+quicklisp(ql:quickload '() :silent t)
19.12+ )
19.13+
19.14+(defpackage :ros.script.build.3891893519
19.15+ (:use :cl))
19.16+(in-package :ros.script.build.3891893519)
19.17+
19.18+(defun main (&rest argv)
19.19+ (declare (ignorable argv))
19.20+ (asdf:load-asd "cl-demo.asd")
19.21+ (asdf:load-system "cl-demo")
19.22+ (asdf:make :cl-demo))
19.23+;;; vim: set ft=lisp lisp:
20.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
20.2+++ b/ros/clean.ros Sun Apr 30 22:01:32 2023 -0400
20.3@@ -0,0 +1,20 @@
20.4+#!/bin/sh
20.5+#|-*- mode:lisp -*-|#
20.6+#|
20.7+exec ros -Q -- $0 "$@" ;
20.8+|#
20.9+
20.10+;; clean:;rm -rf out *.fasl;pushd rust;cargo clean;popd
20.11+
20.12+(progn ;;init forms
20.13+ (ros:ensure-asdf)
20.14+ #+quicklisp(ql:quickload '() :silent t)
20.15+ )
20.16+
20.17+(defpackage :ros.script.clean.3891893753
20.18+ (:use :cl))
20.19+(in-package :ros.script.clean.3891893753)
20.20+
20.21+(defun main (&rest argv)
20.22+ (declare (ignorable argv)))
20.23+;;; vim: set ft=lisp lisp:
21.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
21.2+++ b/ros/compile.ros Sun Apr 30 22:01:32 2023 -0400
21.3@@ -0,0 +1,15 @@
21.4+#!/bin/sh
21.5+#|-*- mode:lisp -*-|#
21.6+#|
21.7+exec ros -Q -- $0 "$@"
21.8+|#
21.9+(progn ;;init forms
21.10+ (in-package :cl-user)
21.11+ (ros:ensure-asdf)
21.12+ (asdf:load-asd #P"~/dev/cl-demo/cl-demo.asd")
21.13+ (asdf:load-asd #P"~/quicklisp/local-projects/cl-rocksdb/cl-rocksdb.asd")
21.14+ #+quicklisp(ql:quickload '(cl-demo) :silent t))
21.15+
21.16+;; TODO 2023-02-25: opts (system, config, user input)
21.17+(defun main (&rest argv)
21.18+ (declare (ignorable argv)))
22.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
22.2+++ b/ros/db.ros Sun Apr 30 22:01:32 2023 -0400
22.3@@ -0,0 +1,12 @@
22.4+#!/bin/sh
22.5+#|-*- mode:lisp -*-|#
22.6+#|
22.7+exec ros -Q -- $0 "$@"
22.8+|#
22.9+(progn ;;init forms
22.10+ (ros:ensure-asdf)
22.11+ #+quicklisp(ql:quickload '() :silent t))
22.12+
22.13+(defun main (&rest argv)
22.14+ (declare (ignorable argv))
22.15+ (format t "hello world"))
23.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
23.2+++ b/ros/demo.ros Sun Apr 30 22:01:32 2023 -0400
23.3@@ -0,0 +1,12 @@
23.4+#!/bin/sh
23.5+#|-*- mode:lisp -*-|#
23.6+#|
23.7+exec ros -Q -- $0 "$@"
23.8+|#
23.9+(progn ;;init forms
23.10+ (ros:ensure-asdf)
23.11+ #+quicklisp(ql:quickload '() :silent t))
23.12+
23.13+(defun main (&rest argv)
23.14+ (declare (ignorable argv))
23.15+ (format t "hello world"))
23.16\ No newline at end of file
24.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
24.2+++ b/ros/docs.ros Sun Apr 30 22:01:32 2023 -0400
24.3@@ -0,0 +1,12 @@
24.4+#!/bin/sh
24.5+#|-*- mode:lisp -*-|#
24.6+#|
24.7+exec ros -Q -- $0 "$@"
24.8+|#
24.9+(progn ;;init forms
24.10+ (ros:ensure-asdf)
24.11+ #+quicklisp(ql:quickload '() :silent t))
24.12+
24.13+(defun main (&rest argv)
24.14+ (declare (ignorable argv))
24.15+ (format t "hello world"))
25.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
25.2+++ b/ros/pack.ros Sun Apr 30 22:01:32 2023 -0400
25.3@@ -0,0 +1,17 @@
25.4+#!/bin/sh
25.5+#|-*- mode:lisp -*-|#
25.6+#|
25.7+exec ros -Q -- $0 "$@"
25.8+|#
25.9+(progn ;;init forms
25.10+ (ros:ensure-asdf)
25.11+ #+quicklisp(ql:quickload '() :silent t)
25.12+ )
25.13+
25.14+(defpackage :ros.script.pack.3891893796
25.15+ (:use :cl))
25.16+(in-package :ros.script.pack.3891893796)
25.17+
25.18+(defun main (&rest argv)
25.19+ (declare (ignorable argv)))
25.20+;;; vim: set ft=lisp lisp:
26.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
26.2+++ b/ros/test.ros Sun Apr 30 22:01:32 2023 -0400
26.3@@ -0,0 +1,12 @@
26.4+#!/bin/sh
26.5+#|-*- mode:lisp -*-|#
26.6+#|
26.7+exec ros -Q -- $0 "$@"
26.8+|#
26.9+(progn ;;init forms
26.10+ (ros:ensure-asdf)
26.11+ #+quicklisp(ql:quickload '() :silent t))
26.12+
26.13+(defun main (&rest argv)
26.14+ (declare (ignorable argv))
26.15+ (format t "hello world"))
27.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
27.2+++ b/rustfmt.toml Sun Apr 30 22:01:32 2023 -0400
27.3@@ -0,0 +1,3 @@
27.4+edition = "2021"
27.5+tab_spaces = 2
27.6+wrap_comments = true
27.7\ No newline at end of file
28.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
28.2+++ b/tests.lisp Sun Apr 30 22:01:32 2023 -0400
28.3@@ -0,0 +1,1 @@
28.4+(in-package :cl-demo)
29.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
29.2+++ b/tests/prime-test.lisp Sun Apr 30 22:01:32 2023 -0400
29.3@@ -0,0 +1,67 @@
29.4+;; (defun is-prime(n)
29.5+;; (do ((num 2 (+ num 1)))
29.6+;; ((> num (/ n 2)) t)
29.7+;; (if (= 0 (mod n num))
29.8+;; (return-from is-prime nil))))
29.9+
29.10+;; (defun kth-prime(k)
29.11+;; (do ((candidate 2 (+ candidate 1)))
29.12+;; ((< k 1) (- candidate 1))
29.13+;; (when (is-prime candidate)
29.14+;; (decf k))))
29.15+
29.16+;; (time (kth-prime 10000))
29.17+
29.18+;; (declaim (inline is-prime))
29.19+;; (defun is-prime (n)
29.20+;; (loop for num of-type fixnum from 3 to (isqrt n) by 2
29.21+;; when (zerop (mod n num))
29.22+;; return nil
29.23+;; finally (return t)))
29.24+
29.25+;; (defun kth-prime (k)
29.26+;; (declare (optimize (speed 3) (safety 0))
29.27+;; (fixnum k))
29.28+;; (if (zerop k)
29.29+;; 2
29.30+;; (loop for candidate of-type fixnum from 3 by 2
29.31+;; when (<= k 0) return (- candidate 2)
29.32+;; when (is-prime candidate) do (decf k))))
29.33+
29.34+;; (declaim
29.35+;; (optimize (speed 3) (safety 0))
29.36+;; (inline is-prime))
29.37+
29.38+;; (defun is-prime(n)
29.39+;; (declare (fixnum n))
29.40+;; (do ((num 2 (+ num 1)))
29.41+;; ((> num (floor n 2)) t)
29.42+;; (declare (fixnum num))
29.43+;; (if (= 0 (mod n num))
29.44+;; (return-from is-prime nil))))
29.45+
29.46+;; (defun kth-prime(k)
29.47+;; (declare (fixnum k))
29.48+;; (do ((candidate 2 (+ candidate 1)))
29.49+;; ((< k 1) (- candidate 1))
29.50+;; (declare (fixnum candidate))
29.51+;; (when (is-prime candidate)
29.52+;; (decf k))))
29.53+
29.54+;; (time (kth-prime 10000))
29.55+
29.56+(declaim (inline is-prime))
29.57+(defun is-prime (n)
29.58+ (loop for num of-type fixnum from 2 to (ash n -1)
29.59+ when (zerop (mod n num))
29.60+ return nil
29.61+ finally (return t)))
29.62+
29.63+(defun kth-prime (k)
29.64+ (declare (optimize (speed 3) (safety 0))
29.65+ (fixnum k))
29.66+ (loop for candidate of-type fixnum from 2
29.67+ when (<= k 0) return (1- candidate)
29.68+ when (is-prime candidate) do (decf k)))
29.69+
29.70+(time (kth-prime 10000))
30.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
30.2+++ b/tk.lisp Sun Apr 30 22:01:32 2023 -0400
30.3@@ -0,0 +1,8 @@
30.4+(in-package #:cl-demo)
30.5+
30.6+(defun random-id ()
30.7+ (format NIL "~8,'0x-~8,'0x" (random #xFFFFFFFF) (get-universal-time)))
30.8+
30.9+(defun scan-dir (dir filename callback)
30.10+ (dolist (path (directory (merge-pathnames (merge-pathnames filename "**/") dir)))
30.11+ (funcall callback path)))
31.1--- /dev/null Thu Jan 01 00:00:00 1970 +0000
31.2+++ b/ui.lisp Sun Apr 30 22:01:32 2023 -0400
31.3@@ -0,0 +1,14 @@
31.4+(in-package :cl-demo)
31.5+
31.6+(defun on-new-window (body)
31.7+ "Handle new window event."
31.8+ (let ((elt (clog:create-child body "<h1>foobar</h1>")))
31.9+ (clog:set-on-click
31.10+ elt
31.11+ (lambda (o)
31.12+ (setf (clog:color elt) "green")))))
31.13+
31.14+(defun start-ui ()
31.15+ "Start the UI."
31.16+ (clog:initialize #'on-new-window)
31.17+ (clog:open-browser))