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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:39:04+00:00 2026-06-13T09:39:04+00:00

In C++ code: class CWindowUI { public CWindowUI(const char* title,int width,int height); ….. };

  • 0

In C++ code:

class CWindowUI {
  public CWindowUI(const char* title,int width,int height);
  .....
};

static int CreateWindow(lua_State *l)
{
    int          width,height;
    char        *title;
    CWindowUI  **winp, *win;

    name = (char *) luaL_checkstring(l, 1);
    width= lua_tounsigned(l, 2);
    height= lua_tounsigned(l, 3);

    win = new CWindowUI(title,width,height);
    if (win == NULL) {
        lua_pushboolean(l, 0);
        return 1;
    }

    winp = (CWindowUI **) lua_newuserdata(l, sizeof(CWindowUI *));
    luaL_getmetatable(l, "WindowUI");
    lua_setmetatable(l, -2);
    *winp = win;

    return 1;
}

In Lua code:

local win = CreateWindow("title", 480, 320);
win:resize(800, 600);

Now my question is:

Function CreateWindow will return a object named win and the function resize is not defined. How do I get a notification when I call an undefined function in Lua?

The notification shall include the string "resize" and the arguments 800,600.
I want to modify the source to map the undefined function onto the callback function but it is incorrect .

  • 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-13T09:39:05+00:00Added an answer on June 13, 2026 at 9:39 am

    How do I get a notification when I call an undefined function in lua.

    You don’t. Not in the way that you mean it.

    You can hook an __index metamethod onto your registered “WindowUI” metatable (*groan*). Your metamethod will only get the userdata it was called on and the key that was used.

    But you cannot differentiate between a function call and simply accessing a member variable, since Lua doesn’t differentiate between these. If you return a function from your metamethod, and the user invokes the function-call operator on the return from the metamethod, then it will be called. Otherwise, they get a function to play with as they see fit. They can store it, pass it around, call it later, whatever. It’s a value, like any other.

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

Sidebar

Related Questions

i have code: class foo { public: bar(const QString& s){} ..... }; int main()
Code: class B { public: B () : b(++bCounter) {} int b; static int
My code class Union { //Search Function static boolean search(int A[], int i) {
I have the following code: class Test { public static void main(String[] args) {
Consider the following code: class Rectangle { public: // Constructors Rectangle(){ init(0,0); } Rectangle(int
this is my short code class A { public: int x,y; A(int a=0, int
See code: class Foo { public static function dumpObj($obj) { var_dump($obj); } } class
I have the following code: class Array { public: int aaa; Array():aaa(1){} void print()
I got the following code: class Book { public: void print(); const Book &Book::get();
Sample code: class Sample{ private int v; public void setV(){ Lock a=new Lock(); a.lock();

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.