Skip to content

Commit be2fd86

Browse files
author
Andrew D. France
committed
Initial commit of cl-win32-types v1.0.0
0 parents  commit be2fd86

File tree

14 files changed

+1114
-0
lines changed

14 files changed

+1114
-0
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ "main", "master" ]
6+
pull_request:
7+
branches: [ "main", "master" ]
8+
9+
jobs:
10+
test:
11+
runs-on: windows-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Common Lisp
18+
uses: 40ants/setup-lisp@v4
19+
20+
- name: Install SBCL latest
21+
shell: bash
22+
run: |
23+
ros config set sbcl-bin.version 2.5.6
24+
ros install sbcl-bin
25+
26+
- name: Install Dependencies & Run Tests
27+
shell: bash
28+
run: |
29+
ros install fiveam
30+
ros --eval "(asdf:test-system :cl-win32-types)" --quit

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Compiled Lisp files
2+
*.fasl
3+
*.p
4+
*.dll
5+
*.so
6+
*.exe
7+
*.image
8+
9+
# Editor backup files
10+
*~
11+
*.bak
12+
#*#
13+
14+
# OS-specific files
15+
.DS_Store
16+
Thumbs.db
17+
18+
# Roswell
19+
.roswell/
20+
21+
# ASDF cache
22+
/asdf-cache/
23+
24+
# Qlot local dependencies
25+
/.qlot/

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"streetsidesoftware.code-spell-checker"
4+
]
5+
}

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6+
7+
## [1.0.0] - 2025-07-20
8+
9+
### Added
10+
- Initial release of `cl-win32-types`.
11+
- An exhaustive set of CFFI type aliases for the Windows API.
12+
- ASDF system definitions for the library, tests, and benchmarks.
13+
- Full unit test suite using FiveAM to verify type correctness.
14+
- Detailed performance benchmark suite using `trivial-benchmark`.

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
9+
## Our Standards
10+
11+
Examples of behavior that contributes to a positive environment for our community include:
12+
13+
* Demonstrating empathy and kindness toward other people
14+
* Being respectful of differing opinions, viewpoints, and experiences
15+
* Giving and gracefully accepting constructive feedback
16+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
* Focusing on what is best not just for us as individuals, but for the overall community
18+
19+
Examples of unacceptable behavior include:
20+
21+
* The use of sexualized language or imagery, and sexual attention or advances of any kind
22+
* Trolling, insulting or derogatory comments, and personal or political attacks
23+
* Public or private harassment
24+
* Publishing others' private information, such as a physical or email address, without their explicit permission
25+
* Other conduct which could reasonably be considered inappropriate in a professional setting
26+
27+
## Enforcement Responsibilities
28+
29+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
32+
33+
## Scope
34+
35+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
36+
37+
## Enforcement
38+
39+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at **[email protected]**. All complaints will be reviewed and investigated promptly and fairly.
40+
41+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
42+
43+
## Enforcement Guidelines
44+
45+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
46+
47+
### 1. Correction
48+
49+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
50+
51+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
52+
53+
### 2. Warning
54+
55+
**Community Impact**: A violation through a single incident or series of actions.
56+
57+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interaction in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
58+
59+
### 3. Temporary Ban
60+
61+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
62+
63+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
64+
65+
### 4. Permanent Ban
66+
67+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
68+
69+
**Consequence**: A permanent ban from any sort of public interaction within the community.
70+
71+
## Attribution
72+
73+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
74+
75+
[homepage]: https://www.contributor-covenant.org
76+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html

