digitalmars.D.learn - Fixed Length Array Syntax in extern(C) Function Signatures
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (30/30) Jul 09 2015 Given
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (3/5) Jul 09 2015 Forgot
- Timon Gehr (2/18) Jul 09 2015 No. You'll need explicit pass by reference on the D side.
- "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com> (3/4) Jul 09 2015 So, how should I modify my call to `image_copy` with respect to
- Alex Parrill (6/10) Jul 09 2015 In C, array parameters are the same as pointers; i.e. `foo(T[]
- Mike Parker (12/23) Jul 09 2015 Static arrays in C function parameter lists should be declared as
- =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= (8/11) Jul 10 2015 Great!
- "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com> (3/4) Jul 10 2015 Is there any tool out there that automatically creates D wrappers
- Andrea Fontana (2/6) Jul 10 2015 https://github.com/jacob-carlborg/dstep ?
- "Per =?UTF-8?B?Tm9yZGzDtnci?= <per.nordlow gmail.com> (2/5) Jul 10 2015 Great! I'll try that!
Given extern(C): struct AVFrame { uint8_t*[AV_NUM_DATA_POINTERS] data; int[AV_NUM_DATA_POINTERS] linesize; int width, height; ... } void av_image_copy(ubyte *[4] dst_data, int[4] dst_linesizes, const ubyte *[4] src_data, const int[4] src_linesizes, AVPixelFormat pix_fmt, int width, int height) will `dst_data` will be C-ABI-fed to `image_copy()` as a C-style single pointer in constrast to what happens in D which calls it as fixed-size (4) array of ubyte-pointers? Further, is it correct to use it in D as void copyVideo(const AVFrame* source, AVFrame* target) { av_image_copy(target.data[0 .. 4], target.linesize[0 .. 4], source.data[0 .. 4], source.linesize[0 .. 4], format, source.width, source.height); } ? It compiles without warnings, at least. I haven't been able to test it yet, though.
Jul 09 2015
On Thursday, 9 July 2015 at 15:19:41 UTC, Nordlöw wrote:uint8_t*[AV_NUM_DATA_POINTERS] data; int[AV_NUM_DATA_POINTERS] linesize;Forgot enum AV_NUM_DATA_POINTERS = 8;
Jul 09 2015
On 07/09/2015 05:19 PM, "Nordlöw" wrote:Given extern(C): struct AVFrame { uint8_t*[AV_NUM_DATA_POINTERS] data; int[AV_NUM_DATA_POINTERS] linesize; int width, height; ... } void av_image_copy(ubyte *[4] dst_data, int[4] dst_linesizes, const ubyte *[4] src_data, const int[4] src_linesizes, AVPixelFormat pix_fmt, int width, int height) will `dst_data` will be C-ABI-fed to `image_copy()` as a C-style single pointer in constrast to what happens in D which calls it as fixed-size (4) array of ubyte-pointers?No. You'll need explicit pass by reference on the D side.
Jul 09 2015
On Thursday, 9 July 2015 at 16:12:27 UTC, Timon Gehr wrote:No. You'll need explicit pass by reference on the D side.So, how should I modify my call to `image_copy` with respect to the four first parameters?
Jul 09 2015
On Thursday, 9 July 2015 at 17:11:36 UTC, Per Nordlöw wrote:On Thursday, 9 July 2015 at 16:12:27 UTC, Timon Gehr wrote:In C, array parameters are the same as pointers; i.e. `foo(T[] arg)` is the same as `foo(T* arg)` [1]. You should just be able to replace `[4]` with `*` in the arguments. [1]: http://stackoverflow.com/a/5573741/646619No. You'll need explicit pass by reference on the D side.So, how should I modify my call to `image_copy` with respect to the four first parameters?
Jul 09 2015
On Thursday, 9 July 2015 at 17:42:33 UTC, Alex Parrill wrote:On Thursday, 9 July 2015 at 17:11:36 UTC, Per Nordlöw wrote:Static arrays in C function parameter lists should be declared as ref on the D side. See "Passinbg D Array Arguments to C Functions" at [1]. So the function declaration above in D should be: void av_image_copy(ref ubyte *[4] dst_data, ref int[4] dst_linesizes, ref const ubyte *[4] src_data, ref const int[4] src_linesizes, AVPixelFormat pix_fmt, int width, int height) [1]http://dlang.org/interfaceToC.htmlOn Thursday, 9 July 2015 at 16:12:27 UTC, Timon Gehr wrote:In C, array parameters are the same as pointers; i.e. `foo(T[] arg)` is the same as `foo(T* arg)` [1]. You should just be able to replace `[4]` with `*` in the arguments. [1]: http://stackoverflow.com/a/5573741/646619No. You'll need explicit pass by reference on the D side.So, how should I modify my call to `image_copy` with respect to the four first parameters?
Jul 09 2015
On Friday, 10 July 2015 at 03:18:23 UTC, Mike Parker wrote:Great! One more thing: How shall my call to `avg_image_copy()` (from D) look then? Is the slicing syntax `[0 .. 4]` I use above as av_image_copy(target.data[0 .. 4], target.linesize[0 .. 4], source.data[0 .. 4], source.linesize[0 .. 4], format, source.width, source.height); the best way?You should just be able to replace `[4]` with `*` in the arguments.[1]http://dlang.org/interfaceToC.html
Jul 10 2015
On Friday, 10 July 2015 at 03:18:23 UTC, Mike Parker wrote:[1]http://dlang.org/interfaceToC.htmlIs there any tool out there that automatically creates D wrappers from C headers`?
Jul 10 2015
On Friday, 10 July 2015 at 08:42:06 UTC, Per Nordlöw wrote:On Friday, 10 July 2015 at 03:18:23 UTC, Mike Parker wrote:https://github.com/jacob-carlborg/dstep ?[1]http://dlang.org/interfaceToC.htmlIs there any tool out there that automatically creates D wrappers from C headers`?
Jul 10 2015
On Friday, 10 July 2015 at 08:54:57 UTC, Andrea Fontana wrote:Great! I'll try that!Is there any tool out there that automatically creates D wrappers from C headers`?https://github.com/jacob-carlborg/dstep ?
Jul 10 2015