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 220215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:55:04+00:00 2026-05-11T18:55:04+00:00

I notice that in the generated SWIG wrappers for a given set of classes,

  • 0

I notice that in the generated SWIG wrappers for a given set of classes, SWIG keeps a list of C-string representations of all the parent classes from which that class inherits. (char ** base_names). I know there is a function

swig_type(some_variable)

that will return a string representation of a given variable’s data type. Is there also a function that will return a table of the parent classes as strings? If not, is there an easy way to write this function? I’m not at all familiar with the inner workings of SWIG.

Thanks!

  • 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-11T18:55:04+00:00Added an answer on May 11, 2026 at 6:55 pm

    Something like this should work (not tested, since I don’t use SWIG with Lua):

    // insert into runtime section
    // this is the C function that iterates over the base_names array 
    // (I'm assuming that the array is terminated with a NULL)
    %runtime %{
        /* lua callable function to get the userdata's type */
        SWIGRUNTIME int SWIG_Lua_basenames(lua_State* L)
        {
          swig_lua_userdata* usr;
          swig_lua_class* clss = NULL;
          int i = 0;
          if (lua_isuserdata(L,1))
          {
            usr=(swig_lua_userdata*)lua_touserdata(L,1);  /* get data */
            if (usr && usr->type && usr->type->clientdata) {
              // fetch the swig_lua_class struct, it contains the base_names
              clss = (swig_lua_class*)usr->type->clientdata;
            }
          }
          /* create a new table with all class base names in it
             note that I create it even if clss is NULL, that way
             an empty table -should- be returned
           */          
          lua_newtable(L);
          while(clss && clss->base_names[i]) {
             lua_pushnumber(L, i+1); /* lua tables are 1-indexed */
             lua_pushstring(L, clss->base_names[i]);
             lua_rawset(L, -3);
             i++;
          }
          return 1;
        }
    %}
    %init %{
      /* this goes into the user init function, register our new function with
         Lua runtime
       */
      SWIG_Lua_add_function(L,"swig_base_names",SWIG_Lua_basenames);
    %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When embeding an HD video from youtube using the generated iframe, I notice that
I notice that when using sys.getsizeof() to check the size of list and dictionary,
I notice that Growl allows for the possibility of Growl notifications from a website.
I notice that Swig provides a whole host of functions to allow for typecasting
I notice that the first time a user visits my site the Wicket-generated URLs
I have a sub in perl (generated automatically by SWIG) that I want to
When using SetFirstResult(start) and SetMaxResults(count) methods to implement paging I've noticed that the generated
Notice that I am asking for little-o here (see similar question here ) -
I notice that sometimes when I try to override a CSS rule, browser does
I notice that there is getWebApplicationContext in org.springframework.web.servlet.mvc.AbstractController . This means that spring programmers

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.