LICENSE

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2025 Andrew D. France
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# cl-win32-types
2+
3+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4+
[![Quicklisp](https://img.shields.io/badge/Quicklisp-available-brightgreen.svg)](http://quicklisp.org/)
5+
6+
A comprehensive set of CFFI type definitions for the Windows API, designed for seamless integration with modern Common Lisp development environments on Windows.
7+
8+
## Overview
9+
10+
This package provides an exhaustive set of 45 CFFI type definitions for the Windows C API (e.g., `DWORD`, `HANDLE`, `WCHAR`, `BOOL`). It is built for production use with Common Lisp (i.e., SBCL) on Windows. The system is designed to be modular, well-documented, and includes very thorough test and benchmark suites.
11+
12+
## Features
13+
14+
* **Comprehensive Type Coverage**: Defines a wide range of standard Windows C types.
15+
* **Lisp-Idiomatic Naming**: Type names are lowercased (e.g., `dword` instead of `DWORD`) and use a `win-` prefix for types that clash with Common Lisp symbols (e.g., `win-char`).
16+
* **Platform Detection**: Includes compile-time checks to ensure pointer-sized types are defined correctly for 32-bit and 64-bit platforms, with a clear error for unsupported environments.
17+
* **ASDF System**: Ready for straightforward use via Quicklisp. The library, tests, and benchmarks are defined as separate systems.
18+
* **Comprehensive Test Suite**: Includes a full suite of unit tests using FiveAM to verify type sizes, ranges, and behavior.
19+
* **Performance Benchmarks**: Provides a detailed benchmark suite to measure FFI call overhead, memory allocation, and type conversion performance.
20+
21+
## Installation (for Users)
22+
23+
Once available in Quicklisp, you can load it with:
24+
25+
```lisp
26+
(ql:quickload :cl-win32-types)
27+
```
28+
## Developer Setup (for Contributors)
29+
30+
This project uses **Qlot** to manage and lock dependency versions for reproducible builds.
31+
32+
1. **Install Qlot** (one-time setup):
33+
```bash
34+
ros install qlot
35+
```
36+
37+
2. **Install Project Dependencies**: This command reads the `qlfile.lock` and installs the exact versions of all dependencies into a local `.qlot/` directory.
38+
```bash
39+
# Make sure you are in the project's root directory
40+
qlot install
41+
```
42+
43+
3. **Start a REPL**: To work on the project, start your REPL using `qlot exec`. This ensures your Lisp session uses the project's local dependencies.
44+
```bash
45+
qlot exec ros run
46+
```
47+
---
48+
49+
## Usage Example
50+
51+
Reference the types in your CFFI definitions. All types are exported from the `cl-win32-types` package.
52+
53+
```lisp
54+
(defpackage #:my-windows-app
55+
(:use #:cl #:cffi #:cl-win32-types))
56+
57+
(in-package #:my-windows-app)
58+
59+
(cffi:defcfun ("MessageBoxW" message-box-w) int
60+
(hwnd hwnd)
61+
(text lpcwstr)
62+
(caption lpcwstr)
63+
(type uint))
64+
65+
(defun show-hello-dialog ()
66+
(message-box-w (cffi:null-pointer) "Hello from Common Lisp!" "My App" 0))
67+
```
68+
69+
## Running Tests and Benchmarks
70+
71+
* **To run the test suite**:
72+
```lisp
73+
(asdf:test-system :cl-win32-types)
74+
```
75+
* **Or with qlot:**
76+
```powershell
77+
qlot exec ros run --eval "(asdf:test-system :cl-win32-types)" --quit
78+
```
79+
80+
81+
* **To run the benchmarks**:
82+
```lisp
83+
(ql:quickload :cl-win32-types/benchmarks)
84+
(cl-win32-types/benchmarks:run-all-benchmarks)
85+
```
86+
* **Or with qlot:**
87+
```powershell
88+
qlot exec ros --eval "(ql:quickload :cl-win32-types/benchmarks)" --eval "(cl-win32-types/benchmarks:run-all-benchmarks)" --quit
89+
```
90+
<details>
91+
<summary>Click to see sample benchmark output</summary>
92+
93+
```text
94+
=== CL-WIN32-TYPES BENCHMARK SUITE ===
95+
96+
--- Basic Type Benchmarks ---
97+
GetTickCount (DWORD return):
98+
- SAMPLES TOTAL MINIMUM MAXIMUM MEDIAN AVERAGE DEVIATION
99+
REAL-TIME 3 0.002202 0.000583 0.000939 0.00068 0.000734 0.00015
100+
...
101+
102+
--- Call Overhead Comparison ---
103+
Native Lisp function call:
104+
- SAMPLES TOTAL MINIMUM MAXIMUM MEDIAN AVERAGE DEVIATION
105+
REAL-TIME 3 0.001002 0.000288 0.00042 0.000294 0.000334 0.000061
106+
107+
CFFI function call (no args):
108+
- SAMPLES TOTAL MINIMUM MAXIMUM MEDIAN AVERAGE DEVIATION
109+
REAL-TIME 3 0.022551 0.006851 0.008161 0.007539 0.007517 0.000535
110+
111+
...
112+
113+
=== BENCHMARK SUITE COMPLETE ===
114+
```
115+
116+
</details>
117+
118+
## Contributing
119+
120+
Bug reports and pull requests are welcome on GitHub. Please ensure the test suite passes by running `(asdf:test-system :cl-win32-types)` before submitting a pull request.
121+
122+
## License
123+
124+
This project is licensed under the **MIT License**. See the `LICENSE` file for details.

0 commit comments

Comments
 (0)