Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with defines and templates #104

Open
mantielero opened this issue May 5, 2024 · 1 comment
Open

Issues with defines and templates #104

mantielero opened this issue May 5, 2024 · 1 comment

Comments

@mantielero
Copy link

I am trying to wrap the header file libavutil/channel_layout.h.

By means of:

import futhark,os

importc:
  outputPath currentSourcePath.parentDir / "libavutil" / "channel_layout.nim"
  path "../FFmpeg-release-6.1/libavutil"
  "channel_layout.h"

This part of the header is not in the produced file.

c2nim is a bit closer to the right answer but I don't what would be the required template in this case:

template AV_CHANNEL_LAYOUT_MASK*(nb, m: untyped): void =
  ##  .order
  ## !!!Ignored construct:  AV_CHANNEL_ORDER_NATIVE ,  .nb_channels ( nb ) ,  .u.mask { m } ,  .opaque NULL }
  ## Error: expected ';'!!!

##
##  @name Common pre-defined channel layouts
##  @{
##

const
  AV_CHANNEL_LAYOUT_MONO* = AV_CHANNEL_LAYOUT_MASK(1, AV_CH_LAYOUT_MONO)
  AV_CHANNEL_LAYOUT_STEREO* = AV_CHANNEL_LAYOUT_MASK(2, AV_CH_LAYOUT_STEREO)
  AV_CHANNEL_LAYOUT_2POINT1* = AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2POINT1)
  AV_CHANNEL_LAYOUT_2_1* = AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_2_1)
  AV_CHANNEL_LAYOUT_SURROUND* = AV_CHANNEL_LAYOUT_MASK(3, AV_CH_LAYOUT_SURROUND)
  AV_CHANNEL_LAYOUT_3POINT1* = AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_3POINT1)
  AV_CHANNEL_LAYOUT_4POINT0* = AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_4POINT0)
  AV_CHANNEL_LAYOUT_4POINT1* = AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_4POINT1)
  AV_CHANNEL_LAYOUT_2_2* = AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_2_2)
  AV_CHANNEL_LAYOUT_QUAD* = AV_CHANNEL_LAYOUT_MASK(4, AV_CH_LAYOUT_QUAD)
  AV_CHANNEL_LAYOUT_5POINT0* = AV_CHANNEL_LAYOUT_MASK(5, AV_CH_LAYOUT_5POINT0)
@PMunch
Copy link
Owner

PMunch commented May 5, 2024

It's basically a structure construction, and Futhark unfortunately doesn't handle C macros well. This is a limitation of how C macros are defined. Should be fairly easy to write that template and just use the output from c2nim though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants