public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Hannes Domani <ssbssa@yahoo.de>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Allow calling of C++ methods from python
Date: Fri, 15 Dec 2023 17:30:27 -0700	[thread overview]
Message-ID: <87msub56qk.fsf@tromey.com> (raw)
In-Reply-To: <20231215151938.3887-1-ssbssa@yahoo.de> (Hannes Domani's message of "Fri, 15 Dec 2023 16:19:38 +0100")

>>>>> "Hannes" == Hannes Domani <ssbssa@yahoo.de> writes:

Hannes>   static int static_func ();

Hannes> (gdb) py b_obj = gdb.parse_and_eval('b_obj')
Hannes> (gdb) py print(b_obj['static_func']())
Hannes> Traceback (most recent call last):
Hannes>   File "<string>", line 1, in <module>
Hannes> RuntimeError: Value is not callable (not TYPE_CODE_FUNC).

I'm a bit surprised that a static method is not TYPE_CODE_FUNC.
It seems like it should be, because these are really just functions.

Hannes> (gdb) py print(b_obj['arg0_func']())
Hannes> Traceback (most recent call last):
Hannes>   File "<string>", line 1, in <module>
Hannes> gdb.error: Too few arguments in function call.
Hannes> Error while executing Python code.
Hannes> (gdb) py print(b_obj['arg0_func'](b_obj))
Hannes> 198

How does this interact with overloading?

It seems to me that either b_obj['name'] has to return some kind of
overload set, or we need a different API, like b_obj.call_method('name', ...).

In the latter case we could have it automatically supply 'this', at
least when it's needed.

Tom

  reply	other threads:[~2023-12-16  0:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20231215151938.3887-1-ssbssa.ref@yahoo.de>
2023-12-15 15:19 ` Hannes Domani
2023-12-16  0:30   ` Tom Tromey [this message]
2023-12-16 11:40     ` Hannes Domani
2024-01-03 10:38       ` Hannes Domani
2024-01-17 15:52         ` Hannes Domani
2024-01-26 17:02           ` Hannes Domani
2024-02-08 16:29   ` Tom Tromey
2024-02-08 19:11     ` Hannes Domani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87msub56qk.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ssbssa@yahoo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).