Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit403f8ee

Browse files
committed
Support FILE* pointers
1 parent511a274 commit403f8ee

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

‎examples/types.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,13 @@ JLCXX_MODULE define_julia_module(jlcxx::Module& types)
481481

482482
types.method("neverempty_array", [] () { NeverEmptyn(1);returnstd::vector({n}); });
483483
types.method("neverempty_deque", [] () { NeverEmptyn(1);returnstd::deque({n}); });
484+
485+
types.method("writefptr", [] (FILE* fp) {fprintf(fp,"Hello world!"); });
486+
types.method("makefptr", [] (const std::string& filename) {
487+
FILE* fp =fopen(filename.c_str(),"w");
488+
fprintf(fp,"Hello");
489+
return fp;
490+
});
484491
}
485492

486493
JLCXX_MODULEdefine_types2_module(jlcxx::Module& types2)

‎include/jlcxx/jlcxx_config.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#defineJLCXX_VERSION_MAJOR0
1818
#defineJLCXX_VERSION_MINOR14
19-
#defineJLCXX_VERSION_PATCH6
19+
#defineJLCXX_VERSION_PATCH7
2020

2121
// From https://stackoverflow.com/questions/5459868/concatenate-int-to-string-using-c-preprocessor
2222
#define__JLCXX_STR_HELPER(x) #x

‎src/jlcxx.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ JLCXX_API void register_core_types()
397397

398398
set_julia_type<jl_datatype_t*>(jl_any_type,false);
399399
set_julia_type<jl_value_t*>(jl_any_type,false);
400+
401+
set_julia_type<FILE*>((jl_datatype_t*)jl_apply_type1((jl_value_t*)jl_pointer_type,julia_type("FILE","Libc")),false);
400402
registered =true;
401403
}
402404
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp