Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6953603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:30:01+00:00 2026-05-27T14:30:01+00:00

I have this structure (from the Teem library): struct NrrdEncoding { // … int

  • 0

I have this structure (from the Teem library):

struct NrrdEncoding {
  // ...
  int (*read)(FILE *file, void *data, size_t elementNum,
              Nrrd *nrrd, struct NrrdIoState_t *nio);
  int (*write)(FILE *file, const void *data, size_t elementNum,
               const Nrrd *nrrd, struct NrrdIoState_t *nio);
};

By default, Swig wants read and write to be userdata, which makes sense if they’re to be opaque and re-assignable. However, I want to be able to call these more than I want to be able to re-assign them, and I don’t know how. (Ideally I’d like to be able to do both.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:30:02+00:00Added an answer on May 27, 2026 at 2:30 pm

    You need to give the object NrrdEncoding member functions via SWIG (ie: C functions that you bind as members of the object) that themselves will call the function pointers. It would work something like this:

    struct NrrdEncoding
    {
      ...
      //Don't expose the function pointers. The struct will still have them, but SWIG won't expose them.
    };
    
    %extend NrrdEncoding
    {
      int read(FILE *file, void *data, size_t elementNum, Nrrd *nrrd, struct NrrdIoState_t *nio)
      {
        return $self->read(file, data, elementNum, nrrd, nio);
      }
    
      int write(FILE *file, const void *data, size_t elementNum, const Nrrd *nrrd, struct NrrdIoState_t *nio)
      {
        return $self->write(file, data, elementNum, nrrd, nio);
      }
    }
    

    In Lua, if you have an NrrdEncoding object, you can call read on it like this: object:read(...).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this structure which I want to write to a file: typedef struct
I have this file structure: folderIWantStuffIn/ - old_stuff Now I want to add some
I have this data structure: request ======= building_id lot_code building ======== building_id lot_id lot
I have a data structure that looks like this: data =[ {'key_1': { 'calc1':
I have this structure (from markItUp plugin): It's image button with CSS a:hover element.
I have this structure typedef struct fpinfo { unsigned long chunk_offset; unsigned long chunk_length;
If I have this project structure Foo.Data reference EntityFramework Foo.Business reference Foo.Data Foo.Web reference
I have a class with this structure: public class BusinessObject { public int Column5
I have a structure, that contain string. Something like that: struct Chunk { int
I have this data structure: <estates version=0.1> <provider name=Foo> <estate id=12345678> <description>aaa</description> <size>300</size> </estate>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.