Giter Club home page Giter Club logo

coffi's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coffi's Issues

cfn arg with pointer to custom types throws exception

typedef struct S1 {
    char c;
    void* p;
} S1;

extern void f1(S1* s){
    
}
(defalias ::S1
  (layout/with-c-layout
   [::mem/struct
    [[:c ::mem/char]
     [:p ::mem/pointer]]]))

(defcfn
 f1
 ""
 "f1"
  [[:coffi.mem/pointer ::S1]]
 :coffi.mem/void)
;; Syntax error compiling at (*cider-repl workspace/clong:localhost:58963(clj)*:40:33).
Unable to resolve symbol: scope12651 in this context

It's likely that I'm doing something dumb here, but I thought I'd file an issue just in case.

Also, I saw the following notes in the readme:

In cases where a pointer to some data is required to pass as an argument to a native function, but doesn't need to be read back in, the pointer primitive type can take a type argument.

I'm not actually sure what you mean by "doesn't need to be read back in".

Mismatch between layout/with-c-layout and clang's reported layout

I'm trying to use libclang to auto-generate struct layouts for use with coffi. As a sanity check, I wanted to make sure that the size of a struct reported by clang matched mem/size-of. It generally does, but I noticed there's a size difference when a struct includes pointers.

For example:

#include <stdio.h>

typedef struct S1 {
    char c;
    void* p;
} S1;

int main(int n, char** args){
    printf("size: %lu\n", sizeof(S1));
}

The above gives a size of 16, but the same struct definition in coffi gives 9:

(defalias ::S1
  (layout/with-c-layout
   [::mem/struct
    [[:c ::mem/char]
     [:p ::mem/pointer]]]))

(mem/size-of ::S1) ;; 9

It doesn't seem like there's anything wrong with the implementation. The byteAlignment of ValueLayout/ADDRESS is 1. I'm not really sure whether I'm using clang wrong or if there's something else going on. Either way, I thought I'd report it in case there is some improvement to be made.

JDK19: ClassNotFoundException for jdk.incubator.foreign.Addressable

This library looks for useful! Unfortunately, my first tests hit a wall right away. If I start the JVM with the --add-modules=jdk.incubator.foreign flag set, I get:

java.lang.module.FindException: Module jdk.incubator.foreign not found

... and if I remove that flag, I get an error telling me that it can't find the jdk.incubator.foreign.Addressable class.

This is on an aarch64 Mac/MacOS 12.6.1. My JDK info:

java -version
openjdk version "19.0.1" 2022-10-18
OpenJDK Runtime Environment Homebrew (build 19.0.1)
OpenJDK 64-Bit Server VM Homebrew (build 19.0.1, mixed mode, sharing)

Anything I should try? Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.