profile
viewpoint
Bas Zalmstra baszalmstra Smart Robotics Utrecht, the Netherlands

baszalmstra/header-parser 34

Extracts information from an annotated C++ header and outputs it as JSON for use in code generation tools.

baszalmstra/MXA 2

Unofficial Mirror of MXA Game Studio (https://mxa.codeplex.com)

baszalmstra/my-little-robots 2

A simple programming game

baszalmstra/omniverse 2

A procedural planet renderer written in Rust.

baszalmstra/adventofcode2017 1

Solutions for http://adventofcode.com/2017 written in rust as a learning experience

baszalmstra/adventofcode2018 0

Saving christmas one line at a time http://adventofcode.com/2018

baszalmstra/adventofcode2020 0

Saving christmas one line at a time http://adventofcode.com/2020

baszalmstra/ansible-concourse 0

A role to install concourse CI https://concourse.ci/

baszalmstra/array_view 0

An implementation of the (former) C++17 proposal `array_view`

startedbaszalmstra/header-parser

started time in a day

startedbaszalmstra/header-parser

started time in 9 days

startedbaszalmstra/my-little-robots

started time in 14 days

startedbaszalmstra/header-parser

started time in 18 days

issue commentmun-lang/mun

Using mun to script rust?

Haha, all good.

The code for the parser can be found here. Lowering from an abstract syntax tree to HIR can be found here.

I hope that helps! 🙂

shadowcat-mst

comment created time in 20 days

startedvcapretz/bull-board

started time in 22 days

fork yurivangeffen/bull-board

🎯 Queue background jobs inspector

fork in 22 days

issue commentmun-lang/mun

Using mun to script rust?

Aha, I see. I somehow read that document, saw the 'extern C' one, and then completely flipping missed the first non-C-ABI example.

Whereabouts in the codebase would I look to see the current bits? I'm not at the point with the project that led me to start asking questions where it's an itch I'm likely to try to scratch myself, I'm afraid, but I'd love to at least read up and understand what's there a bit better :)

shadowcat-mst

comment created time in 24 days

startedbaszalmstra/header-parser

started time in 24 days

startedpboehm/ddns

started time in a month

issue openedmun-lang/mun

Using mun to script rust?

I can see in the documentation that I can bind in an extern C function, which I presume also means I can bind in a plain rust function.

However I'm not sure where I'd start to, say, expose a rust struct and its methods to mun code, and I'm also not sure where to look to try and figure out where to start :/

To be clear, my hope would be to be able to do roughly

let thing = get_thing_from_rust(...);
futz_thing(thing);

where get_thing_from_rust returns a struct or a reference thereto and futz_thing can then call 'thing.futz()' on the rust side or similar.

I apologise if this issue is still vague or if I've missed something obvious - replies of the form "please go read document X" or "please go read code Y" or "please clarify question Z" would be much appreciated :D

created time in a month

startedbaszalmstra/my-little-robots

started time in a month

Pull request review commentmun-lang/mun

feature: adds modules and visibility

