Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 54 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,12 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/utils/mcp/tests/
FILES_MATCHING PATTERN "*.das"
)

# Install dascov (code coverage)
install(FILES ${PROJECT_SOURCE_DIR}/utils/dascov/main.das DESTINATION utils/dascov)
install(FILES ${PROJECT_SOURCE_DIR}/utils/dascov/README.md DESTINATION utils/dascov)
file(GLOB DAS_DASCOV_TEST_FILES ${PROJECT_SOURCE_DIR}/utils/dascov/tests/*.das)
install(FILES ${DAS_DASCOV_TEST_FILES} DESTINATION utils/dascov/tests)

# Install benchctl (benchmark analysis)
file(GLOB DAS_BENCHCTL_FILES ${PROJECT_SOURCE_DIR}/utils/benchctl/*.das)
install(FILES ${DAS_BENCHCTL_FILES} DESTINATION utils/benchctl)
Expand All @@ -1361,15 +1367,44 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/examples/daspkg/
# Install daslive examples
install(DIRECTORY ${PROJECT_SOURCE_DIR}/examples/daslive/
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/daslive
FILES_MATCHING PATTERN "*.das"
FILES_MATCHING
PATTERN "*.das"
PATTERN ".das_package"
PATTERN "modules" EXCLUDE
PATTERN ".jitted_scripts" EXCLUDE
PATTERN "_aot_generated" EXCLUDE
PATTERN "jitted_scripts" EXCLUDE
)

# Install core example .das files
# Install core example files
install(FILES
${PROJECT_SOURCE_DIR}/examples/hello_world.das
${PROJECT_SOURCE_DIR}/examples/README.md
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}
)

# Install dasbind example
install(FILES
${PROJECT_SOURCE_DIR}/examples/dasbind/dasbind_example.das
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/dasbind
)

# Install crash example
install(FILES
${PROJECT_SOURCE_DIR}/examples/crash/main.das
${PROJECT_SOURCE_DIR}/examples/crash/stack_overflow.das
${PROJECT_SOURCE_DIR}/examples/crash/main.cpp
${PROJECT_SOURCE_DIR}/examples/crash/CMakeLists.txt
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/crash
)

# Install minfft example
install(FILES
${PROJECT_SOURCE_DIR}/examples/minfft/main.das
${PROJECT_SOURCE_DIR}/examples/minfft/.das_package
DESTINATION ${DAS_INSTALL_EXAMPLESDIR}/minfft
)

file(GLOB DAS_DEBUGAPI_EXAMPLES
${PROJECT_SOURCE_DIR}/examples/debugapi/*.das
)
Expand Down Expand Up @@ -1457,6 +1492,23 @@ install(FILES ${DASHV_TUTORIAL_SOURCES}
DESTINATION ${DAS_INSTALL_TUTORIALSDIR}/dasHV
)

# Install dasPUGIXML tutorial files (.das + data files)
file(GLOB PUGIXML_TUTORIAL_SOURCES
${PROJECT_SOURCE_DIR}/tutorials/dasPUGIXML/*.das
${PROJECT_SOURCE_DIR}/tutorials/dasPUGIXML/*.xml
)
install(FILES ${PUGIXML_TUTORIAL_SOURCES}
DESTINATION ${DAS_INSTALL_TUTORIALSDIR}/dasPUGIXML
)

# Install dasStbImage tutorial .das files
file(GLOB STBIMAGE_TUTORIAL_SOURCES
${PROJECT_SOURCE_DIR}/tutorials/dasStbImage/*.das
)
install(FILES ${STBIMAGE_TUTORIAL_SOURCES}
DESTINATION ${DAS_INSTALL_TUTORIALSDIR}/dasStbImage
)

# ── Documentation build (optional) ──────────────────────────────────────────
if(DAS_BUILD_DOCUMENTATION)
find_package(Python3 COMPONENTS Interpreter)
Expand Down
21 changes: 16 additions & 5 deletions doc/reflections/das2rst.das
Original file line number Diff line number Diff line change
Expand Up @@ -1204,11 +1204,22 @@ def document_module_stbtruetype(root : string) {
def document_module_stbimage_ttf(root : string) {
var mod = find_module("stbimage_ttf")
var groups <- array<DocGroup>(
group_by_regex("Font loading", mod, %regex~(load_ttf)$%%),
group_by_regex("Font metrics", mod, %regex~(font_metrics)$%%),
group_by_regex("Text rendering", mod, %regex~(render_text)$%%)
)
document("High-level TrueType font API (stbimage_ttf)", mod, "stbimage_ttf.rst", groups)
// Low-level safe wrappers (stbtt_fontinfo)
group_by_regex("Low-level initialization", mod, %regex~(stbtt_init|stbtt_num_fonts)$%%),
group_by_regex("Low-level scale", mod, %regex~(stbtt_scale_for_pixel_height|stbtt_scale_for_em)$%%),
group_by_regex("Low-level metrics", mod, %regex~(stbtt_font_vmetrics|stbtt_font_bbox|stbtt_codepoint_hmetrics|stbtt_codepoint_kern|stbtt_codepoint_box|stbtt_find_glyph)$%%),
group_by_regex("Low-level glyph shape", mod, %regex~(stbtt_codepoint_shape|stbtt_codepoint_shape_count)$%%),
group_by_regex("Low-level bitmap rendering", mod, %regex~(stbtt_codepoint_bitmap_box|stbtt_codepoint_bitmap_box_subpixel|stbtt_codepoint_bitmap|stbtt_codepoint_bitmap_subpixel|stbtt_make_codepoint_bitmap|stbtt_make_codepoint_bitmap_subpixel)$%%),
group_by_regex("Low-level packing", mod, %regex~(stbtt_pack|stbtt_packed_quad)$%%),
// Font API (high-level)
group_by_regex("Font loading", mod, %regex~^(load_font|load_ttf|is_valid)$%%),
group_by_regex("Font scale", mod, %regex~^(scale_for_pixel_height|scale_for_em)$%%),
group_by_regex("Font metrics", mod, %regex~^(font_vmetrics|font_metrics|font_bounding_box|codepoint_hmetrics|codepoint_kern|codepoint_box|find_glyph)$%%),
group_by_regex("Font glyph shape", mod, %regex~^(codepoint_shape|codepoint_shape_count)$%%),
group_by_regex("Font bitmap rendering", mod, %regex~^(codepoint_bitmap_box|codepoint_bitmap_box_subpixel|codepoint_bitmap|codepoint_bitmap_subpixel)$%%),
group_by_regex("Text measurement and rendering", mod, %regex~^(measure_text|render_text)$%%)
)
document("TrueType font API (stbimage_ttf)", mod, "stbimage_ttf.rst", groups)
}

[export]
Expand Down
68 changes: 55 additions & 13 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,47 @@ daslang.exe examples/hello_world.das
|------|-------------|
| `hello_world.das` | Minimal hello-world program |

## crash/ — Crash Handler Example

Demonstrates native crash handling with daslang + C++ stack traces.
Built as a C++ executable (`example_crash`) that links `libDaScriptDyn`.

| File | Description |
|------|-------------|
| `main.das` | daslang script that triggers a native crash via `native_crash()` |
| `stack_overflow.das` | Stack overflow test case |
| `main.cpp` | C++ host with crash handler integration |

## dasbind/ — Foreign Function Interface

| File | Description |
|------|-------------|
| `dasbind_example.das` | Calling external C functions (Win32 API) via `[extern]` annotations |

## daslive/ — Live-Reload Examples

Examples for `daslang-live.exe`, the live-reloading application host.
Scripts are edited and hot-reloaded without restarting. Run with:

```
daslang-live.exe examples/daslive/hello/main.das
```

| Directory | Description |
|-----------|-------------|
| `hello/` | Basic live-reload hello-world with OpenGL background color |
| `triangle/` | Live-reloading triangle rendering |
| `tank_game/` | Tank game example |
| `arcanoid/` | Arcanoid game |
| `sequence/` | Card game with AI bots, ELO rating, and evolution (requires `daspkg install`) |
| `reload_test/` | Live-reload mechanism test |
| `live_vars_demo/` | Variable viewer demo |
| `test_api/` | REST API test |
| `test_api_http/` | HTTP API test |
| `test_commands/` | Live commands test |
| `test_decs_reload/` | DECS (ECS) reload test |
| `test_watch/` | Watch mechanism test |

## debugapi/ — Debug Agent Examples

Debug agents let you inspect and control program execution at runtime:
Expand All @@ -22,17 +63,10 @@ All examples require `options debugger = true`.
| File | Description |
|------|-------------|
| `allocation_tracking.das` | Heap allocation callbacks (`onAllocate`, `onReallocate`, `onFree`, `onAllocateString`, `onFreeString`) |
| `heartbeat.das` | Periodic callback injection via `daslib/heartbeat` — watchdog, progress reporting |
| `hw_breakpoint.das` | Hardware data breakpoints that fire when a memory address is written |
| `instrumentation.das` | Line-level and function-level instrumentation hooks for profiling and tracing |
| `stack_walker.das` | `DapiStackWalker` for call-stack inspection and diagnostic collection |

## dasbind/ — Foreign Function Interface

| File | Description |
|------|-------------|
| `dasbind_example.das` | Calling external C functions (Win32 API) via `[extern]` annotations |

## pathTracer/ — Path Tracer Demo

A toy path tracer implemented in daslang, with OpenGL visualization variants.
Expand All @@ -47,11 +81,6 @@ Requires the `stbimage` module and (for OpenGL variants) `dasGlfw` / `dasImgui`.
| `toy_path_tracer_opengl_hdr.das` | Real-time path tracer with HDR tonemapping |
| `toy_path_tracer_profile.das` | Path tracer performance benchmark |

## profile/ — Performance Benchmarks

A benchmark suite comparing daslang against C++ and other languages.
Built as a C++ executable that compiles and runs `.das` benchmark scripts.

## uncategorized/ — Miscellaneous Examples

Standalone examples that don't fit neatly into other categories.
Expand All @@ -76,6 +105,20 @@ Start the server, open `http://localhost:9090` in a browser,
and/or run `ws_chat_client.das` in a terminal — all clients share the
same chat room. See `examples/hv/README.md` for details.

## minfft/ — FFT Example

FFT (Fast Fourier Transform) example using the `das-minfft` daspkg package. Requires setup:

```
cd examples/minfft
daslang.exe ../../utils/daspkg/main.das -- install
daslang.exe main.das
```

| File | Description |
|------|-------------|
| `main.das` | Compute FFT of a sine wave signal |

## daspkg/ — Package Manager Examples

Example projects demonstrating the `daspkg` package manager. Each subdirectory
Expand Down Expand Up @@ -145,4 +188,3 @@ daslang.exe -project_root . imgui_node_editor_basic.das
| File | Description |
|------|-------------|
| `imgui_node_editor_basic.das` | Two linked nodes in a fullscreen node-editor canvas |

85 changes: 0 additions & 85 deletions examples/pugixml_smoke_test.das

This file was deleted.

23 changes: 20 additions & 3 deletions install/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Task-specific instructions are in skill files under `skills/`. Read the relevant
| `skills/daslib_modules.md` | Using `daslib/` modules (linq, json, regex, functional, match, etc.), channels |
| `skills/das_macros.md` | Writing compile-time macros, AST manipulation, qmacro/quote code generation, smart_ptr ownership |
| `skills/daspkg.md` | Creating `.das_package` manifests, package structure, daspkg commands |
| `skills/dynamic_modules.md` | Understanding `.das_module` descriptors, module resolution, `register_native_path`, `register_dynamic_module` |
| `skills/daslang_live.md` | Working with `daslang-live`, live-reload lifecycle, REST API, `[live_command]`, persistent state |

Multiple skill files may apply to a single task. For example, embedding daslang and calling its standard library requires reading both `skills/cpp_integration.md` and `skills/daslib_modules.md`.

Expand Down Expand Up @@ -84,6 +86,17 @@ All code MUST use gen2 syntax (add `options gen2` at the top of every file). Key
- Hex literals are `uint` by default — use `int(0x3F)` for int
- **`default<T>`** — the default (zero) value of type `T`: `default<int>` is `0`, `default<string>` is `""`, `default<float>` is `0.0f`
- **`typedecl(expr)`** — compile-time type-of expression, usable inside `default<>`: `default<typedecl(field)>` gives the zero value of `field`'s type. Useful in generic code with `static_if` to compare against defaults.
- **Bitfield sizes**: `bitfield Name : uint8 { ... }`, `: uint16`, `: uint64`; default is `uint` (32-bit). Always unsigned.
- **Bitfield from expression**: `bitfield64(1ul << 13ul)` — use the constructor to create a bitfield value from an integer expression. Similarly `bitfield8()`, `bitfield16()`.

### Pass-by-value vs pass-by-reference

- Most types (structs, arrays, tables) always pass by reference — `&` is unnecessary on them
- Only **workhorse types** (`int`, `float`, `bool`, `string`, etc.) pass by value
- **`var s : string`** — writable local copy, changes do NOT propagate back to the caller
- **`var s : string&`** — pass by reference, changes propagate back. Use `&` for string out-parameters
- **`clone_string(s)`** — clones a string into the current context's heap. Required for cross-context calls where the source context may be destroyed
- **`:=`** on strings performs a clone (allocates in current context). Plain `=` copies the pointer

### Memory and move semantics

Expand Down Expand Up @@ -144,14 +157,18 @@ All code MUST use gen2 syntax (add `options gen2` at the top of every file). Key

## SDK Directory Layout

- `bin/` — Compiler binary (`daslang`)
- `lib/` — Static libraries for C++ embedding
- `bin/` — Compiler binaries (`daslang`, `daslang-live`, `das-fmt`, `clang-cl`, `sqlite_shell`)
- `lib/` — Static and shared libraries for C++ embedding
- `include/daScript/` — C++ headers for embedding
- `daslib/` — Standard library modules (.das files)
- `modules/` — Optional plugin modules (dasHV, dasGlfw, dasImgui, dasPUGIXML, etc.)
- `examples/` — Example scripts
- `tutorials/` — Language, integration, and module tutorials
- `dastest/` — Test framework (usable for testing your own code)
- `utils/mcp/` — MCP server for AI coding assistants (28 tools, stdio transport, no extra deps)
- `utils/mcp/` — MCP server for AI coding assistants (29 tools, stdio transport, no extra deps)
- `utils/daspkg/` — Package manager
- `utils/dascov/` — Code coverage tool
- `tree-sitter-daslang/` — Tree-sitter grammar, shared library, and highlighting queries

## Package Manager (daspkg)

Expand Down
Loading
Loading