From: Simon Marchi <simon.marchi@polymtl.ca>
To: Pedro Alves <palves@redhat.com>
Cc: Simon Marchi <simon.marchi@ericsson.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 1/5] Introduce specialized versions of gdbpy_ref
Date: Thu, 09 Feb 2017 16:18:00 -0000 [thread overview]
Message-ID: <7ba500c23d1b0ac8e964b87c489a0afc@polymtl.ca> (raw)
In-Reply-To: <5bc0d9b3-f863-0f3d-00d8-67ca81d8f549@redhat.com>
On 2017-02-09 06:58, Pedro Alves wrote:
> On 01/23/2017 10:40 PM, Simon Marchi wrote:
>>
>> We must make sure to only use gdbpy_ref_base on objects that actually
>> are Python objects. For example, gdbpy_ref_base<thread_info> would
>> make
>> not sense. Since the "inheritance" from the PyObject type is done in
>> a
>> C way (using PyObject_HEAD), I don't know how we can check at
>> compile-time that we are not using it with a wrong type. If you have
>> an
>> idea on how to do that, let me know. We would need to check that
>> there
>> exists a field named ob_base. Bonus points for ensuring that its type
>> is PyObject. More bonus points for ensuring that it's the first field
>> in the structure.
>
> You can do all this with SFINAE. For the "is first field check, you
> could
> use something like "(PyObject*) this == &this->ob_base" as expression,
> I think.
>
> https://en.wikipedia.org/wiki/Substitution_failure_is_not_an_error
>
> There are many examples around the web, if you search for SFINAE and
> "C++ check if member exists", etc. E.g,:
>
> http://stackoverflow.com/questions/1005476/how-to-detect-whether-there-is-a-specific-member-variable-in-class
Thanks! This kind of thing doesn't come to me naturally yet.
> Though I still wonder whether just inheriting our objects from
> PyObject wouldn't make things simpler.
I'll have to try that.
Thanks,
Simon
next prev parent reply other threads:[~2017-02-09 16:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-23 22:43 [PATCH 0/5] Improve Python Inferior reference handling + fix a bug Simon Marchi
2017-01-23 22:43 ` [PATCH 2/5] Add Python Inferior object debug traces Simon Marchi
2017-01-23 22:43 ` [PATCH 4/5] Make Python inferior-related internal functions return a gdbpy_inf_ref Simon Marchi
2017-01-24 16:15 ` Simon Marchi
2017-02-09 12:30 ` Pedro Alves
2017-02-09 16:39 ` Simon Marchi
2017-01-23 22:43 ` [PATCH 1/5] Introduce specialized versions of gdbpy_ref Simon Marchi
2017-01-24 15:54 ` Tom Tromey
2017-01-24 16:18 ` Simon Marchi
2017-02-09 11:58 ` Pedro Alves
2017-02-09 16:18 ` Simon Marchi [this message]
2017-01-23 22:43 ` [PATCH 3/5] Make Python inferior-related internal functions return inferior_object* Simon Marchi
2017-01-24 0:03 ` Pedro Alves
2017-01-23 22:43 ` [PATCH 5/5] Add missing incref when creating Inferior Python object Simon Marchi
2017-02-25 18:41 ` Simon Marchi
2017-04-27 21:13 ` [pushed master+8.0] " Simon Marchi
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=7ba500c23d1b0ac8e964b87c489a0afc@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=simon.marchi@ericsson.com \
/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