| 646 | } |
| 647 | |
| 648 | PyObject *JSObjectProxyMethodDefinitions::JSObjectProxy_setdefault_method(JSObjectProxy *self, PyObject *const *args, Py_ssize_t nargs) { |
| 649 | PyObject *key; |
| 650 | PyObject *default_value = Py_None; |
| 651 | |
| 652 | if (!_PyArg_CheckPositional("setdefault", nargs, 1, 2)) { |
| 653 | return NULL; |
| 654 | } |
| 655 | key = args[0]; |
| 656 | if (nargs < 2) { |
| 657 | goto skip_optional; |
| 658 | } |
| 659 | |
| 660 | default_value = args[1]; |
| 661 | |
| 662 | skip_optional: |
| 663 | |
| 664 | JS::RootedId id(GLOBAL_CX); |
| 665 | if (!keyToId(key, &id)) { // invalid key |
| 666 | // TODO (Caleb Aikens): raise exception here |
| 667 | return NULL; |
| 668 | } |
| 669 | |
| 670 | PyObject *value = getKey(self, key, id, true); |
| 671 | if (value == Py_None) { |
| 672 | assignKeyValue(self, key, id, default_value); |
| 673 | Py_XINCREF(default_value); |
| 674 | return default_value; |
| 675 | } |
| 676 | |
| 677 | return value; |
| 678 | } |
| 679 | |
| 680 | PyObject *JSObjectProxyMethodDefinitions::JSObjectProxy_pop_method(JSObjectProxy *self, PyObject *const *args, Py_ssize_t nargs) { |
| 681 | PyObject *key; |
nothing calls this directly
no test coverage detected