Comments (4)
You've set up bindLib correctly, but you called hts_open with 1 arg instead of 2. Since Cyber currently has function overloading by number of params, it say's it's missing a symbol. I'll make the error message more descriptive.
Oh, wow. Thanks for noticing this. Indeed it's working now.
from cyber.
This hasn't been implemented yet but I did check that it's possible with libtcc. It would look something like this in Cyber:
import os 'os'
lib = os.bindLib('./libfoo.so', [
os.CFunc{ sym: 'getBitStruct', args: [#uint], ret: bitStruct }
os.CStruct{ fields: [os.CuintBits(1), os.CuintBits(31)], type: bitStruct }
])
object bitStruct:
flag number
other number
s = lib.getBitStruct(22)
print s.flag
print s.other
from cyber.
I see. Thanks for the response.
For that example, I also don't mind bitshifting myself. I do have a related question. I was just trying out wrapping htslib. The first function is hts_open with this signature:
htsFile *hts_open(const char *fn, const char *mode);
where htsFile is:
typedef struct htsFile {
uint32_t is_bin:1, is_write:1, is_be:1, is_cram:1, is_bgzf:1, dummy:27;
int64_t lineno;
kstring_t line;
char *fn, *fn_aux;
union {
BGZF *bgzf;
struct cram_fd *cram;
struct hFILE *hfile;
} fp;
void *state; // format specific state information
htsFormat format;
hts_idx_t *idx;
const char *fnidx;
struct sam_hdr_t *bam_header;
struct hts_filter_t *filter;
} htsFile;
so I'd prefer not to specify that in cyber. In fact it can be completely opaque.
I tried this:
import os 'os'
hts = os.bindLib('libhts.so', [
os.CFunc{ sym: 'hts_open', args: [#charPtrZ, #charPtrZ], ret: #ptr}
])
print hts
h = hts.hts_open("../htslib/test/range.bam")
print h
but I see:
BindLib53175d61490b23df
panic: Missing method symbol `hts_open` from receiver of type `BindLib53175d61490b23df`.
/home/brentp/src/cyber/bam.cy:8:5 main:
h = hts.hts_open("../htslib/test/range.bam")
^
Is there a way to do this without writing a separate shared lib containing a wrapper function that returns a void *
?
from cyber.
You've set up bindLib correctly, but you called hts_open with 1 arg instead of 2. Since Cyber currently has function overloading by number of params, it say's it's missing a symbol. I'll make the error message more descriptive.
Is there a way to do this without writing a separate shared lib containing a wrapper function that returns a void *
That's the intended purpose of #ptr, I think it will be renamed to #voidPtr in the near future.
from cyber.
Related Issues (20)
- Question on libtcc HOT 2
- date functions HOT 5
- Indentation rules overlap with ":" HOT 1
- Implement `catch`. HOT 3
- Attempting to print the output of return value from execCmd() (value.out) giving 'rawstring' HOT 11
- Can't run on emscripten environment. HOT 2
- Promote on the list of embedded-scripting-languages HOT 1
- Logo Proposal HOT 2
- Performance comparison with daScript
- `nan_f64` compilation errors with latest Zig HOT 1
- I can't append list to list HOT 2
- Web Interpreter Can't Use Int Type HOT 2
- `..=` is Not Recognized as Valid Operator
- Indexed Assignment Into Non-List Type Generates "Unknown Error Code" HOT 1
- fiber example on the landing page not working HOT 1
- Cyber crashes (method with self parameter inside object) HOT 1
- frontend HOT 5
- JIT Backend
- C/C++ Backend HOT 3
- Jupyter Kernel HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cyber.