+use super::PackageDefs;+use crate::arena::map::ArenaMap;+use crate::ids::{+    FunctionLoc, Intern, ItemDefinitionId, ModuleId, PackageId, StructLoc, TypeAliasLoc,+};+use crate::item_scope::ItemScope;+use crate::item_tree::{+    Function, ItemTree, ItemTreeId, LocalItemTreeId, ModItem, Struct, StructDefKind, TypeAlias,+};+use crate::module_tree::{LocalModuleId, ModuleTree};+use crate::visibility::RawVisibility;+use crate::{DefDatabase, FileId, Name, PerNs, Visibility};+use std::sync::Arc;++pub(super) fn collect(db: &dyn DefDatabase, package_id: PackageId) -> PackageDefs {+    let mut collector = DefCollector {+        db,+        package_id,+        modules: Default::default(),+        module_tree: db.module_tree(package_id),+    };+    collector.collect();+    collector.finish()+}++struct DefCollector<'db> {+    db: &'db dyn DefDatabase,+    package_id: PackageId,+    modules: ArenaMap<LocalModuleId, ItemScope>,+    module_tree: Arc<ModuleTree>,+}++impl<'t> DefCollector<'t> {+    /// Collects all information and stores it in the instance+    fn collect(&mut self) {+        // Collect all definitions in each module+        let module_tree = self.module_tree.clone();++        fn collect_modules_recursive<'t>(+            collector: &mut DefCollector<'t>,+            module_id: LocalModuleId,+            parent: Option<(Name, LocalModuleId)>,+        ) {+            // Insert an empty item scope for this module, this will be filled in.+            collector.modules.insert(module_id, ItemScope::default());++            // If there is a file associated with the module, collect all definitions from it+            let module_data = &collector.module_tree[module_id];+            if let Some(file_id) = module_data.file {+                let item_tree = collector.db.item_tree(file_id);+                ModCollector {

Thanks for all of your effort trying to improve this! 🙂

baszalmstra

comment created time in a month

fork hihod/header-parser

Extracts information from an annotated C++ header and outputs it as JSON for use in code generation tools.

fork in a month

startedbaszalmstra/header-parser

started time in a month

pull request commentmun-lang/mun

refactor: make type-specific data (such as StructInfo) part of TypeInfo

Waiting for a cbindgen bug (https://github.com/eqrion/cbindgen/pull/615) to be resolved, before I merged.

Wodann

comment created time in a month

push eventmun-lang/website

Wodann

commit sha 91919d10b7266ee0879be9097383a90b524dcb2f

feat(blog): add blog for October

view details

Wodann

commit sha 0d0487c9451775dc56bcb1c8f1ce45e5ecb1d2cd

Merge pull request #56 from Wodann/blog/october feat(blog): add blog for October

view details

push time in a month

PR merged mun-lang/website

feat(blog): add blog for October
+98 -0

0 comment

1 changed file

Wodann

pr closed time in a month

PR opened mun-lang/website

Reviewers
feat(blog): add blog for October
+98 -0

0 comment

1 changed file

pr created time in a month

Pull request review commentmun-lang/mun

feature: adds modules and visibility

+use super::PackageDefs;+use crate::arena::map::ArenaMap;+use crate::ids::{+    FunctionLoc, Intern, ItemDefinitionId, ModuleId, PackageId, StructLoc, TypeAliasLoc,+};+use crate::item_scope::ItemScope;+use crate::item_tree::{+    Function, ItemTree, ItemTreeId, LocalItemTreeId, ModItem, Struct, StructDefKind, TypeAlias,+};+use crate::module_tree::{LocalModuleId, ModuleTree};+use crate::visibility::RawVisibility;+use crate::{DefDatabase, FileId, Name, PerNs, Visibility};+use std::sync::Arc;++pub(super) fn collect(db: &dyn DefDatabase, package_id: PackageId) -> PackageDefs {+    let mut collector = DefCollector {+        db,+        package_id,+        modules: Default::default(),+        module_tree: db.module_tree(package_id),+    };+    collector.collect();+    collector.finish()+}++struct DefCollector<'db> {+    db: &'db dyn DefDatabase,+    package_id: PackageId,+    modules: ArenaMap<LocalModuleId, ItemScope>,+    module_tree: Arc<ModuleTree>,+}++impl<'t> DefCollector<'t> {+    /// Collects all information and stores it in the instance+    fn collect(&mut self) {+        // Collect all definitions in each module+        let module_tree = self.module_tree.clone();++        fn collect_modules_recursive<'t>(+            collector: &mut DefCollector<'t>,+            module_id: LocalModuleId,+            parent: Option<(Name, LocalModuleId)>,+        ) {+            // Insert an empty item scope for this module, this will be filled in.+            collector.modules.insert(module_id, ItemScope::default());++            // If there is a file associated with the module, collect all definitions from it+            let module_data = &collector.module_tree[module_id];+            if let Some(file_id) = module_data.file {+                let item_tree = collector.db.item_tree(file_id);+                ModCollector {

I think a context would work. You'd then pass that context to (unassocitaed) methods that use it?

baszalmstra

comment created time in a month

push eventmun-lang/runtime-ffi

Wodann

commit sha 0e00b6ad6b7514bab3e7a17f3e017e0b8a3ba8cd

refactor: make type-specific data (such as StructInfo) part of TypeInfo

view details

push time in a month

push eventmun-lang/runtime-ffi

Wodann

commit sha 73b9c98bbaa7f481be11fae6b19bf5111d9c45c5

refactor: make type-specific data (such as StructInfo) part of TypeInfo

view details

push time in a month

push eventmun-lang/runtime-ffi

MoustaphaSaad

commit sha 5c70c8ce98048452c276e4fa7a1765139a401f6e

Fix MunGuid compare and add equal operators to RuntimeFunction

view details

Wodann

commit sha 1b923f873916d79371c782bac180eb5c4d58710c

Merge pull request #9 from MoustaphaSaad/fix-guid-compare Fix MunGuid compare and add equal operators to RuntimeFunction

view details

Wodann

commit sha 6b6de49a721817abf2c07d9fcc58a960df3f0acb

refactor: make type-specific data (such as StructInfo) part of TypeInfo

view details

push time in a month

Pull request review commentmun-lang/mun

feature: adds modules and visibility

+use super::PackageDefs;+use crate::arena::map::ArenaMap;+use crate::ids::{+    FunctionLoc, Intern, ItemDefinitionId, ModuleId, PackageId, StructLoc, TypeAliasLoc,+};+use crate::item_scope::ItemScope;+use crate::item_tree::{+    Function, ItemTree, ItemTreeId, LocalItemTreeId, ModItem, Struct, StructDefKind, TypeAlias,+};+use crate::module_tree::{LocalModuleId, ModuleTree};+use crate::visibility::RawVisibility;+use crate::{DefDatabase, FileId, Name, PerNs, Visibility};+use std::sync::Arc;++pub(super) fn collect(db: &dyn DefDatabase, package_id: PackageId) -> PackageDefs {+    let mut collector = DefCollector {+        db,+        package_id,+        modules: Default::default(),+        module_tree: db.module_tree(package_id),+    };+    collector.collect();+    collector.finish()+}++struct DefCollector<'db> {+    db: &'db dyn DefDatabase,+    package_id: PackageId,+    modules: ArenaMap<LocalModuleId, ItemScope>,+    module_tree: Arc<ModuleTree>,+}++impl<'t> DefCollector<'t> {+    /// Collects all information and stores it in the instance+    fn collect(&mut self) {+        // Collect all definitions in each module+        let module_tree = self.module_tree.clone();++        fn collect_modules_recursive<'t>(+            collector: &mut DefCollector<'t>,+            module_id: LocalModuleId,+            parent: Option<(Name, LocalModuleId)>,+        ) {+            // Insert an empty item scope for this module, this will be filled in.+            collector.modules.insert(module_id, ItemScope::default());++            // If there is a file associated with the module, collect all definitions from it+            let module_data = &collector.module_tree[module_id];+            if let Some(file_id) = module_data.file {+                let item_tree = collector.db.item_tree(file_id);+                ModCollector {

I don't know that it helps solves the issue I pointed out. To me, it's still unclear that you are actually operating on the DefCollector through the helper struct. If the goal was to use helper functions that operate on DefCollectors public API, I'd probably just do so using unassociated pub fns instead of creating a helper struct that obfuscates the control flow.

I might be overlooking something; or it's a personal preference, so I'm not making an issue of this.

baszalmstra

comment created time in a month

startedbaszalmstra/header-parser

started time in a month

push eventmun-lang/mun

Wodann

commit sha b27718b7e819ba1fa5dcd3fd90063359d89d7258

feat(codegen): add AsValue macro support for enums

view details

Wodann

commit sha 3e660990c9e8604ad9b855d5aafde12c448473ec

test(codegen): add tests for as_bytes_and_ptrs and has_const_value

view details

Wodann

commit sha b6f6c40dcc7b805bc544457218647a2b2cd63037

Merge pull request #286 from Wodann/feat/enum-as-value-macro feat(codegen): add AsValue macro support for enums

view details

push time in a month

PR merged mun-lang/mun

feat(codegen): add AsValue macro support for enums type: feat

Closes #275

+804 -55

2 comments

11 changed files

Wodann

pr closed time in a month

issue closedmun-lang/mun

Support for enums in the `AsValue` macro

The AsValue macro that is used for procedurally generating LLVM IR conversion functions for Rust types currently only supports structs.

We also want to be able to generate conversion functions for enums, as follows:

#[derive(AsValue)]
#[repr(u8)]
pub enum TypeInfoData<'ink> {
    Primitive,
    Struct(StructInfo<'ink>),
}

closed time in a month

Wodann

Pull request review commentmun-lang/mun

feat(codegen): add AsValue macro support for enums

 pub fn as_value_derive(input: TokenStream) -> TokenStream {                         let type_context = context.type_context;                         let field_padding = #field_padding_values; -                        let struct_type = Self::get_ir_type(context.type_context);+                        if <#ident>::has_const_value() {

Resolved.

Wodann

comment created time in a month

Pull request review commentmun-lang/mun

feature: adds modules and visibility

+use super::PackageDefs;+use crate::arena::map::ArenaMap;

If possible, can you merge these use statements?

baszalmstra

comment created time in a month

more