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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:46:32+00:00 2026-06-02T23:46:32+00:00

Im having the following in my Swig interface file interfacing a .c/.h for a

  • 0

Im having the following in my Swig interface file interfacing a .c/.h for a small GUI library:

%{
    void Widget_name_set( Widget *widget, char *name )
    {
        if( !name ) return;

        WidgetSetName( widget, name );
    }


    char *Widget_name_get( Widget *widget )
    {
        return WidgetGetName( widget );
    }
%}


struct Widget
{
    %extend
    {           
        char name[ 32 ];

        Widget( void )
        {
            return WidgetNew();
        }


        ~Widget()
        {
            if( $self ) WidgetDelete( $self );
        }


        void SetName( char *name )
        {
            Widget_name_set( $self, name );
        }


        char *GetName()
        {
            return Widget_name_get( $self );
        }
    }
};

Then I use the interface file to generate a Lua wrapper. The results are almost as expected if I call in Lua the following:

w = Widget(); 
w:SetName("test");

Everything is ok. But if I do this:

w = Widget(); 
w.SetName( nil, "test" );

It obviously crash as the parameter is nil. Is there a way (either using the Swig interface or in Lua) to suppress all the call with a dot and only keep the one with column? Like this it would be easier for the user and will avoid me to add 10 million checks of pointers etc…

  • 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-06-02T23:46:34+00:00Added an answer on June 2, 2026 at 11:46 pm

    Is there a way (either using the Swig interface or in Lua) to suppress all the call with a dot and only keep the one with column?

    No. It’s just semantic sugar as far as Lua is concerned. Using . means to just access the member. Using : means that when you call the function, the first parameter is the table being accessed with :.

    You probably couldn’t even tell the difference from inspecting the Lua disassembly (though admittedly, that’s just guessing on my part); by then, it’s probably been converted into its final form.

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

Sidebar

Related Questions

I'm currently having following error message when executing a .sql file with about 26MB
I am having following issue with reading binary file in C. I have read
In my XAML i m having following two textBlocks <TextBlock Name=tbGeneratedSignature TextWrapping=Wrap Margin=2,2,0,0 Height=auto
i came across a sample gdbinit file, which was having following statements. can anyone
Having the following code: int main(int argc, char* argv[]) { // program code std::cout
I have created a table in MSSQL having following structure - **Table Name -
I am trying to extract the string from a file having following pattern within
Having the following sample: <form id=form name=form method=post> <a id=submit1 name=submit1 href=javascript:doPostBack('submit1', '')>#1</a> <a
I am having following database schema, I want to fetch name of all categories
I have an extjs combobox used for auto-complete having following configuration: xtype:'combo', displayField: 'name',

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.