Introduce ref_ptr::new_reference
authorTom Tromey <tom@tromey.com>
Mon, 30 Apr 2018 02:59:21 +0000 (20:59 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 30 Apr 2018 17:33:11 +0000 (11:33 -0600)
commit7c1b5f3db73d7ecab03dc4e866e291582935fb04
tree01ac632a9ca2a8de49aba34932ec8d7c14ca57b8
parente11fb955fbab035748fa53ffc30c103157a284b6
Introduce ref_ptr::new_reference

I noticed a common pattern with gdb::ref_ptr, where callers would
"incref" and then create a new wrapper object, like:

    Py_INCREF (obj);
    gdbpy_ref<> ref (obj);

The ref_ptr constructor intentionally does not acquire a new
reference, but it seemed to me that it would be reasonable to add a
static member function that does so.

In this patch I chose to call the function "new_reference".  I
considered "acquire_reference" as well, but "new" seemed less
ambiguous than "acquire" to me.

ChangeLog
2018-04-30  Tom Tromey  <tom@tromey.com>

* common/gdb_ref_ptr.h (ref_ptr::new_reference): New static
method.
gdb/ChangeLog
gdb/common/gdb_ref_ptr.h
This page took 0.027118 seconds and 4 git commands to generate.