[binutils-gdb] Introduce ref_ptr::new_reference

sergiodj+buildbot@sergiodj.net sergiodj+buildbot@sergiodj.net
Mon Apr 30 21:46:00 GMT 2018


*** TEST RESULTS FOR COMMIT 7c1b5f3db73d7ecab03dc4e866e291582935fb04 ***

Author: Tom Tromey <tom@tromey.com>
Branch: master
Commit: 7c1b5f3db73d7ecab03dc4e866e291582935fb04

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.



More information about the Gdb-testers mailing list