libv8 6.7.288.46.1 → 7.3.492.27.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/CHANGELOG.md +4 -0
- data/README.md +2 -0
- data/ext/libv8/builder.rb +6 -2
- data/lib/libv8/version.rb +1 -1
- data/vendor/depot_tools/.gitattributes +1 -0
- data/vendor/depot_tools/.gitignore +7 -0
- data/vendor/depot_tools/CROS_OWNERS +5 -0
- data/vendor/depot_tools/OWNERS +12 -1
- data/vendor/depot_tools/PRESUBMIT.py +16 -9
- data/vendor/depot_tools/README.md +9 -2
- data/vendor/depot_tools/autoninja +14 -6
- data/vendor/depot_tools/autoninja.bat +11 -1
- data/vendor/depot_tools/autoninja.py +40 -18
- data/vendor/depot_tools/bb +12 -0
- data/vendor/depot_tools/bb.bat +7 -0
- data/vendor/depot_tools/bootstrap/win/manifest.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/manifest_bleeding_edge.txt +1 -1
- data/vendor/depot_tools/bootstrap/win/win_tools.py +2 -1
- data/vendor/depot_tools/buildbucket.py +57 -4
- data/vendor/depot_tools/cipd +157 -44
- data/vendor/depot_tools/cipd.bat +51 -14
- data/vendor/depot_tools/cipd.ps1 +104 -42
- data/vendor/depot_tools/cipd_client_version +1 -1
- data/vendor/depot_tools/cipd_client_version.digests +21 -0
- data/vendor/depot_tools/cipd_manifest.txt +19 -6
- data/vendor/depot_tools/cipd_manifest.versions +318 -0
- data/vendor/depot_tools/clang_format.py +4 -4
- data/vendor/depot_tools/cpplint.py +44 -199
- data/vendor/depot_tools/dart_format.py +2 -2
- data/vendor/depot_tools/detect_host_arch.py +8 -3
- data/vendor/depot_tools/download_from_google_storage.py +47 -39
- data/vendor/depot_tools/fetch.py +30 -18
- data/vendor/depot_tools/fetch_configs/android_internal.py +34 -0
- data/vendor/depot_tools/fetch_configs/chromium.py +18 -1
- data/vendor/depot_tools/fetch_configs/config_util.py +4 -2
- data/vendor/depot_tools/fetch_configs/inspector_protocol.py +40 -0
- data/vendor/depot_tools/fetch_configs/node-ci.py +41 -0
- data/vendor/depot_tools/fix_encoding.py +3 -3
- data/vendor/depot_tools/gclient +1 -1
- data/vendor/depot_tools/gclient.py +415 -198
- data/vendor/depot_tools/gclient_eval.py +220 -171
- data/vendor/depot_tools/gclient_paths.py +142 -0
- data/vendor/depot_tools/gclient_scm.py +200 -51
- data/vendor/depot_tools/gclient_utils.py +88 -191
- data/vendor/depot_tools/gerrit_client.py +13 -0
- data/vendor/depot_tools/gerrit_util.py +158 -23
- data/vendor/depot_tools/git-nav-upstream +1 -1
- data/vendor/depot_tools/git_cache.py +77 -24
- data/vendor/depot_tools/git_cl.py +705 -1099
- data/vendor/depot_tools/git_common.py +9 -6
- data/vendor/depot_tools/git_map_branches.py +19 -2
- data/vendor/depot_tools/git_nav_downstream.py +3 -4
- data/vendor/depot_tools/git_rebase_update.py +14 -0
- data/vendor/depot_tools/git_reparent_branch.py +8 -2
- data/vendor/depot_tools/gn.py +38 -3
- data/vendor/depot_tools/gsutil.py +8 -3
- data/vendor/depot_tools/gsutil.py.bat +15 -0
- data/vendor/depot_tools/gsutil.vpython +16 -0
- data/vendor/depot_tools/infra/config/OWNERS +0 -1
- data/vendor/depot_tools/infra/config/recipes.cfg +3 -2
- data/vendor/depot_tools/lucicfg +12 -0
- data/vendor/depot_tools/lucicfg.bat +7 -0
- data/vendor/depot_tools/man/html/git-map-branches.html +34 -2
- data/vendor/depot_tools/man/html/git-new-branch.html +40 -32
- data/vendor/depot_tools/man/man1/git-map-branches.1 +24 -5
- data/vendor/depot_tools/man/man1/git-new-branch.1 +35 -27
- data/vendor/depot_tools/man/src/git-map-branches.demo.1.sh +1 -0
- data/vendor/depot_tools/man/src/git-map-branches.txt +10 -0
- data/vendor/depot_tools/man/src/git-new-branch.demo.1.sh +9 -4
- data/vendor/depot_tools/man/src/git-new-branch.txt +1 -1
- data/vendor/depot_tools/metrics.README.md +98 -0
- data/vendor/depot_tools/metrics.py +296 -0
- data/vendor/depot_tools/metrics_utils.py +303 -0
- data/vendor/depot_tools/my_activity.py +91 -29
- data/vendor/depot_tools/ninja +1 -1
- data/vendor/depot_tools/ninjalog.README.md +64 -0
- data/vendor/depot_tools/ninjalog_uploader.py +232 -0
- data/vendor/depot_tools/ninjalog_uploader_wrapper.py +116 -0
- data/vendor/depot_tools/owners.py +30 -13
- data/vendor/depot_tools/owners_finder.py +5 -2
- data/vendor/depot_tools/presubmit_canned_checks.py +188 -29
- data/vendor/depot_tools/presubmit_support.py +18 -41
- data/vendor/depot_tools/pylintrc +23 -19
- data/vendor/depot_tools/recipes/OWNERS +2 -0
- data/vendor/depot_tools/recipes/README.recipes.md +344 -151
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/OWNERS +2 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/__init__.py +2 -16
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/api.py +141 -99
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_luci.json +5 -8
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/basic_with_branch_heads.json +6 -98
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/clobber.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/deprecated_got_revision_mapping.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_rebase_patch_ref.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/gerrit_no_reset.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob.json → input_commit_with_id_without_repo.json} +6 -11
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{tryjob_empty_revision.json → multiple_patch_refs.json} +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/no_apply_patch_on_gclient.json +19 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/{trychange.json → refs.json} +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/reset_root_solution_revision.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch.json +50 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_fail_patch_download.json +51 -6
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_branch_heads.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8_feature_branch.json +18 -26
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_webrtc.json +26 -28
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8.json +45 -5
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_v8_head_by_default.json +17 -25
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/unrecognized_commit_repo.json +13 -0
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name.json +13 -152
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_tags.json +4 -9
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.py +185 -202
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/bot_update.py +52 -157
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/test_api.py +5 -14
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/tests/ensure_checkout.py +34 -0
- data/vendor/depot_tools/recipes/recipe_modules/cipd/api.py +14 -2
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/basic_pkg.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-failed.json +7 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_file.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_mode.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/pkg_bad_verfile.json +9 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/full.expected/win64.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk arch.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/junk bits.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_arm_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/linux_mips_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/mac_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_32.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/cipd/examples/platform_suffix.expected/win_intel_64.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/api.py +13 -8
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/basic_luci.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.expected/win.json +18 -12
- data/vendor/depot_tools/recipes/recipe_modules/depot_tools/examples/full.py +3 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/gclient/api.py +58 -46
- data/vendor/depot_tools/recipes/recipe_modules/gclient/config.py +65 -22
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/basic.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/buildbot.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/revision.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.expected/tryserver.json +20 -21
- data/vendor/depot_tools/recipes/recipe_modules/gclient/examples/full.py +5 -2
- data/vendor/depot_tools/recipes/recipe_modules/gclient/tests/patch_project.py +62 -14
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/api.py +24 -38
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.expected/basic.json +56 -50
- data/vendor/depot_tools/recipes/recipe_modules/gerrit/examples/full.py +15 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/__init__.py +4 -1
- data/vendor/depot_tools/recipes/recipe_modules/git/api.py +34 -22
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_branch.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_file_name.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_hash.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_luci.json +222 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_ref.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_submodule_update_force.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/basic_tags.json +224 -0
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/can_fail_build.json +10 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cannot_fail_build.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/cat-file_test.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_delta.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_failed.json +5 -7
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/count-objects_with_bad_output_fails_build.json +10 -5
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/curl_trace_file.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/git-cache-checkout.json +8 -9
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/platform_win.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/rebase_failed.json +12 -8
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/remote_not_origin.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.expected/set_got_revision.json +5 -6
- data/vendor/depot_tools/recipes/recipe_modules/git/examples/full.py +27 -11
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/api.py +1 -1
- data/vendor/depot_tools/recipes/recipe_modules/git_cl/examples/full.expected/basic.json +12 -13
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/__init__.py +5 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/api.py +120 -5
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.expected/basic.json +45 -3
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/examples/full.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/resources/gerrit_client.py +56 -4
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.expected/basic.json +6 -0
- data/vendor/depot_tools/recipes/recipe_modules/gitiles/tests/parse_repo_url.py +49 -0
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/api.py +24 -13
- data/vendor/depot_tools/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +13 -14
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/basic.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_buildbot_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_generic_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_linux.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_mac.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/examples/full.expected/paths_kitchen_win.json +2 -3
- data/vendor/depot_tools/recipes/recipe_modules/infra_paths/path_config.py +1 -2
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/__init__.py +35 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/api.py +116 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/mac.json +82 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.expected/win.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/osx_sdk/examples/full.py +23 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/api.py +2 -7
- data/vendor/depot_tools/recipes/recipe_modules/presubmit/examples/full.expected/basic.json +7 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/__init__.py +1 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/api.py +117 -8
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/basic_tags.json +4 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/set_failure_hash_with_no_steps.json +7 -4
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch.json +98 -7
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_gerrit_patch_and_target_ref.json +147 -0
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_git_patch_luci.json +8 -5
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.expected/with_wrong_patch_new.json +9 -6
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/examples/full.py +27 -2
- data/vendor/depot_tools/recipes/recipe_modules/tryserver/test_api.py +14 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/__init__.py +25 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/api.py +137 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/linux.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/mac.json +22 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.expected/win.json +107 -0
- data/vendor/depot_tools/recipes/recipe_modules/windows_sdk/examples/full.py +26 -0
- data/vendor/depot_tools/recipes/recipes.py +37 -27
- data/vendor/depot_tools/recipes/recipes/fetch_end_to_end_test.expected/basic.json +7 -10
- data/vendor/depot_tools/repo +34 -8
- data/vendor/depot_tools/roll_dep.py +52 -49
- data/vendor/depot_tools/scm.py +38 -23
- data/vendor/depot_tools/setup_color.py +4 -2
- data/vendor/depot_tools/split_cl.py +32 -4
- data/vendor/depot_tools/subprocess2.py +22 -4
- data/vendor/depot_tools/third_party/httplib2/README.chromium +2 -2
- data/vendor/depot_tools/third_party/httplib2/__init__.py +242 -158
- data/vendor/depot_tools/third_party/httplib2/cacerts.txt +57 -44
- data/vendor/depot_tools/third_party/httplib2/socks.py +15 -5
- data/vendor/depot_tools/third_party/logilab/README.chromium +2 -4
- data/vendor/depot_tools/third_party/logilab/astroid/README.chromium +2 -1
- data/vendor/depot_tools/third_party/logilab/astroid/__init__.py +10 -5
- data/vendor/depot_tools/third_party/logilab/astroid/__pkginfo__.py +5 -5
- data/vendor/depot_tools/third_party/logilab/astroid/arguments.py +233 -0
- data/vendor/depot_tools/third_party/logilab/astroid/as_string.py +82 -33
- data/vendor/depot_tools/third_party/logilab/astroid/bases.py +137 -153
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{builtin_inference.py → brain_builtin_inference.py} +117 -26
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_dateutil.py +15 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2gi.py → brain_gi.py} +48 -8
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{py2mechanize.py → brain_mechanize.py} +0 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pynose.py → brain_nose.py} +4 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_numpy.py +62 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_pytest.py +76 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_qt.py +44 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/{pysix_moves.py → brain_six.py} +28 -1
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_ssl.py +65 -0
- data/vendor/depot_tools/third_party/logilab/astroid/brain/brain_stdlib.py +473 -0
- data/vendor/depot_tools/third_party/logilab/astroid/builder.py +104 -81
- data/vendor/depot_tools/third_party/logilab/astroid/context.py +81 -0
- data/vendor/depot_tools/third_party/logilab/astroid/decorators.py +75 -0
- data/vendor/depot_tools/third_party/logilab/astroid/exceptions.py +20 -0
- data/vendor/depot_tools/third_party/logilab/astroid/inference.py +137 -183
- data/vendor/depot_tools/third_party/logilab/astroid/manager.py +45 -169
- data/vendor/depot_tools/third_party/logilab/astroid/mixins.py +37 -14
- data/vendor/depot_tools/third_party/logilab/astroid/modutils.py +112 -41
- data/vendor/depot_tools/third_party/logilab/astroid/node_classes.py +243 -156
- data/vendor/depot_tools/third_party/logilab/astroid/nodes.py +35 -22
- data/vendor/depot_tools/third_party/logilab/astroid/objects.py +186 -0
- data/vendor/depot_tools/third_party/logilab/astroid/protocols.py +157 -102
- data/vendor/depot_tools/third_party/logilab/astroid/raw_building.py +32 -8
- data/vendor/depot_tools/third_party/logilab/astroid/rebuilder.py +372 -309
- data/vendor/depot_tools/third_party/logilab/astroid/scoped_nodes.py +652 -420
- data/vendor/depot_tools/third_party/logilab/astroid/test_utils.py +4 -21
- data/vendor/depot_tools/third_party/logilab/astroid/transforms.py +96 -0
- data/vendor/depot_tools/third_party/logilab/astroid/util.py +89 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/LICENSE +19 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/__init__.py +20 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/cext.c +1421 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/compat.py +9 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/simple.py +246 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/slots.py +414 -0
- data/vendor/depot_tools/third_party/logilab/lazy_object_proxy/utils.py +13 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/LICENSE +24 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/README.chromium +11 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/__init__.py +19 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/_wrappers.c +2729 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/arguments.py +96 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/decorators.py +512 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/importer.py +228 -0
- data/vendor/depot_tools/third_party/logilab/wrapt/wrappers.py +901 -0
- data/vendor/depot_tools/third_party/pylint/README.chromium +2 -25
- data/vendor/depot_tools/third_party/pylint/__pkginfo__.py +13 -3
- data/vendor/depot_tools/third_party/pylint/checkers/__init__.py +1 -2
- data/vendor/depot_tools/third_party/pylint/checkers/async.py +82 -0
- data/vendor/depot_tools/third_party/pylint/checkers/base.py +893 -119
- data/vendor/depot_tools/third_party/pylint/checkers/classes.py +342 -204
- data/vendor/depot_tools/third_party/pylint/checkers/design_analysis.py +51 -34
- data/vendor/depot_tools/third_party/pylint/checkers/exceptions.py +84 -47
- data/vendor/depot_tools/third_party/pylint/checkers/format.py +55 -30
- data/vendor/depot_tools/third_party/pylint/checkers/imports.py +314 -73
- data/vendor/depot_tools/third_party/pylint/checkers/logging.py +10 -8
- data/vendor/depot_tools/third_party/pylint/checkers/misc.py +2 -1
- data/vendor/depot_tools/third_party/pylint/checkers/newstyle.py +45 -48
- data/vendor/depot_tools/third_party/pylint/checkers/python3.py +31 -21
- data/vendor/depot_tools/third_party/pylint/checkers/raw_metrics.py +3 -3
- data/vendor/depot_tools/third_party/pylint/checkers/similar.py +4 -5
- data/vendor/depot_tools/third_party/pylint/checkers/spelling.py +24 -10
- data/vendor/depot_tools/third_party/pylint/checkers/stdlib.py +120 -56
- data/vendor/depot_tools/third_party/pylint/checkers/strings.py +38 -35
- data/vendor/depot_tools/third_party/pylint/checkers/typecheck.py +485 -138
- data/vendor/depot_tools/third_party/pylint/checkers/utils.py +319 -142
- data/vendor/depot_tools/third_party/pylint/checkers/variables.py +329 -207
- data/vendor/depot_tools/third_party/pylint/config.py +739 -76
- data/vendor/depot_tools/third_party/pylint/epylint.py +9 -5
- data/vendor/depot_tools/third_party/pylint/extensions/__init__.py +0 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_docs.py +311 -0
- data/vendor/depot_tools/third_party/pylint/extensions/check_elif.py +62 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint}/graph.py +30 -133
- data/vendor/depot_tools/third_party/pylint/gui.py +2 -2
- data/vendor/depot_tools/third_party/pylint/interfaces.py +21 -3
- data/vendor/depot_tools/third_party/pylint/lint.py +123 -140
- data/vendor/depot_tools/third_party/pylint/pyreverse/diadefslib.py +10 -13
- data/vendor/depot_tools/third_party/pylint/pyreverse/diagrams.py +15 -4
- data/vendor/depot_tools/third_party/pylint/pyreverse/inspector.py +372 -0
- data/vendor/depot_tools/third_party/pylint/pyreverse/main.py +30 -7
- data/vendor/depot_tools/third_party/pylint/pyreverse/utils.py +80 -2
- data/vendor/depot_tools/third_party/{logilab/common → pylint/pyreverse}/vcgutils.py +19 -37
- data/vendor/depot_tools/third_party/pylint/pyreverse/writer.py +3 -4
- data/vendor/depot_tools/third_party/pylint/reporters/__init__.py +34 -18
- data/vendor/depot_tools/third_party/pylint/reporters/guireporter.py +1 -1
- data/vendor/depot_tools/third_party/pylint/reporters/html.py +10 -3
- data/vendor/depot_tools/third_party/pylint/reporters/json.py +10 -4
- data/vendor/depot_tools/third_party/pylint/reporters/text.py +94 -3
- data/vendor/depot_tools/third_party/pylint/reporters/ureports/__init__.py +106 -0
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/html_writer.py +17 -57
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/nodes.py +52 -74
- data/vendor/depot_tools/third_party/{logilab/common → pylint/reporters}/ureports/text_writer.py +14 -60
- data/vendor/depot_tools/third_party/pylint/testutils.py +22 -20
- data/vendor/depot_tools/third_party/pylint/utils.py +268 -44
- data/vendor/depot_tools/third_party/repo/progress.py +42 -0
- data/vendor/depot_tools/update_depot_tools +1 -1
- data/vendor/depot_tools/upload_metrics.py +25 -0
- data/vendor/depot_tools/win_toolchain/get_toolchain_if_necessary.py +45 -15
- data/vendor/depot_tools/win_toolchain/package_from_installed.py +71 -24
- data/vendor/depot_tools/yapf +1 -1
- data/vendor/depot_tools/yapf.bat +1 -1
- metadata +92 -77
- data/vendor/depot_tools/git-crsync +0 -3
- data/vendor/depot_tools/infra/config/cq.cfg +0 -32
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/apply_gerrit_ref_custom.json +0 -29
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/buildbot.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/shallow.json +0 -195
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_angle_deprecated.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/tryjob_gerrit_v8.json +0 -248
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/examples/full.expected/with_manifest_name_no_patch.json +0 -105
- data/vendor/depot_tools/recipes/recipe_modules/bot_update/resources/apply_gerrit.py +0 -33
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2pytest.py +0 -31
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2qt4.py +0 -22
- data/vendor/depot_tools/third_party/logilab/astroid/brain/py2stdlib.py +0 -334
- data/vendor/depot_tools/third_party/logilab/astroid/inspector.py +0 -273
- data/vendor/depot_tools/third_party/logilab/astroid/utils.py +0 -239
- data/vendor/depot_tools/third_party/logilab/common/LICENSE.txt +0 -339
- data/vendor/depot_tools/third_party/logilab/common/README.chromium +0 -11
- data/vendor/depot_tools/third_party/logilab/common/__init__.py +0 -175
- data/vendor/depot_tools/third_party/logilab/common/__pkginfo__.py +0 -57
- data/vendor/depot_tools/third_party/logilab/common/cache.py +0 -114
- data/vendor/depot_tools/third_party/logilab/common/changelog.py +0 -238
- data/vendor/depot_tools/third_party/logilab/common/clcommands.py +0 -334
- data/vendor/depot_tools/third_party/logilab/common/cli.py +0 -211
- data/vendor/depot_tools/third_party/logilab/common/compat.py +0 -78
- data/vendor/depot_tools/third_party/logilab/common/configuration.py +0 -1105
- data/vendor/depot_tools/third_party/logilab/common/contexts.py +0 -5
- data/vendor/depot_tools/third_party/logilab/common/corbautils.py +0 -117
- data/vendor/depot_tools/third_party/logilab/common/daemon.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/date.py +0 -335
- data/vendor/depot_tools/third_party/logilab/common/dbf.py +0 -231
- data/vendor/depot_tools/third_party/logilab/common/debugger.py +0 -214
- data/vendor/depot_tools/third_party/logilab/common/decorators.py +0 -281
- data/vendor/depot_tools/third_party/logilab/common/deprecation.py +0 -189
- data/vendor/depot_tools/third_party/logilab/common/fileutils.py +0 -404
- data/vendor/depot_tools/third_party/logilab/common/interface.py +0 -71
- data/vendor/depot_tools/third_party/logilab/common/logging_ext.py +0 -195
- data/vendor/depot_tools/third_party/logilab/common/modutils.py +0 -702
- data/vendor/depot_tools/third_party/logilab/common/optik_ext.py +0 -392
- data/vendor/depot_tools/third_party/logilab/common/optparser.py +0 -92
- data/vendor/depot_tools/third_party/logilab/common/proc.py +0 -277
- data/vendor/depot_tools/third_party/logilab/common/pyro_ext.py +0 -180
- data/vendor/depot_tools/third_party/logilab/common/pytest.py +0 -1199
- data/vendor/depot_tools/third_party/logilab/common/registry.py +0 -1119
- data/vendor/depot_tools/third_party/logilab/common/shellutils.py +0 -462
- data/vendor/depot_tools/third_party/logilab/common/sphinx_ext.py +0 -87
- data/vendor/depot_tools/third_party/logilab/common/sphinxutils.py +0 -122
- data/vendor/depot_tools/third_party/logilab/common/table.py +0 -929
- data/vendor/depot_tools/third_party/logilab/common/tasksqueue.py +0 -101
- data/vendor/depot_tools/third_party/logilab/common/testlib.py +0 -1392
- data/vendor/depot_tools/third_party/logilab/common/textutils.py +0 -537
- data/vendor/depot_tools/third_party/logilab/common/tree.py +0 -369
- data/vendor/depot_tools/third_party/logilab/common/umessage.py +0 -194
- data/vendor/depot_tools/third_party/logilab/common/ureports/__init__.py +0 -172
- data/vendor/depot_tools/third_party/logilab/common/ureports/docbook_writer.py +0 -140
- data/vendor/depot_tools/third_party/logilab/common/urllib2ext.py +0 -89
- data/vendor/depot_tools/third_party/logilab/common/visitor.py +0 -109
- data/vendor/depot_tools/third_party/logilab/common/xmlrpcutils.py +0 -131
- data/vendor/depot_tools/third_party/logilab/common/xmlutils.py +0 -61
@@ -0,0 +1,13 @@
|
|
1
|
+
def identity(obj):
|
2
|
+
return obj
|
3
|
+
|
4
|
+
|
5
|
+
class cached_property(object):
|
6
|
+
def __init__(self, func):
|
7
|
+
self.func = func
|
8
|
+
|
9
|
+
def __get__(self, obj, cls):
|
10
|
+
if obj is None:
|
11
|
+
return self
|
12
|
+
value = obj.__dict__[self.func.__name__] = self.func(obj)
|
13
|
+
return value
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2013-2017, Graham Dumpleton
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
8
|
+
list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
17
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
18
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
19
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
20
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
21
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
22
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
23
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
24
|
+
POSSIBILITY OF SUCH DAMAGE.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
URL: https://github.com/GrahamDumpleton/wrapt
|
2
|
+
URL: https://pypi.org/project/wrapt/#files
|
3
|
+
Version: 1.10.11
|
4
|
+
License: BSD-2
|
5
|
+
License File: LICENSE
|
6
|
+
|
7
|
+
Description:
|
8
|
+
This directory contains the wrapt module, required for pylint.
|
9
|
+
|
10
|
+
Local Modifications:
|
11
|
+
None
|
@@ -0,0 +1,19 @@
|
|
1
|
+
__version_info__ = ('1', '10', '11')
|
2
|
+
__version__ = '.'.join(__version_info__)
|
3
|
+
|
4
|
+
from .wrappers import (ObjectProxy, CallableObjectProxy, FunctionWrapper,
|
5
|
+
BoundFunctionWrapper, WeakFunctionProxy, resolve_path, apply_patch,
|
6
|
+
wrap_object, wrap_object_attribute, function_wrapper,
|
7
|
+
wrap_function_wrapper, patch_function_wrapper,
|
8
|
+
transient_function_wrapper)
|
9
|
+
|
10
|
+
from .decorators import (adapter_factory, AdapterFactory, decorator,
|
11
|
+
synchronized)
|
12
|
+
|
13
|
+
from .importer import (register_post_import_hook, when_imported,
|
14
|
+
notify_module_loaded, discover_post_import_hooks)
|
15
|
+
|
16
|
+
try:
|
17
|
+
from inspect import getcallargs
|
18
|
+
except ImportError:
|
19
|
+
from .arguments import getcallargs
|
@@ -0,0 +1,2729 @@
|
|
1
|
+
/* ------------------------------------------------------------------------- */
|
2
|
+
|
3
|
+
#include "Python.h"
|
4
|
+
|
5
|
+
#include "structmember.h"
|
6
|
+
|
7
|
+
#ifndef PyVarObject_HEAD_INIT
|
8
|
+
#define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
|
9
|
+
#endif
|
10
|
+
|
11
|
+
/* ------------------------------------------------------------------------- */
|
12
|
+
|
13
|
+
typedef struct {
|
14
|
+
PyObject_HEAD
|
15
|
+
|
16
|
+
PyObject *dict;
|
17
|
+
PyObject *wrapped;
|
18
|
+
PyObject *weakreflist;
|
19
|
+
} WraptObjectProxyObject;
|
20
|
+
|
21
|
+
PyTypeObject WraptObjectProxy_Type;
|
22
|
+
PyTypeObject WraptCallableObjectProxy_Type;
|
23
|
+
|
24
|
+
typedef struct {
|
25
|
+
WraptObjectProxyObject object_proxy;
|
26
|
+
|
27
|
+
PyObject *instance;
|
28
|
+
PyObject *wrapper;
|
29
|
+
PyObject *enabled;
|
30
|
+
PyObject *binding;
|
31
|
+
PyObject *parent;
|
32
|
+
} WraptFunctionWrapperObject;
|
33
|
+
|
34
|
+
PyTypeObject WraptFunctionWrapperBase_Type;
|
35
|
+
PyTypeObject WraptBoundFunctionWrapper_Type;
|
36
|
+
PyTypeObject WraptFunctionWrapper_Type;
|
37
|
+
|
38
|
+
/* ------------------------------------------------------------------------- */
|
39
|
+
|
40
|
+
static PyObject *WraptObjectProxy_new(PyTypeObject *type,
|
41
|
+
PyObject *args, PyObject *kwds)
|
42
|
+
{
|
43
|
+
WraptObjectProxyObject *self;
|
44
|
+
|
45
|
+
self = (WraptObjectProxyObject *)type->tp_alloc(type, 0);
|
46
|
+
|
47
|
+
if (!self)
|
48
|
+
return NULL;
|
49
|
+
|
50
|
+
self->dict = PyDict_New();
|
51
|
+
self->wrapped = NULL;
|
52
|
+
self->weakreflist = NULL;
|
53
|
+
|
54
|
+
return (PyObject *)self;
|
55
|
+
}
|
56
|
+
|
57
|
+
/* ------------------------------------------------------------------------- */
|
58
|
+
|
59
|
+
static int WraptObjectProxy_raw_init(WraptObjectProxyObject *self,
|
60
|
+
PyObject *wrapped)
|
61
|
+
{
|
62
|
+
static PyObject *module_str = NULL;
|
63
|
+
static PyObject *doc_str = NULL;
|
64
|
+
|
65
|
+
PyObject *object = NULL;
|
66
|
+
|
67
|
+
Py_INCREF(wrapped);
|
68
|
+
Py_XDECREF(self->wrapped);
|
69
|
+
self->wrapped = wrapped;
|
70
|
+
|
71
|
+
if (!module_str) {
|
72
|
+
#if PY_MAJOR_VERSION >= 3
|
73
|
+
module_str = PyUnicode_InternFromString("__module__");
|
74
|
+
#else
|
75
|
+
module_str = PyString_InternFromString("__module__");
|
76
|
+
#endif
|
77
|
+
}
|
78
|
+
|
79
|
+
if (!doc_str) {
|
80
|
+
#if PY_MAJOR_VERSION >= 3
|
81
|
+
doc_str = PyUnicode_InternFromString("__doc__");
|
82
|
+
#else
|
83
|
+
doc_str = PyString_InternFromString("__doc__");
|
84
|
+
#endif
|
85
|
+
}
|
86
|
+
|
87
|
+
object = PyObject_GetAttr(wrapped, module_str);
|
88
|
+
|
89
|
+
if (object) {
|
90
|
+
if (PyDict_SetItem(self->dict, module_str, object) == -1) {
|
91
|
+
Py_DECREF(object);
|
92
|
+
return -1;
|
93
|
+
}
|
94
|
+
Py_DECREF(object);
|
95
|
+
}
|
96
|
+
else
|
97
|
+
PyErr_Clear();
|
98
|
+
|
99
|
+
object = PyObject_GetAttr(wrapped, doc_str);
|
100
|
+
|
101
|
+
if (object) {
|
102
|
+
if (PyDict_SetItem(self->dict, doc_str, object) == -1) {
|
103
|
+
Py_DECREF(object);
|
104
|
+
return -1;
|
105
|
+
}
|
106
|
+
Py_DECREF(object);
|
107
|
+
}
|
108
|
+
else
|
109
|
+
PyErr_Clear();
|
110
|
+
|
111
|
+
return 0;
|
112
|
+
}
|
113
|
+
|
114
|
+
/* ------------------------------------------------------------------------- */
|
115
|
+
|
116
|
+
static int WraptObjectProxy_init(WraptObjectProxyObject *self,
|
117
|
+
PyObject *args, PyObject *kwds)
|
118
|
+
{
|
119
|
+
PyObject *wrapped = NULL;
|
120
|
+
|
121
|
+
static char *kwlist[] = { "wrapped", NULL };
|
122
|
+
|
123
|
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:ObjectProxy",
|
124
|
+
kwlist, &wrapped)) {
|
125
|
+
return -1;
|
126
|
+
}
|
127
|
+
|
128
|
+
return WraptObjectProxy_raw_init(self, wrapped);
|
129
|
+
}
|
130
|
+
|
131
|
+
/* ------------------------------------------------------------------------- */
|
132
|
+
|
133
|
+
static int WraptObjectProxy_traverse(WraptObjectProxyObject *self,
|
134
|
+
visitproc visit, void *arg)
|
135
|
+
{
|
136
|
+
Py_VISIT(self->dict);
|
137
|
+
Py_VISIT(self->wrapped);
|
138
|
+
|
139
|
+
return 0;
|
140
|
+
}
|
141
|
+
|
142
|
+
/* ------------------------------------------------------------------------- */
|
143
|
+
|
144
|
+
static int WraptObjectProxy_clear(WraptObjectProxyObject *self)
|
145
|
+
{
|
146
|
+
Py_CLEAR(self->dict);
|
147
|
+
Py_CLEAR(self->wrapped);
|
148
|
+
|
149
|
+
return 0;
|
150
|
+
}
|
151
|
+
|
152
|
+
/* ------------------------------------------------------------------------- */
|
153
|
+
|
154
|
+
static void WraptObjectProxy_dealloc(WraptObjectProxyObject *self)
|
155
|
+
{
|
156
|
+
PyObject_GC_UnTrack(self);
|
157
|
+
|
158
|
+
if (self->weakreflist != NULL)
|
159
|
+
PyObject_ClearWeakRefs((PyObject *)self);
|
160
|
+
|
161
|
+
WraptObjectProxy_clear(self);
|
162
|
+
|
163
|
+
Py_TYPE(self)->tp_free(self);
|
164
|
+
}
|
165
|
+
|
166
|
+
/* ------------------------------------------------------------------------- */
|
167
|
+
|
168
|
+
static PyObject *WraptObjectProxy_repr(WraptObjectProxyObject *self)
|
169
|
+
{
|
170
|
+
if (!self->wrapped) {
|
171
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
172
|
+
return NULL;
|
173
|
+
}
|
174
|
+
|
175
|
+
#if PY_MAJOR_VERSION >= 3
|
176
|
+
return PyUnicode_FromFormat("<%s at %p for %s at %p>",
|
177
|
+
Py_TYPE(self)->tp_name, self,
|
178
|
+
Py_TYPE(self->wrapped)->tp_name, self->wrapped);
|
179
|
+
#else
|
180
|
+
return PyString_FromFormat("<%s at %p for %s at %p>",
|
181
|
+
Py_TYPE(self)->tp_name, self,
|
182
|
+
Py_TYPE(self->wrapped)->tp_name, self->wrapped);
|
183
|
+
#endif
|
184
|
+
}
|
185
|
+
|
186
|
+
/* ------------------------------------------------------------------------- */
|
187
|
+
|
188
|
+
static long WraptObjectProxy_hash(WraptObjectProxyObject *self)
|
189
|
+
{
|
190
|
+
if (!self->wrapped) {
|
191
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
192
|
+
return -1;
|
193
|
+
}
|
194
|
+
|
195
|
+
return PyObject_Hash(self->wrapped);
|
196
|
+
}
|
197
|
+
|
198
|
+
/* ------------------------------------------------------------------------- */
|
199
|
+
|
200
|
+
static PyObject *WraptObjectProxy_str(WraptObjectProxyObject *self)
|
201
|
+
{
|
202
|
+
if (!self->wrapped) {
|
203
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
204
|
+
return NULL;
|
205
|
+
}
|
206
|
+
|
207
|
+
return PyObject_Str(self->wrapped);
|
208
|
+
}
|
209
|
+
|
210
|
+
/* ------------------------------------------------------------------------- */
|
211
|
+
|
212
|
+
static PyObject *WraptObjectProxy_add(PyObject *o1, PyObject *o2)
|
213
|
+
{
|
214
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
215
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
216
|
+
return NULL;
|
217
|
+
}
|
218
|
+
|
219
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
220
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
221
|
+
return NULL;
|
222
|
+
}
|
223
|
+
|
224
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
225
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
226
|
+
|
227
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
228
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
229
|
+
|
230
|
+
return PyNumber_Add(o1, o2);
|
231
|
+
}
|
232
|
+
|
233
|
+
/* ------------------------------------------------------------------------- */
|
234
|
+
|
235
|
+
static PyObject *WraptObjectProxy_subtract(PyObject *o1, PyObject *o2)
|
236
|
+
{
|
237
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
238
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
239
|
+
return NULL;
|
240
|
+
}
|
241
|
+
|
242
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
243
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
244
|
+
return NULL;
|
245
|
+
}
|
246
|
+
|
247
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
248
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
249
|
+
|
250
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
251
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
252
|
+
|
253
|
+
|
254
|
+
return PyNumber_Subtract(o1, o2);
|
255
|
+
}
|
256
|
+
|
257
|
+
/* ------------------------------------------------------------------------- */
|
258
|
+
|
259
|
+
static PyObject *WraptObjectProxy_multiply(PyObject *o1, PyObject *o2)
|
260
|
+
{
|
261
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
262
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
263
|
+
return NULL;
|
264
|
+
}
|
265
|
+
|
266
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
267
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
268
|
+
return NULL;
|
269
|
+
}
|
270
|
+
|
271
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
272
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
273
|
+
|
274
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
275
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
276
|
+
|
277
|
+
return PyNumber_Multiply(o1, o2);
|
278
|
+
}
|
279
|
+
|
280
|
+
/* ------------------------------------------------------------------------- */
|
281
|
+
|
282
|
+
#if PY_MAJOR_VERSION < 3
|
283
|
+
static PyObject *WraptObjectProxy_divide(PyObject *o1, PyObject *o2)
|
284
|
+
{
|
285
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
286
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
287
|
+
return NULL;
|
288
|
+
}
|
289
|
+
|
290
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
291
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
292
|
+
return NULL;
|
293
|
+
}
|
294
|
+
|
295
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
296
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
297
|
+
|
298
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
299
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
300
|
+
|
301
|
+
return PyNumber_Divide(o1, o2);
|
302
|
+
}
|
303
|
+
#endif
|
304
|
+
|
305
|
+
/* ------------------------------------------------------------------------- */
|
306
|
+
|
307
|
+
static PyObject *WraptObjectProxy_remainder(PyObject *o1, PyObject *o2)
|
308
|
+
{
|
309
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
310
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
311
|
+
return NULL;
|
312
|
+
}
|
313
|
+
|
314
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
315
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
316
|
+
return NULL;
|
317
|
+
}
|
318
|
+
|
319
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
320
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
321
|
+
|
322
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
323
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
324
|
+
|
325
|
+
return PyNumber_Remainder(o1, o2);
|
326
|
+
}
|
327
|
+
|
328
|
+
/* ------------------------------------------------------------------------- */
|
329
|
+
|
330
|
+
static PyObject *WraptObjectProxy_divmod(PyObject *o1, PyObject *o2)
|
331
|
+
{
|
332
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
333
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
334
|
+
return NULL;
|
335
|
+
}
|
336
|
+
|
337
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
338
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
339
|
+
return NULL;
|
340
|
+
}
|
341
|
+
|
342
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
343
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
344
|
+
|
345
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
346
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
347
|
+
|
348
|
+
return PyNumber_Divmod(o1, o2);
|
349
|
+
}
|
350
|
+
|
351
|
+
/* ------------------------------------------------------------------------- */
|
352
|
+
|
353
|
+
static PyObject *WraptObjectProxy_power(PyObject *o1, PyObject *o2,
|
354
|
+
PyObject *modulo)
|
355
|
+
{
|
356
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
357
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
358
|
+
return NULL;
|
359
|
+
}
|
360
|
+
|
361
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
362
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
363
|
+
return NULL;
|
364
|
+
}
|
365
|
+
|
366
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
367
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
368
|
+
|
369
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
370
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
371
|
+
|
372
|
+
return PyNumber_Power(o1, o2, modulo);
|
373
|
+
}
|
374
|
+
|
375
|
+
/* ------------------------------------------------------------------------- */
|
376
|
+
|
377
|
+
static PyObject *WraptObjectProxy_negative(WraptObjectProxyObject *self)
|
378
|
+
{
|
379
|
+
if (!self->wrapped) {
|
380
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
381
|
+
return NULL;
|
382
|
+
}
|
383
|
+
|
384
|
+
return PyNumber_Negative(self->wrapped);
|
385
|
+
}
|
386
|
+
|
387
|
+
/* ------------------------------------------------------------------------- */
|
388
|
+
|
389
|
+
static PyObject *WraptObjectProxy_positive(WraptObjectProxyObject *self)
|
390
|
+
{
|
391
|
+
if (!self->wrapped) {
|
392
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
393
|
+
return NULL;
|
394
|
+
}
|
395
|
+
|
396
|
+
return PyNumber_Positive(self->wrapped);
|
397
|
+
}
|
398
|
+
|
399
|
+
/* ------------------------------------------------------------------------- */
|
400
|
+
|
401
|
+
static PyObject *WraptObjectProxy_absolute(WraptObjectProxyObject *self)
|
402
|
+
{
|
403
|
+
if (!self->wrapped) {
|
404
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
405
|
+
return NULL;
|
406
|
+
}
|
407
|
+
|
408
|
+
return PyNumber_Absolute(self->wrapped);
|
409
|
+
}
|
410
|
+
|
411
|
+
/* ------------------------------------------------------------------------- */
|
412
|
+
|
413
|
+
static int WraptObjectProxy_bool(WraptObjectProxyObject *self)
|
414
|
+
{
|
415
|
+
if (!self->wrapped) {
|
416
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
417
|
+
return -1;
|
418
|
+
}
|
419
|
+
|
420
|
+
return PyObject_IsTrue(self->wrapped);
|
421
|
+
}
|
422
|
+
|
423
|
+
/* ------------------------------------------------------------------------- */
|
424
|
+
|
425
|
+
static PyObject *WraptObjectProxy_invert(WraptObjectProxyObject *self)
|
426
|
+
{
|
427
|
+
if (!self->wrapped) {
|
428
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
429
|
+
return NULL;
|
430
|
+
}
|
431
|
+
|
432
|
+
return PyNumber_Invert(self->wrapped);
|
433
|
+
}
|
434
|
+
|
435
|
+
/* ------------------------------------------------------------------------- */
|
436
|
+
|
437
|
+
static PyObject *WraptObjectProxy_lshift(PyObject *o1, PyObject *o2)
|
438
|
+
{
|
439
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
440
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
441
|
+
return NULL;
|
442
|
+
}
|
443
|
+
|
444
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
445
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
446
|
+
return NULL;
|
447
|
+
}
|
448
|
+
|
449
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
450
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
451
|
+
|
452
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
453
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
454
|
+
|
455
|
+
return PyNumber_Lshift(o1, o2);
|
456
|
+
}
|
457
|
+
|
458
|
+
/* ------------------------------------------------------------------------- */
|
459
|
+
|
460
|
+
static PyObject *WraptObjectProxy_rshift(PyObject *o1, PyObject *o2)
|
461
|
+
{
|
462
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
463
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
464
|
+
return NULL;
|
465
|
+
}
|
466
|
+
|
467
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
468
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
469
|
+
return NULL;
|
470
|
+
}
|
471
|
+
|
472
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
473
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
474
|
+
|
475
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
476
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
477
|
+
|
478
|
+
return PyNumber_Rshift(o1, o2);
|
479
|
+
}
|
480
|
+
|
481
|
+
/* ------------------------------------------------------------------------- */
|
482
|
+
|
483
|
+
static PyObject *WraptObjectProxy_and(PyObject *o1, PyObject *o2)
|
484
|
+
{
|
485
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
486
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
487
|
+
return NULL;
|
488
|
+
}
|
489
|
+
|
490
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
491
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
492
|
+
return NULL;
|
493
|
+
}
|
494
|
+
|
495
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
496
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
497
|
+
|
498
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
499
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
500
|
+
|
501
|
+
return PyNumber_And(o1, o2);
|
502
|
+
}
|
503
|
+
|
504
|
+
/* ------------------------------------------------------------------------- */
|
505
|
+
|
506
|
+
static PyObject *WraptObjectProxy_xor(PyObject *o1, PyObject *o2)
|
507
|
+
{
|
508
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
509
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
510
|
+
return NULL;
|
511
|
+
}
|
512
|
+
|
513
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
514
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
515
|
+
return NULL;
|
516
|
+
}
|
517
|
+
|
518
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
519
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
520
|
+
|
521
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
522
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
523
|
+
|
524
|
+
return PyNumber_Xor(o1, o2);
|
525
|
+
}
|
526
|
+
|
527
|
+
/* ------------------------------------------------------------------------- */
|
528
|
+
|
529
|
+
static PyObject *WraptObjectProxy_or(PyObject *o1, PyObject *o2)
|
530
|
+
{
|
531
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
532
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
533
|
+
return NULL;
|
534
|
+
}
|
535
|
+
|
536
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
537
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
538
|
+
return NULL;
|
539
|
+
}
|
540
|
+
|
541
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
542
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
543
|
+
|
544
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
545
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
546
|
+
|
547
|
+
return PyNumber_Or(o1, o2);
|
548
|
+
}
|
549
|
+
|
550
|
+
/* ------------------------------------------------------------------------- */
|
551
|
+
|
552
|
+
#if PY_MAJOR_VERSION < 3
|
553
|
+
static PyObject *WraptObjectProxy_int(WraptObjectProxyObject *self)
|
554
|
+
{
|
555
|
+
if (!self->wrapped) {
|
556
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
557
|
+
return NULL;
|
558
|
+
}
|
559
|
+
|
560
|
+
return PyNumber_Int(self->wrapped);
|
561
|
+
}
|
562
|
+
#endif
|
563
|
+
|
564
|
+
/* ------------------------------------------------------------------------- */
|
565
|
+
|
566
|
+
static PyObject *WraptObjectProxy_long(WraptObjectProxyObject *self)
|
567
|
+
{
|
568
|
+
if (!self->wrapped) {
|
569
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
570
|
+
return NULL;
|
571
|
+
}
|
572
|
+
|
573
|
+
return PyNumber_Long(self->wrapped);
|
574
|
+
}
|
575
|
+
|
576
|
+
/* ------------------------------------------------------------------------- */
|
577
|
+
|
578
|
+
static PyObject *WraptObjectProxy_float(WraptObjectProxyObject *self)
|
579
|
+
{
|
580
|
+
if (!self->wrapped) {
|
581
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
582
|
+
return NULL;
|
583
|
+
}
|
584
|
+
|
585
|
+
return PyNumber_Float(self->wrapped);
|
586
|
+
}
|
587
|
+
|
588
|
+
/* ------------------------------------------------------------------------- */
|
589
|
+
|
590
|
+
#if PY_MAJOR_VERSION < 3
|
591
|
+
static PyObject *WraptObjectProxy_oct(WraptObjectProxyObject *self)
|
592
|
+
{
|
593
|
+
PyNumberMethods *nb;
|
594
|
+
|
595
|
+
if (!self->wrapped) {
|
596
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
597
|
+
return NULL;
|
598
|
+
}
|
599
|
+
|
600
|
+
if ((nb = self->wrapped->ob_type->tp_as_number) == NULL ||
|
601
|
+
nb->nb_oct == NULL) {
|
602
|
+
PyErr_SetString(PyExc_TypeError,
|
603
|
+
"oct() argument can't be converted to oct");
|
604
|
+
return NULL;
|
605
|
+
}
|
606
|
+
|
607
|
+
return (*nb->nb_oct)(self->wrapped);
|
608
|
+
}
|
609
|
+
#endif
|
610
|
+
|
611
|
+
/* ------------------------------------------------------------------------- */
|
612
|
+
|
613
|
+
#if PY_MAJOR_VERSION < 3
|
614
|
+
static PyObject *WraptObjectProxy_hex(WraptObjectProxyObject *self)
|
615
|
+
{
|
616
|
+
PyNumberMethods *nb;
|
617
|
+
|
618
|
+
if (!self->wrapped) {
|
619
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
620
|
+
return NULL;
|
621
|
+
}
|
622
|
+
|
623
|
+
if ((nb = self->wrapped->ob_type->tp_as_number) == NULL ||
|
624
|
+
nb->nb_hex == NULL) {
|
625
|
+
PyErr_SetString(PyExc_TypeError,
|
626
|
+
"hex() argument can't be converted to hex");
|
627
|
+
return NULL;
|
628
|
+
}
|
629
|
+
|
630
|
+
return (*nb->nb_hex)(self->wrapped);
|
631
|
+
}
|
632
|
+
#endif
|
633
|
+
|
634
|
+
/* ------------------------------------------------------------------------- */
|
635
|
+
|
636
|
+
static PyObject *WraptObjectProxy_inplace_add(WraptObjectProxyObject *self,
|
637
|
+
PyObject *other)
|
638
|
+
{
|
639
|
+
PyObject *object = NULL;
|
640
|
+
|
641
|
+
if (!self->wrapped) {
|
642
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
643
|
+
return NULL;
|
644
|
+
}
|
645
|
+
|
646
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
647
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
648
|
+
|
649
|
+
object = PyNumber_InPlaceAdd(self->wrapped, other);
|
650
|
+
|
651
|
+
if (!object)
|
652
|
+
return NULL;
|
653
|
+
|
654
|
+
Py_DECREF(self->wrapped);
|
655
|
+
self->wrapped = object;
|
656
|
+
|
657
|
+
Py_INCREF(self);
|
658
|
+
return (PyObject *)self;
|
659
|
+
}
|
660
|
+
|
661
|
+
/* ------------------------------------------------------------------------- */
|
662
|
+
|
663
|
+
static PyObject *WraptObjectProxy_inplace_subtract(
|
664
|
+
WraptObjectProxyObject *self, PyObject *other)
|
665
|
+
{
|
666
|
+
PyObject *object = NULL;
|
667
|
+
|
668
|
+
if (!self->wrapped) {
|
669
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
670
|
+
return NULL;
|
671
|
+
}
|
672
|
+
|
673
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
674
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
675
|
+
|
676
|
+
object = PyNumber_InPlaceSubtract(self->wrapped, other);
|
677
|
+
|
678
|
+
if (!object)
|
679
|
+
return NULL;
|
680
|
+
|
681
|
+
Py_DECREF(self->wrapped);
|
682
|
+
self->wrapped = object;
|
683
|
+
|
684
|
+
Py_INCREF(self);
|
685
|
+
return (PyObject *)self;
|
686
|
+
}
|
687
|
+
|
688
|
+
/* ------------------------------------------------------------------------- */
|
689
|
+
|
690
|
+
static PyObject *WraptObjectProxy_inplace_multiply(
|
691
|
+
WraptObjectProxyObject *self, PyObject *other)
|
692
|
+
{
|
693
|
+
PyObject *object = NULL;
|
694
|
+
|
695
|
+
if (!self->wrapped) {
|
696
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
697
|
+
return NULL;
|
698
|
+
}
|
699
|
+
|
700
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
701
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
702
|
+
|
703
|
+
object = PyNumber_InPlaceMultiply(self->wrapped, other);
|
704
|
+
|
705
|
+
if (!object)
|
706
|
+
return NULL;
|
707
|
+
|
708
|
+
Py_DECREF(self->wrapped);
|
709
|
+
self->wrapped = object;
|
710
|
+
|
711
|
+
Py_INCREF(self);
|
712
|
+
return (PyObject *)self;
|
713
|
+
}
|
714
|
+
|
715
|
+
/* ------------------------------------------------------------------------- */
|
716
|
+
|
717
|
+
#if PY_MAJOR_VERSION < 3
|
718
|
+
static PyObject *WraptObjectProxy_inplace_divide(
|
719
|
+
WraptObjectProxyObject *self, PyObject *other)
|
720
|
+
{
|
721
|
+
PyObject *object = NULL;
|
722
|
+
|
723
|
+
if (!self->wrapped) {
|
724
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
725
|
+
return NULL;
|
726
|
+
}
|
727
|
+
|
728
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
729
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
730
|
+
|
731
|
+
object = PyNumber_InPlaceDivide(self->wrapped, other);
|
732
|
+
|
733
|
+
if (!object)
|
734
|
+
return NULL;
|
735
|
+
|
736
|
+
Py_DECREF(self->wrapped);
|
737
|
+
self->wrapped = object;
|
738
|
+
|
739
|
+
Py_INCREF(self);
|
740
|
+
return (PyObject *)self;
|
741
|
+
}
|
742
|
+
#endif
|
743
|
+
|
744
|
+
/* ------------------------------------------------------------------------- */
|
745
|
+
|
746
|
+
static PyObject *WraptObjectProxy_inplace_remainder(
|
747
|
+
WraptObjectProxyObject *self, PyObject *other)
|
748
|
+
{
|
749
|
+
PyObject *object = NULL;
|
750
|
+
|
751
|
+
if (!self->wrapped) {
|
752
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
753
|
+
return NULL;
|
754
|
+
}
|
755
|
+
|
756
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
757
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
758
|
+
|
759
|
+
object = PyNumber_InPlaceRemainder(self->wrapped, other);
|
760
|
+
|
761
|
+
if (!object)
|
762
|
+
return NULL;
|
763
|
+
|
764
|
+
Py_DECREF(self->wrapped);
|
765
|
+
self->wrapped = object;
|
766
|
+
|
767
|
+
Py_INCREF(self);
|
768
|
+
return (PyObject *)self;
|
769
|
+
}
|
770
|
+
|
771
|
+
/* ------------------------------------------------------------------------- */
|
772
|
+
|
773
|
+
static PyObject *WraptObjectProxy_inplace_power(WraptObjectProxyObject *self,
|
774
|
+
PyObject *other, PyObject *modulo)
|
775
|
+
{
|
776
|
+
PyObject *object = NULL;
|
777
|
+
|
778
|
+
if (!self->wrapped) {
|
779
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
780
|
+
return NULL;
|
781
|
+
}
|
782
|
+
|
783
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
784
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
785
|
+
|
786
|
+
object = PyNumber_InPlacePower(self->wrapped, other, modulo);
|
787
|
+
|
788
|
+
if (!object)
|
789
|
+
return NULL;
|
790
|
+
|
791
|
+
Py_DECREF(self->wrapped);
|
792
|
+
self->wrapped = object;
|
793
|
+
|
794
|
+
Py_INCREF(self);
|
795
|
+
return (PyObject *)self;
|
796
|
+
}
|
797
|
+
|
798
|
+
/* ------------------------------------------------------------------------- */
|
799
|
+
|
800
|
+
static PyObject *WraptObjectProxy_inplace_lshift(WraptObjectProxyObject *self,
|
801
|
+
PyObject *other)
|
802
|
+
{
|
803
|
+
PyObject *object = NULL;
|
804
|
+
|
805
|
+
if (!self->wrapped) {
|
806
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
807
|
+
return NULL;
|
808
|
+
}
|
809
|
+
|
810
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
811
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
812
|
+
|
813
|
+
object = PyNumber_InPlaceLshift(self->wrapped, other);
|
814
|
+
|
815
|
+
if (!object)
|
816
|
+
return NULL;
|
817
|
+
|
818
|
+
Py_DECREF(self->wrapped);
|
819
|
+
self->wrapped = object;
|
820
|
+
|
821
|
+
Py_INCREF(self);
|
822
|
+
return (PyObject *)self;
|
823
|
+
}
|
824
|
+
|
825
|
+
/* ------------------------------------------------------------------------- */
|
826
|
+
|
827
|
+
static PyObject *WraptObjectProxy_inplace_rshift(WraptObjectProxyObject *self,
|
828
|
+
PyObject *other)
|
829
|
+
{
|
830
|
+
PyObject *object = NULL;
|
831
|
+
|
832
|
+
if (!self->wrapped) {
|
833
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
834
|
+
return NULL;
|
835
|
+
}
|
836
|
+
|
837
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
838
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
839
|
+
|
840
|
+
object = PyNumber_InPlaceRshift(self->wrapped, other);
|
841
|
+
|
842
|
+
if (!object)
|
843
|
+
return NULL;
|
844
|
+
|
845
|
+
Py_DECREF(self->wrapped);
|
846
|
+
self->wrapped = object;
|
847
|
+
|
848
|
+
Py_INCREF(self);
|
849
|
+
return (PyObject *)self;
|
850
|
+
}
|
851
|
+
|
852
|
+
/* ------------------------------------------------------------------------- */
|
853
|
+
|
854
|
+
static PyObject *WraptObjectProxy_inplace_and(WraptObjectProxyObject *self,
|
855
|
+
PyObject *other)
|
856
|
+
{
|
857
|
+
PyObject *object = NULL;
|
858
|
+
|
859
|
+
if (!self->wrapped) {
|
860
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
861
|
+
return NULL;
|
862
|
+
}
|
863
|
+
|
864
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
865
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
866
|
+
|
867
|
+
object = PyNumber_InPlaceAnd(self->wrapped, other);
|
868
|
+
|
869
|
+
if (!object)
|
870
|
+
return NULL;
|
871
|
+
|
872
|
+
Py_DECREF(self->wrapped);
|
873
|
+
self->wrapped = object;
|
874
|
+
|
875
|
+
Py_INCREF(self);
|
876
|
+
return (PyObject *)self;
|
877
|
+
}
|
878
|
+
|
879
|
+
/* ------------------------------------------------------------------------- */
|
880
|
+
|
881
|
+
static PyObject *WraptObjectProxy_inplace_xor(WraptObjectProxyObject *self,
|
882
|
+
PyObject *other)
|
883
|
+
{
|
884
|
+
PyObject *object = NULL;
|
885
|
+
|
886
|
+
if (!self->wrapped) {
|
887
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
888
|
+
return NULL;
|
889
|
+
}
|
890
|
+
|
891
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
892
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
893
|
+
|
894
|
+
object = PyNumber_InPlaceXor(self->wrapped, other);
|
895
|
+
|
896
|
+
if (!object)
|
897
|
+
return NULL;
|
898
|
+
|
899
|
+
Py_DECREF(self->wrapped);
|
900
|
+
self->wrapped = object;
|
901
|
+
|
902
|
+
Py_INCREF(self);
|
903
|
+
return (PyObject *)self;
|
904
|
+
}
|
905
|
+
|
906
|
+
/* ------------------------------------------------------------------------- */
|
907
|
+
|
908
|
+
static PyObject *WraptObjectProxy_inplace_or(WraptObjectProxyObject *self,
|
909
|
+
PyObject *other)
|
910
|
+
{
|
911
|
+
PyObject *object = NULL;
|
912
|
+
|
913
|
+
if (!self->wrapped) {
|
914
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
915
|
+
return NULL;
|
916
|
+
}
|
917
|
+
|
918
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
919
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
920
|
+
|
921
|
+
object = PyNumber_InPlaceOr(self->wrapped, other);
|
922
|
+
|
923
|
+
Py_DECREF(self->wrapped);
|
924
|
+
self->wrapped = object;
|
925
|
+
|
926
|
+
Py_INCREF(self);
|
927
|
+
return (PyObject *)self;
|
928
|
+
}
|
929
|
+
|
930
|
+
/* ------------------------------------------------------------------------- */
|
931
|
+
|
932
|
+
static PyObject *WraptObjectProxy_floor_divide(PyObject *o1, PyObject *o2)
|
933
|
+
{
|
934
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
935
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
936
|
+
return NULL;
|
937
|
+
}
|
938
|
+
|
939
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
940
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
941
|
+
return NULL;
|
942
|
+
}
|
943
|
+
|
944
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
945
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
946
|
+
|
947
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
948
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
949
|
+
|
950
|
+
return PyNumber_FloorDivide(o1, o2);
|
951
|
+
}
|
952
|
+
|
953
|
+
/* ------------------------------------------------------------------------- */
|
954
|
+
|
955
|
+
static PyObject *WraptObjectProxy_true_divide(PyObject *o1, PyObject *o2)
|
956
|
+
{
|
957
|
+
if (!((WraptObjectProxyObject *)o1)->wrapped) {
|
958
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
959
|
+
return NULL;
|
960
|
+
}
|
961
|
+
|
962
|
+
if (!((WraptObjectProxyObject *)o2)->wrapped) {
|
963
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
964
|
+
return NULL;
|
965
|
+
}
|
966
|
+
|
967
|
+
if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
|
968
|
+
o1 = ((WraptObjectProxyObject *)o1)->wrapped;
|
969
|
+
|
970
|
+
if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
|
971
|
+
o2 = ((WraptObjectProxyObject *)o2)->wrapped;
|
972
|
+
|
973
|
+
return PyNumber_TrueDivide(o1, o2);
|
974
|
+
}
|
975
|
+
|
976
|
+
/* ------------------------------------------------------------------------- */
|
977
|
+
|
978
|
+
static PyObject *WraptObjectProxy_inplace_floor_divide(
|
979
|
+
WraptObjectProxyObject *self, PyObject *other)
|
980
|
+
{
|
981
|
+
PyObject *object = NULL;
|
982
|
+
|
983
|
+
if (!self->wrapped) {
|
984
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
985
|
+
return NULL;
|
986
|
+
}
|
987
|
+
|
988
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
989
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
990
|
+
|
991
|
+
object = PyNumber_InPlaceFloorDivide(self->wrapped, other);
|
992
|
+
|
993
|
+
if (!object)
|
994
|
+
return NULL;
|
995
|
+
|
996
|
+
Py_DECREF(self->wrapped);
|
997
|
+
self->wrapped = object;
|
998
|
+
|
999
|
+
Py_INCREF(self);
|
1000
|
+
return (PyObject *)self;
|
1001
|
+
}
|
1002
|
+
|
1003
|
+
/* ------------------------------------------------------------------------- */
|
1004
|
+
|
1005
|
+
static PyObject *WraptObjectProxy_inplace_true_divide(
|
1006
|
+
WraptObjectProxyObject *self, PyObject *other)
|
1007
|
+
{
|
1008
|
+
PyObject *object = NULL;
|
1009
|
+
|
1010
|
+
if (!self->wrapped) {
|
1011
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1012
|
+
return NULL;
|
1013
|
+
}
|
1014
|
+
|
1015
|
+
if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
|
1016
|
+
other = ((WraptObjectProxyObject *)other)->wrapped;
|
1017
|
+
|
1018
|
+
object = PyNumber_InPlaceTrueDivide(self->wrapped, other);
|
1019
|
+
|
1020
|
+
if (!object)
|
1021
|
+
return NULL;
|
1022
|
+
|
1023
|
+
Py_DECREF(self->wrapped);
|
1024
|
+
self->wrapped = object;
|
1025
|
+
|
1026
|
+
Py_INCREF(self);
|
1027
|
+
return (PyObject *)self;
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
/* ------------------------------------------------------------------------- */
|
1031
|
+
|
1032
|
+
static PyObject *WraptObjectProxy_index(WraptObjectProxyObject *self)
|
1033
|
+
{
|
1034
|
+
if (!self->wrapped) {
|
1035
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1036
|
+
return NULL;
|
1037
|
+
}
|
1038
|
+
|
1039
|
+
return PyNumber_Index(self->wrapped);
|
1040
|
+
}
|
1041
|
+
|
1042
|
+
/* ------------------------------------------------------------------------- */
|
1043
|
+
|
1044
|
+
static Py_ssize_t WraptObjectProxy_length(WraptObjectProxyObject *self)
|
1045
|
+
{
|
1046
|
+
if (!self->wrapped) {
|
1047
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1048
|
+
return -1;
|
1049
|
+
}
|
1050
|
+
|
1051
|
+
return PyObject_Length(self->wrapped);
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
/* ------------------------------------------------------------------------- */
|
1055
|
+
|
1056
|
+
static int WraptObjectProxy_contains(WraptObjectProxyObject *self,
|
1057
|
+
PyObject *value)
|
1058
|
+
{
|
1059
|
+
if (!self->wrapped) {
|
1060
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1061
|
+
return -1;
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
return PySequence_Contains(self->wrapped, value);
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
/* ------------------------------------------------------------------------- */
|
1068
|
+
|
1069
|
+
static PyObject *WraptObjectProxy_getitem(WraptObjectProxyObject *self,
|
1070
|
+
PyObject *key)
|
1071
|
+
{
|
1072
|
+
if (!self->wrapped) {
|
1073
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1074
|
+
return NULL;
|
1075
|
+
}
|
1076
|
+
|
1077
|
+
return PyObject_GetItem(self->wrapped, key);
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
/* ------------------------------------------------------------------------- */
|
1081
|
+
|
1082
|
+
static int WraptObjectProxy_setitem(WraptObjectProxyObject *self,
|
1083
|
+
PyObject *key, PyObject* value)
|
1084
|
+
{
|
1085
|
+
if (!self->wrapped) {
|
1086
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1087
|
+
return -1;
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
if (value == NULL)
|
1091
|
+
return PyObject_DelItem(self->wrapped, key);
|
1092
|
+
else
|
1093
|
+
return PyObject_SetItem(self->wrapped, key, value);
|
1094
|
+
}
|
1095
|
+
|
1096
|
+
/* ------------------------------------------------------------------------- */
|
1097
|
+
|
1098
|
+
static PyObject *WraptObjectProxy_dir(
|
1099
|
+
WraptObjectProxyObject *self, PyObject *args)
|
1100
|
+
{
|
1101
|
+
if (!self->wrapped) {
|
1102
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1103
|
+
return NULL;
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
return PyObject_Dir(self->wrapped);
|
1107
|
+
}
|
1108
|
+
|
1109
|
+
/* ------------------------------------------------------------------------- */
|
1110
|
+
|
1111
|
+
static PyObject *WraptObjectProxy_enter(
|
1112
|
+
WraptObjectProxyObject *self, PyObject *args, PyObject *kwds)
|
1113
|
+
{
|
1114
|
+
PyObject *method = NULL;
|
1115
|
+
PyObject *result = NULL;
|
1116
|
+
|
1117
|
+
if (!self->wrapped) {
|
1118
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1119
|
+
return NULL;
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
method = PyObject_GetAttrString(self->wrapped, "__enter__");
|
1123
|
+
|
1124
|
+
if (!method)
|
1125
|
+
return NULL;
|
1126
|
+
|
1127
|
+
result = PyObject_Call(method, args, kwds);
|
1128
|
+
|
1129
|
+
Py_DECREF(method);
|
1130
|
+
|
1131
|
+
return result;
|
1132
|
+
}
|
1133
|
+
|
1134
|
+
/* ------------------------------------------------------------------------- */
|
1135
|
+
|
1136
|
+
static PyObject *WraptObjectProxy_exit(
|
1137
|
+
WraptObjectProxyObject *self, PyObject *args, PyObject *kwds)
|
1138
|
+
{
|
1139
|
+
PyObject *method = NULL;
|
1140
|
+
PyObject *result = NULL;
|
1141
|
+
|
1142
|
+
if (!self->wrapped) {
|
1143
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1144
|
+
return NULL;
|
1145
|
+
}
|
1146
|
+
|
1147
|
+
method = PyObject_GetAttrString(self->wrapped, "__exit__");
|
1148
|
+
|
1149
|
+
if (!method)
|
1150
|
+
return NULL;
|
1151
|
+
|
1152
|
+
result = PyObject_Call(method, args, kwds);
|
1153
|
+
|
1154
|
+
Py_DECREF(method);
|
1155
|
+
|
1156
|
+
return result;
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
/* ------------------------------------------------------------------------- */
|
1160
|
+
|
1161
|
+
static PyObject *WraptObjectProxy_bytes(
|
1162
|
+
WraptObjectProxyObject *self, PyObject *args)
|
1163
|
+
{
|
1164
|
+
if (!self->wrapped) {
|
1165
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1166
|
+
return NULL;
|
1167
|
+
}
|
1168
|
+
|
1169
|
+
return PyObject_Bytes(self->wrapped);
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
/* ------------------------------------------------------------------------- */
|
1173
|
+
|
1174
|
+
static PyObject *WraptObjectProxy_reversed(
|
1175
|
+
WraptObjectProxyObject *self, PyObject *args)
|
1176
|
+
{
|
1177
|
+
if (!self->wrapped) {
|
1178
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1179
|
+
return NULL;
|
1180
|
+
}
|
1181
|
+
|
1182
|
+
return PyObject_CallFunctionObjArgs((PyObject *)&PyReversed_Type,
|
1183
|
+
self->wrapped, NULL);
|
1184
|
+
}
|
1185
|
+
|
1186
|
+
/* ------------------------------------------------------------------------- */
|
1187
|
+
|
1188
|
+
#if PY_MAJOR_VERSION >= 3
|
1189
|
+
static PyObject *WraptObjectProxy_round(
|
1190
|
+
WraptObjectProxyObject *self, PyObject *args)
|
1191
|
+
{
|
1192
|
+
PyObject *module = NULL;
|
1193
|
+
PyObject *dict = NULL;
|
1194
|
+
PyObject *round = NULL;
|
1195
|
+
|
1196
|
+
PyObject *result = NULL;
|
1197
|
+
|
1198
|
+
if (!self->wrapped) {
|
1199
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1200
|
+
return NULL;
|
1201
|
+
}
|
1202
|
+
|
1203
|
+
module = PyImport_ImportModule("builtins");
|
1204
|
+
|
1205
|
+
if (!module)
|
1206
|
+
return NULL;
|
1207
|
+
|
1208
|
+
dict = PyModule_GetDict(module);
|
1209
|
+
round = PyDict_GetItemString(dict, "round");
|
1210
|
+
|
1211
|
+
if (!round) {
|
1212
|
+
Py_DECREF(module);
|
1213
|
+
return NULL;
|
1214
|
+
}
|
1215
|
+
|
1216
|
+
Py_INCREF(round);
|
1217
|
+
Py_DECREF(module);
|
1218
|
+
|
1219
|
+
result = PyObject_CallFunctionObjArgs(round, self->wrapped, NULL);
|
1220
|
+
|
1221
|
+
Py_DECREF(round);
|
1222
|
+
|
1223
|
+
return result;
|
1224
|
+
}
|
1225
|
+
#endif
|
1226
|
+
|
1227
|
+
/* ------------------------------------------------------------------------- */
|
1228
|
+
|
1229
|
+
static PyObject *WraptObjectProxy_get_name(
|
1230
|
+
WraptObjectProxyObject *self)
|
1231
|
+
{
|
1232
|
+
if (!self->wrapped) {
|
1233
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1234
|
+
return NULL;
|
1235
|
+
}
|
1236
|
+
|
1237
|
+
return PyObject_GetAttrString(self->wrapped, "__name__");
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
/* ------------------------------------------------------------------------- */
|
1241
|
+
|
1242
|
+
static int WraptObjectProxy_set_name(WraptObjectProxyObject *self,
|
1243
|
+
PyObject *value)
|
1244
|
+
{
|
1245
|
+
if (!self->wrapped) {
|
1246
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1247
|
+
return -1;
|
1248
|
+
}
|
1249
|
+
|
1250
|
+
return PyObject_SetAttrString(self->wrapped, "__name__", value);
|
1251
|
+
}
|
1252
|
+
|
1253
|
+
/* ------------------------------------------------------------------------- */
|
1254
|
+
|
1255
|
+
static PyObject *WraptObjectProxy_get_qualname(
|
1256
|
+
WraptObjectProxyObject *self)
|
1257
|
+
{
|
1258
|
+
if (!self->wrapped) {
|
1259
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1260
|
+
return NULL;
|
1261
|
+
}
|
1262
|
+
|
1263
|
+
return PyObject_GetAttrString(self->wrapped, "__qualname__");
|
1264
|
+
}
|
1265
|
+
|
1266
|
+
/* ------------------------------------------------------------------------- */
|
1267
|
+
|
1268
|
+
static int WraptObjectProxy_set_qualname(WraptObjectProxyObject *self,
|
1269
|
+
PyObject *value)
|
1270
|
+
{
|
1271
|
+
if (!self->wrapped) {
|
1272
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1273
|
+
return -1;
|
1274
|
+
}
|
1275
|
+
|
1276
|
+
return PyObject_SetAttrString(self->wrapped, "__qualname__", value);
|
1277
|
+
}
|
1278
|
+
|
1279
|
+
/* ------------------------------------------------------------------------- */
|
1280
|
+
|
1281
|
+
static PyObject *WraptObjectProxy_get_module(
|
1282
|
+
WraptObjectProxyObject *self)
|
1283
|
+
{
|
1284
|
+
if (!self->wrapped) {
|
1285
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1286
|
+
return NULL;
|
1287
|
+
}
|
1288
|
+
|
1289
|
+
return PyObject_GetAttrString(self->wrapped, "__module__");
|
1290
|
+
}
|
1291
|
+
|
1292
|
+
/* ------------------------------------------------------------------------- */
|
1293
|
+
|
1294
|
+
static int WraptObjectProxy_set_module(WraptObjectProxyObject *self,
|
1295
|
+
PyObject *value)
|
1296
|
+
{
|
1297
|
+
if (!self->wrapped) {
|
1298
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1299
|
+
return -1;
|
1300
|
+
}
|
1301
|
+
|
1302
|
+
if (PyObject_SetAttrString(self->wrapped, "__module__", value) == -1)
|
1303
|
+
return -1;
|
1304
|
+
|
1305
|
+
return PyDict_SetItemString(self->dict, "__module__", value);
|
1306
|
+
}
|
1307
|
+
|
1308
|
+
/* ------------------------------------------------------------------------- */
|
1309
|
+
|
1310
|
+
static PyObject *WraptObjectProxy_get_doc(
|
1311
|
+
WraptObjectProxyObject *self)
|
1312
|
+
{
|
1313
|
+
if (!self->wrapped) {
|
1314
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1315
|
+
return NULL;
|
1316
|
+
}
|
1317
|
+
|
1318
|
+
return PyObject_GetAttrString(self->wrapped, "__doc__");
|
1319
|
+
}
|
1320
|
+
|
1321
|
+
/* ------------------------------------------------------------------------- */
|
1322
|
+
|
1323
|
+
static int WraptObjectProxy_set_doc(WraptObjectProxyObject *self,
|
1324
|
+
PyObject *value)
|
1325
|
+
{
|
1326
|
+
if (!self->wrapped) {
|
1327
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1328
|
+
return -1;
|
1329
|
+
}
|
1330
|
+
|
1331
|
+
if (PyObject_SetAttrString(self->wrapped, "__doc__", value) == -1)
|
1332
|
+
return -1;
|
1333
|
+
|
1334
|
+
return PyDict_SetItemString(self->dict, "__doc__", value);
|
1335
|
+
}
|
1336
|
+
|
1337
|
+
/* ------------------------------------------------------------------------- */
|
1338
|
+
|
1339
|
+
static PyObject *WraptObjectProxy_get_class(
|
1340
|
+
WraptObjectProxyObject *self)
|
1341
|
+
{
|
1342
|
+
if (!self->wrapped) {
|
1343
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1344
|
+
return NULL;
|
1345
|
+
}
|
1346
|
+
|
1347
|
+
return PyObject_GetAttrString(self->wrapped, "__class__");
|
1348
|
+
}
|
1349
|
+
|
1350
|
+
/* ------------------------------------------------------------------------- */
|
1351
|
+
|
1352
|
+
static PyObject *WraptObjectProxy_get_annotations(
|
1353
|
+
WraptObjectProxyObject *self)
|
1354
|
+
{
|
1355
|
+
if (!self->wrapped) {
|
1356
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1357
|
+
return NULL;
|
1358
|
+
}
|
1359
|
+
|
1360
|
+
return PyObject_GetAttrString(self->wrapped, "__annotations__");
|
1361
|
+
}
|
1362
|
+
|
1363
|
+
/* ------------------------------------------------------------------------- */
|
1364
|
+
|
1365
|
+
static int WraptObjectProxy_set_annotations(WraptObjectProxyObject *self,
|
1366
|
+
PyObject *value)
|
1367
|
+
{
|
1368
|
+
if (!self->wrapped) {
|
1369
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1370
|
+
return -1;
|
1371
|
+
}
|
1372
|
+
|
1373
|
+
return PyObject_SetAttrString(self->wrapped, "__annotations__", value);
|
1374
|
+
}
|
1375
|
+
|
1376
|
+
/* ------------------------------------------------------------------------- */
|
1377
|
+
|
1378
|
+
static PyObject *WraptObjectProxy_get_wrapped(
|
1379
|
+
WraptObjectProxyObject *self)
|
1380
|
+
{
|
1381
|
+
if (!self->wrapped) {
|
1382
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1383
|
+
return NULL;
|
1384
|
+
}
|
1385
|
+
|
1386
|
+
Py_INCREF(self->wrapped);
|
1387
|
+
return self->wrapped;
|
1388
|
+
}
|
1389
|
+
|
1390
|
+
/* ------------------------------------------------------------------------- */
|
1391
|
+
|
1392
|
+
static int WraptObjectProxy_set_wrapped(WraptObjectProxyObject *self,
|
1393
|
+
PyObject *value)
|
1394
|
+
{
|
1395
|
+
if (!value) {
|
1396
|
+
PyErr_SetString(PyExc_TypeError, "__wrapped__ must be an object");
|
1397
|
+
return -1;
|
1398
|
+
}
|
1399
|
+
|
1400
|
+
Py_INCREF(value);
|
1401
|
+
Py_XDECREF(self->wrapped);
|
1402
|
+
|
1403
|
+
self->wrapped = value;
|
1404
|
+
|
1405
|
+
return 0;
|
1406
|
+
}
|
1407
|
+
|
1408
|
+
/* ------------------------------------------------------------------------- */
|
1409
|
+
|
1410
|
+
static PyObject *WraptObjectProxy_getattro(
|
1411
|
+
WraptObjectProxyObject *self, PyObject *name)
|
1412
|
+
{
|
1413
|
+
PyObject *object = NULL;
|
1414
|
+
PyObject *result = NULL;
|
1415
|
+
|
1416
|
+
static PyObject *getattr_str = NULL;
|
1417
|
+
|
1418
|
+
object = PyObject_GenericGetAttr((PyObject *)self, name);
|
1419
|
+
|
1420
|
+
if (object)
|
1421
|
+
return object;
|
1422
|
+
|
1423
|
+
PyErr_Clear();
|
1424
|
+
|
1425
|
+
if (!getattr_str) {
|
1426
|
+
#if PY_MAJOR_VERSION >= 3
|
1427
|
+
getattr_str = PyUnicode_InternFromString("__getattr__");
|
1428
|
+
#else
|
1429
|
+
getattr_str = PyString_InternFromString("__getattr__");
|
1430
|
+
#endif
|
1431
|
+
}
|
1432
|
+
|
1433
|
+
object = PyObject_GenericGetAttr((PyObject *)self, getattr_str);
|
1434
|
+
|
1435
|
+
if (!object)
|
1436
|
+
return NULL;
|
1437
|
+
|
1438
|
+
result = PyObject_CallFunctionObjArgs(object, name, NULL);
|
1439
|
+
|
1440
|
+
Py_DECREF(object);
|
1441
|
+
|
1442
|
+
return result;
|
1443
|
+
}
|
1444
|
+
|
1445
|
+
/* ------------------------------------------------------------------------- */
|
1446
|
+
|
1447
|
+
static PyObject *WraptObjectProxy_getattr(
|
1448
|
+
WraptObjectProxyObject *self, PyObject *args)
|
1449
|
+
{
|
1450
|
+
PyObject *name = NULL;
|
1451
|
+
|
1452
|
+
#if PY_MAJOR_VERSION >= 3
|
1453
|
+
if (!PyArg_ParseTuple(args, "U:__getattr__", &name))
|
1454
|
+
return NULL;
|
1455
|
+
#else
|
1456
|
+
if (!PyArg_ParseTuple(args, "S:__getattr__", &name))
|
1457
|
+
return NULL;
|
1458
|
+
#endif
|
1459
|
+
|
1460
|
+
if (!self->wrapped) {
|
1461
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1462
|
+
return NULL;
|
1463
|
+
}
|
1464
|
+
|
1465
|
+
return PyObject_GetAttr(self->wrapped, name);
|
1466
|
+
}
|
1467
|
+
|
1468
|
+
/* ------------------------------------------------------------------------- */
|
1469
|
+
|
1470
|
+
static int WraptObjectProxy_setattro(
|
1471
|
+
WraptObjectProxyObject *self, PyObject *name, PyObject *value)
|
1472
|
+
{
|
1473
|
+
static PyObject *self_str = NULL;
|
1474
|
+
static PyObject *wrapped_str = NULL;
|
1475
|
+
static PyObject *startswith_str = NULL;
|
1476
|
+
|
1477
|
+
PyObject *match = NULL;
|
1478
|
+
|
1479
|
+
if (!startswith_str) {
|
1480
|
+
#if PY_MAJOR_VERSION >= 3
|
1481
|
+
startswith_str = PyUnicode_InternFromString("startswith");
|
1482
|
+
#else
|
1483
|
+
startswith_str = PyString_InternFromString("startswith");
|
1484
|
+
#endif
|
1485
|
+
}
|
1486
|
+
|
1487
|
+
if (!self_str) {
|
1488
|
+
#if PY_MAJOR_VERSION >= 3
|
1489
|
+
self_str = PyUnicode_InternFromString("_self_");
|
1490
|
+
#else
|
1491
|
+
self_str = PyString_InternFromString("_self_");
|
1492
|
+
#endif
|
1493
|
+
}
|
1494
|
+
|
1495
|
+
match = PyObject_CallMethodObjArgs(name, startswith_str, self_str, NULL);
|
1496
|
+
|
1497
|
+
if (match == Py_True) {
|
1498
|
+
Py_DECREF(match);
|
1499
|
+
|
1500
|
+
return PyObject_GenericSetAttr((PyObject *)self, name, value);
|
1501
|
+
}
|
1502
|
+
else if (!match)
|
1503
|
+
PyErr_Clear();
|
1504
|
+
|
1505
|
+
Py_XDECREF(match);
|
1506
|
+
|
1507
|
+
if (!wrapped_str) {
|
1508
|
+
#if PY_MAJOR_VERSION >= 3
|
1509
|
+
wrapped_str = PyUnicode_InternFromString("__wrapped__");
|
1510
|
+
#else
|
1511
|
+
wrapped_str = PyString_InternFromString("__wrapped__");
|
1512
|
+
#endif
|
1513
|
+
}
|
1514
|
+
|
1515
|
+
if (PyObject_HasAttr((PyObject *)Py_TYPE(self), name))
|
1516
|
+
return PyObject_GenericSetAttr((PyObject *)self, name, value);
|
1517
|
+
|
1518
|
+
if (!self->wrapped) {
|
1519
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1520
|
+
return -1;
|
1521
|
+
}
|
1522
|
+
|
1523
|
+
return PyObject_SetAttr(self->wrapped, name, value);
|
1524
|
+
}
|
1525
|
+
|
1526
|
+
/* ------------------------------------------------------------------------- */
|
1527
|
+
|
1528
|
+
static PyObject *WraptObjectProxy_richcompare(WraptObjectProxyObject *self,
|
1529
|
+
PyObject *other, int opcode)
|
1530
|
+
{
|
1531
|
+
if (!self->wrapped) {
|
1532
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1533
|
+
return NULL;
|
1534
|
+
}
|
1535
|
+
|
1536
|
+
return PyObject_RichCompare(self->wrapped, other, opcode);
|
1537
|
+
}
|
1538
|
+
|
1539
|
+
/* ------------------------------------------------------------------------- */
|
1540
|
+
|
1541
|
+
static PyObject *WraptObjectProxy_iter(WraptObjectProxyObject *self)
|
1542
|
+
{
|
1543
|
+
if (!self->wrapped) {
|
1544
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1545
|
+
return NULL;
|
1546
|
+
}
|
1547
|
+
|
1548
|
+
return PyObject_GetIter(self->wrapped);
|
1549
|
+
}
|
1550
|
+
|
1551
|
+
/* ------------------------------------------------------------------------- */
|
1552
|
+
|
1553
|
+
static PyNumberMethods WraptObjectProxy_as_number = {
|
1554
|
+
(binaryfunc)WraptObjectProxy_add, /*nb_add*/
|
1555
|
+
(binaryfunc)WraptObjectProxy_subtract, /*nb_subtract*/
|
1556
|
+
(binaryfunc)WraptObjectProxy_multiply, /*nb_multiply*/
|
1557
|
+
#if PY_MAJOR_VERSION < 3
|
1558
|
+
(binaryfunc)WraptObjectProxy_divide, /*nb_divide*/
|
1559
|
+
#endif
|
1560
|
+
(binaryfunc)WraptObjectProxy_remainder, /*nb_remainder*/
|
1561
|
+
(binaryfunc)WraptObjectProxy_divmod, /*nb_divmod*/
|
1562
|
+
(ternaryfunc)WraptObjectProxy_power, /*nb_power*/
|
1563
|
+
(unaryfunc)WraptObjectProxy_negative, /*nb_negative*/
|
1564
|
+
(unaryfunc)WraptObjectProxy_positive, /*nb_positive*/
|
1565
|
+
(unaryfunc)WraptObjectProxy_absolute, /*nb_absolute*/
|
1566
|
+
(inquiry)WraptObjectProxy_bool, /*nb_nonzero/nb_bool*/
|
1567
|
+
(unaryfunc)WraptObjectProxy_invert, /*nb_invert*/
|
1568
|
+
(binaryfunc)WraptObjectProxy_lshift, /*nb_lshift*/
|
1569
|
+
(binaryfunc)WraptObjectProxy_rshift, /*nb_rshift*/
|
1570
|
+
(binaryfunc)WraptObjectProxy_and, /*nb_and*/
|
1571
|
+
(binaryfunc)WraptObjectProxy_xor, /*nb_xor*/
|
1572
|
+
(binaryfunc)WraptObjectProxy_or, /*nb_or*/
|
1573
|
+
#if PY_MAJOR_VERSION < 3
|
1574
|
+
0, /*nb_coerce*/
|
1575
|
+
#endif
|
1576
|
+
#if PY_MAJOR_VERSION < 3
|
1577
|
+
(unaryfunc)WraptObjectProxy_int, /*nb_int*/
|
1578
|
+
(unaryfunc)WraptObjectProxy_long, /*nb_long*/
|
1579
|
+
#else
|
1580
|
+
(unaryfunc)WraptObjectProxy_long, /*nb_int*/
|
1581
|
+
0, /*nb_long/nb_reserved*/
|
1582
|
+
#endif
|
1583
|
+
(unaryfunc)WraptObjectProxy_float, /*nb_float*/
|
1584
|
+
#if PY_MAJOR_VERSION < 3
|
1585
|
+
(unaryfunc)WraptObjectProxy_oct, /*nb_oct*/
|
1586
|
+
(unaryfunc)WraptObjectProxy_hex, /*nb_hex*/
|
1587
|
+
#endif
|
1588
|
+
(binaryfunc)WraptObjectProxy_inplace_add, /*nb_inplace_add*/
|
1589
|
+
(binaryfunc)WraptObjectProxy_inplace_subtract, /*nb_inplace_subtract*/
|
1590
|
+
(binaryfunc)WraptObjectProxy_inplace_multiply, /*nb_inplace_multiply*/
|
1591
|
+
#if PY_MAJOR_VERSION < 3
|
1592
|
+
(binaryfunc)WraptObjectProxy_inplace_divide, /*nb_inplace_divide*/
|
1593
|
+
#endif
|
1594
|
+
(binaryfunc)WraptObjectProxy_inplace_remainder, /*nb_inplace_remainder*/
|
1595
|
+
(ternaryfunc)WraptObjectProxy_inplace_power, /*nb_inplace_power*/
|
1596
|
+
(binaryfunc)WraptObjectProxy_inplace_lshift, /*nb_inplace_lshift*/
|
1597
|
+
(binaryfunc)WraptObjectProxy_inplace_rshift, /*nb_inplace_rshift*/
|
1598
|
+
(binaryfunc)WraptObjectProxy_inplace_and, /*nb_inplace_and*/
|
1599
|
+
(binaryfunc)WraptObjectProxy_inplace_xor, /*nb_inplace_xor*/
|
1600
|
+
(binaryfunc)WraptObjectProxy_inplace_or, /*nb_inplace_or*/
|
1601
|
+
(binaryfunc)WraptObjectProxy_floor_divide, /*nb_floor_divide*/
|
1602
|
+
(binaryfunc)WraptObjectProxy_true_divide, /*nb_true_divide*/
|
1603
|
+
(binaryfunc)WraptObjectProxy_inplace_floor_divide, /*nb_inplace_floor_divide*/
|
1604
|
+
(binaryfunc)WraptObjectProxy_inplace_true_divide, /*nb_inplace_true_divide*/
|
1605
|
+
(unaryfunc)WraptObjectProxy_index, /*nb_index*/
|
1606
|
+
};
|
1607
|
+
|
1608
|
+
static PySequenceMethods WraptObjectProxy_as_sequence = {
|
1609
|
+
(lenfunc)WraptObjectProxy_length, /*sq_length*/
|
1610
|
+
0, /*sq_concat*/
|
1611
|
+
0, /*sq_repeat*/
|
1612
|
+
0, /*sq_item*/
|
1613
|
+
0, /*sq_slice*/
|
1614
|
+
0, /*sq_ass_item*/
|
1615
|
+
0, /*sq_ass_slice*/
|
1616
|
+
(objobjproc)WraptObjectProxy_contains, /* sq_contains */
|
1617
|
+
};
|
1618
|
+
|
1619
|
+
static PyMappingMethods WraptObjectProxy_as_mapping = {
|
1620
|
+
(lenfunc)WraptObjectProxy_length, /*mp_length*/
|
1621
|
+
(binaryfunc)WraptObjectProxy_getitem, /*mp_subscript*/
|
1622
|
+
(objobjargproc)WraptObjectProxy_setitem, /*mp_ass_subscript*/
|
1623
|
+
};
|
1624
|
+
|
1625
|
+
static PyMethodDef WraptObjectProxy_methods[] = {
|
1626
|
+
{ "__dir__", (PyCFunction)WraptObjectProxy_dir, METH_NOARGS, 0 },
|
1627
|
+
{ "__enter__", (PyCFunction)WraptObjectProxy_enter,
|
1628
|
+
METH_VARARGS | METH_KEYWORDS, 0 },
|
1629
|
+
{ "__exit__", (PyCFunction)WraptObjectProxy_exit,
|
1630
|
+
METH_VARARGS | METH_KEYWORDS, 0 },
|
1631
|
+
{ "__getattr__", (PyCFunction)WraptObjectProxy_getattr,
|
1632
|
+
METH_VARARGS , 0 },
|
1633
|
+
{ "__bytes__", (PyCFunction)WraptObjectProxy_bytes, METH_NOARGS, 0 },
|
1634
|
+
{ "__reversed__", (PyCFunction)WraptObjectProxy_reversed, METH_NOARGS, 0 },
|
1635
|
+
#if PY_MAJOR_VERSION >= 3
|
1636
|
+
{ "__round__", (PyCFunction)WraptObjectProxy_round, METH_NOARGS, 0 },
|
1637
|
+
#endif
|
1638
|
+
{ NULL, NULL },
|
1639
|
+
};
|
1640
|
+
|
1641
|
+
static PyGetSetDef WraptObjectProxy_getset[] = {
|
1642
|
+
{ "__name__", (getter)WraptObjectProxy_get_name,
|
1643
|
+
(setter)WraptObjectProxy_set_name, 0 },
|
1644
|
+
{ "__qualname__", (getter)WraptObjectProxy_get_qualname,
|
1645
|
+
(setter)WraptObjectProxy_set_qualname, 0 },
|
1646
|
+
{ "__module__", (getter)WraptObjectProxy_get_module,
|
1647
|
+
(setter)WraptObjectProxy_set_module, 0 },
|
1648
|
+
{ "__doc__", (getter)WraptObjectProxy_get_doc,
|
1649
|
+
(setter)WraptObjectProxy_set_doc, 0 },
|
1650
|
+
{ "__class__", (getter)WraptObjectProxy_get_class,
|
1651
|
+
NULL, 0 },
|
1652
|
+
{ "__annotations__", (getter)WraptObjectProxy_get_annotations,
|
1653
|
+
(setter)WraptObjectProxy_set_annotations, 0 },
|
1654
|
+
{ "__wrapped__", (getter)WraptObjectProxy_get_wrapped,
|
1655
|
+
(setter)WraptObjectProxy_set_wrapped, 0 },
|
1656
|
+
{ NULL },
|
1657
|
+
};
|
1658
|
+
|
1659
|
+
PyTypeObject WraptObjectProxy_Type = {
|
1660
|
+
PyVarObject_HEAD_INIT(NULL, 0)
|
1661
|
+
"ObjectProxy", /*tp_name*/
|
1662
|
+
sizeof(WraptObjectProxyObject), /*tp_basicsize*/
|
1663
|
+
0, /*tp_itemsize*/
|
1664
|
+
/* methods */
|
1665
|
+
(destructor)WraptObjectProxy_dealloc, /*tp_dealloc*/
|
1666
|
+
0, /*tp_print*/
|
1667
|
+
0, /*tp_getattr*/
|
1668
|
+
0, /*tp_setattr*/
|
1669
|
+
0, /*tp_compare*/
|
1670
|
+
(unaryfunc)WraptObjectProxy_repr, /*tp_repr*/
|
1671
|
+
&WraptObjectProxy_as_number, /*tp_as_number*/
|
1672
|
+
&WraptObjectProxy_as_sequence, /*tp_as_sequence*/
|
1673
|
+
&WraptObjectProxy_as_mapping, /*tp_as_mapping*/
|
1674
|
+
(hashfunc)WraptObjectProxy_hash, /*tp_hash*/
|
1675
|
+
0, /*tp_call*/
|
1676
|
+
(unaryfunc)WraptObjectProxy_str, /*tp_str*/
|
1677
|
+
(getattrofunc)WraptObjectProxy_getattro, /*tp_getattro*/
|
1678
|
+
(setattrofunc)WraptObjectProxy_setattro, /*tp_setattro*/
|
1679
|
+
0, /*tp_as_buffer*/
|
1680
|
+
#if PY_MAJOR_VERSION < 3
|
1681
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
|
1682
|
+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
|
1683
|
+
#else
|
1684
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
|
1685
|
+
Py_TPFLAGS_HAVE_GC, /*tp_flags*/
|
1686
|
+
#endif
|
1687
|
+
0, /*tp_doc*/
|
1688
|
+
(traverseproc)WraptObjectProxy_traverse, /*tp_traverse*/
|
1689
|
+
(inquiry)WraptObjectProxy_clear, /*tp_clear*/
|
1690
|
+
(richcmpfunc)WraptObjectProxy_richcompare, /*tp_richcompare*/
|
1691
|
+
offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
|
1692
|
+
(getiterfunc)WraptObjectProxy_iter, /*tp_iter*/
|
1693
|
+
0, /*tp_iternext*/
|
1694
|
+
WraptObjectProxy_methods, /*tp_methods*/
|
1695
|
+
0, /*tp_members*/
|
1696
|
+
WraptObjectProxy_getset, /*tp_getset*/
|
1697
|
+
0, /*tp_base*/
|
1698
|
+
0, /*tp_dict*/
|
1699
|
+
0, /*tp_descr_get*/
|
1700
|
+
0, /*tp_descr_set*/
|
1701
|
+
offsetof(WraptObjectProxyObject, dict), /*tp_dictoffset*/
|
1702
|
+
(initproc)WraptObjectProxy_init, /*tp_init*/
|
1703
|
+
PyType_GenericAlloc, /*tp_alloc*/
|
1704
|
+
WraptObjectProxy_new, /*tp_new*/
|
1705
|
+
PyObject_GC_Del, /*tp_free*/
|
1706
|
+
0, /*tp_is_gc*/
|
1707
|
+
};
|
1708
|
+
|
1709
|
+
/* ------------------------------------------------------------------------- */
|
1710
|
+
|
1711
|
+
static PyObject *WraptCallableObjectProxy_call(
|
1712
|
+
WraptObjectProxyObject *self, PyObject *args, PyObject *kwds)
|
1713
|
+
{
|
1714
|
+
if (!self->wrapped) {
|
1715
|
+
PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
|
1716
|
+
return NULL;
|
1717
|
+
}
|
1718
|
+
|
1719
|
+
return PyObject_Call(self->wrapped, args, kwds);
|
1720
|
+
}
|
1721
|
+
|
1722
|
+
/* ------------------------------------------------------------------------- */;
|
1723
|
+
|
1724
|
+
static PyGetSetDef WraptCallableObjectProxy_getset[] = {
|
1725
|
+
{ "__module__", (getter)WraptObjectProxy_get_module,
|
1726
|
+
(setter)WraptObjectProxy_set_module, 0 },
|
1727
|
+
{ "__doc__", (getter)WraptObjectProxy_get_doc,
|
1728
|
+
(setter)WraptObjectProxy_set_doc, 0 },
|
1729
|
+
{ NULL },
|
1730
|
+
};
|
1731
|
+
|
1732
|
+
PyTypeObject WraptCallableObjectProxy_Type = {
|
1733
|
+
PyVarObject_HEAD_INIT(NULL, 0)
|
1734
|
+
"CallableObjectProxy", /*tp_name*/
|
1735
|
+
sizeof(WraptObjectProxyObject), /*tp_basicsize*/
|
1736
|
+
0, /*tp_itemsize*/
|
1737
|
+
/* methods */
|
1738
|
+
0, /*tp_dealloc*/
|
1739
|
+
0, /*tp_print*/
|
1740
|
+
0, /*tp_getattr*/
|
1741
|
+
0, /*tp_setattr*/
|
1742
|
+
0, /*tp_compare*/
|
1743
|
+
0, /*tp_repr*/
|
1744
|
+
0, /*tp_as_number*/
|
1745
|
+
0, /*tp_as_sequence*/
|
1746
|
+
0, /*tp_as_mapping*/
|
1747
|
+
0, /*tp_hash*/
|
1748
|
+
(ternaryfunc)WraptCallableObjectProxy_call, /*tp_call*/
|
1749
|
+
0, /*tp_str*/
|
1750
|
+
0, /*tp_getattro*/
|
1751
|
+
0, /*tp_setattro*/
|
1752
|
+
0, /*tp_as_buffer*/
|
1753
|
+
#if PY_MAJOR_VERSION < 3
|
1754
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
|
1755
|
+
#else
|
1756
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
1757
|
+
#endif
|
1758
|
+
0, /*tp_doc*/
|
1759
|
+
0, /*tp_traverse*/
|
1760
|
+
0, /*tp_clear*/
|
1761
|
+
0, /*tp_richcompare*/
|
1762
|
+
offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
|
1763
|
+
0, /*tp_iter*/
|
1764
|
+
0, /*tp_iternext*/
|
1765
|
+
0, /*tp_methods*/
|
1766
|
+
0, /*tp_members*/
|
1767
|
+
WraptCallableObjectProxy_getset, /*tp_getset*/
|
1768
|
+
0, /*tp_base*/
|
1769
|
+
0, /*tp_dict*/
|
1770
|
+
0, /*tp_descr_get*/
|
1771
|
+
0, /*tp_descr_set*/
|
1772
|
+
0, /*tp_dictoffset*/
|
1773
|
+
(initproc)WraptObjectProxy_init, /*tp_init*/
|
1774
|
+
0, /*tp_alloc*/
|
1775
|
+
0, /*tp_new*/
|
1776
|
+
0, /*tp_free*/
|
1777
|
+
0, /*tp_is_gc*/
|
1778
|
+
};
|
1779
|
+
|
1780
|
+
/* ------------------------------------------------------------------------- */
|
1781
|
+
|
1782
|
+
static PyObject *WraptFunctionWrapperBase_new(PyTypeObject *type,
|
1783
|
+
PyObject *args, PyObject *kwds)
|
1784
|
+
{
|
1785
|
+
WraptFunctionWrapperObject *self;
|
1786
|
+
|
1787
|
+
self = (WraptFunctionWrapperObject *)WraptObjectProxy_new(type,
|
1788
|
+
args, kwds);
|
1789
|
+
|
1790
|
+
if (!self)
|
1791
|
+
return NULL;
|
1792
|
+
|
1793
|
+
self->instance = NULL;
|
1794
|
+
self->wrapper = NULL;
|
1795
|
+
self->enabled = NULL;
|
1796
|
+
self->binding = NULL;
|
1797
|
+
self->parent = NULL;
|
1798
|
+
|
1799
|
+
return (PyObject *)self;
|
1800
|
+
}
|
1801
|
+
|
1802
|
+
/* ------------------------------------------------------------------------- */
|
1803
|
+
|
1804
|
+
static int WraptFunctionWrapperBase_raw_init(WraptFunctionWrapperObject *self,
|
1805
|
+
PyObject *wrapped, PyObject *instance, PyObject *wrapper,
|
1806
|
+
PyObject *enabled, PyObject *binding, PyObject *parent)
|
1807
|
+
{
|
1808
|
+
int result = 0;
|
1809
|
+
|
1810
|
+
result = WraptObjectProxy_raw_init((WraptObjectProxyObject *)self,
|
1811
|
+
wrapped);
|
1812
|
+
|
1813
|
+
if (result == 0) {
|
1814
|
+
Py_INCREF(instance);
|
1815
|
+
Py_XDECREF(self->instance);
|
1816
|
+
self->instance = instance;
|
1817
|
+
|
1818
|
+
Py_INCREF(wrapper);
|
1819
|
+
Py_XDECREF(self->wrapper);
|
1820
|
+
self->wrapper = wrapper;
|
1821
|
+
|
1822
|
+
Py_INCREF(enabled);
|
1823
|
+
Py_XDECREF(self->enabled);
|
1824
|
+
self->enabled = enabled;
|
1825
|
+
|
1826
|
+
Py_INCREF(binding);
|
1827
|
+
Py_XDECREF(self->binding);
|
1828
|
+
self->binding = binding;
|
1829
|
+
|
1830
|
+
Py_INCREF(parent);
|
1831
|
+
Py_XDECREF(self->parent);
|
1832
|
+
self->parent = parent;
|
1833
|
+
}
|
1834
|
+
|
1835
|
+
return result;
|
1836
|
+
}
|
1837
|
+
|
1838
|
+
/* ------------------------------------------------------------------------- */
|
1839
|
+
|
1840
|
+
static int WraptFunctionWrapperBase_init(WraptFunctionWrapperObject *self,
|
1841
|
+
PyObject *args, PyObject *kwds)
|
1842
|
+
{
|
1843
|
+
PyObject *wrapped = NULL;
|
1844
|
+
PyObject *instance = NULL;
|
1845
|
+
PyObject *wrapper = NULL;
|
1846
|
+
PyObject *enabled = Py_None;
|
1847
|
+
PyObject *binding = NULL;
|
1848
|
+
PyObject *parent = Py_None;
|
1849
|
+
|
1850
|
+
static PyObject *function_str = NULL;
|
1851
|
+
|
1852
|
+
static char *kwlist[] = { "wrapped", "instance", "wrapper",
|
1853
|
+
"enabled", "binding", "parent", NULL };
|
1854
|
+
|
1855
|
+
if (!function_str) {
|
1856
|
+
#if PY_MAJOR_VERSION >= 3
|
1857
|
+
function_str = PyUnicode_InternFromString("function");
|
1858
|
+
#else
|
1859
|
+
function_str = PyString_InternFromString("function");
|
1860
|
+
#endif
|
1861
|
+
}
|
1862
|
+
|
1863
|
+
if (!PyArg_ParseTupleAndKeywords(args, kwds,
|
1864
|
+
"OOO|OOO:FunctionWrapperBase", kwlist, &wrapped, &instance,
|
1865
|
+
&wrapper, &enabled, &binding, &parent)) {
|
1866
|
+
return -1;
|
1867
|
+
}
|
1868
|
+
|
1869
|
+
if (!binding)
|
1870
|
+
binding = function_str;
|
1871
|
+
|
1872
|
+
return WraptFunctionWrapperBase_raw_init(self, wrapped, instance, wrapper,
|
1873
|
+
enabled, binding, parent);
|
1874
|
+
}
|
1875
|
+
|
1876
|
+
/* ------------------------------------------------------------------------- */
|
1877
|
+
|
1878
|
+
static int WraptFunctionWrapperBase_traverse(WraptFunctionWrapperObject *self,
|
1879
|
+
visitproc visit, void *arg)
|
1880
|
+
{
|
1881
|
+
WraptObjectProxy_traverse((WraptObjectProxyObject *)self, visit, arg);
|
1882
|
+
|
1883
|
+
Py_VISIT(self->instance);
|
1884
|
+
Py_VISIT(self->wrapper);
|
1885
|
+
Py_VISIT(self->enabled);
|
1886
|
+
Py_VISIT(self->binding);
|
1887
|
+
Py_VISIT(self->parent);
|
1888
|
+
|
1889
|
+
return 0;
|
1890
|
+
}
|
1891
|
+
|
1892
|
+
/* ------------------------------------------------------------------------- */
|
1893
|
+
|
1894
|
+
static int WraptFunctionWrapperBase_clear(WraptFunctionWrapperObject *self)
|
1895
|
+
{
|
1896
|
+
WraptObjectProxy_clear((WraptObjectProxyObject *)self);
|
1897
|
+
|
1898
|
+
Py_CLEAR(self->instance);
|
1899
|
+
Py_CLEAR(self->wrapper);
|
1900
|
+
Py_CLEAR(self->enabled);
|
1901
|
+
Py_CLEAR(self->binding);
|
1902
|
+
Py_CLEAR(self->parent);
|
1903
|
+
|
1904
|
+
return 0;
|
1905
|
+
}
|
1906
|
+
|
1907
|
+
/* ------------------------------------------------------------------------- */
|
1908
|
+
|
1909
|
+
static void WraptFunctionWrapperBase_dealloc(WraptFunctionWrapperObject *self)
|
1910
|
+
{
|
1911
|
+
WraptFunctionWrapperBase_clear(self);
|
1912
|
+
|
1913
|
+
WraptObjectProxy_dealloc((WraptObjectProxyObject *)self);
|
1914
|
+
}
|
1915
|
+
|
1916
|
+
/* ------------------------------------------------------------------------- */
|
1917
|
+
|
1918
|
+
static PyObject *WraptFunctionWrapperBase_call(
|
1919
|
+
WraptFunctionWrapperObject *self, PyObject *args, PyObject *kwds)
|
1920
|
+
{
|
1921
|
+
PyObject *param_kwds = NULL;
|
1922
|
+
|
1923
|
+
PyObject *result = NULL;
|
1924
|
+
|
1925
|
+
static PyObject *function_str = NULL;
|
1926
|
+
|
1927
|
+
if (!function_str) {
|
1928
|
+
#if PY_MAJOR_VERSION >= 3
|
1929
|
+
function_str = PyUnicode_InternFromString("function");
|
1930
|
+
#else
|
1931
|
+
function_str = PyString_InternFromString("function");
|
1932
|
+
#endif
|
1933
|
+
}
|
1934
|
+
|
1935
|
+
if (self->enabled != Py_None) {
|
1936
|
+
if (PyCallable_Check(self->enabled)) {
|
1937
|
+
PyObject *object = NULL;
|
1938
|
+
|
1939
|
+
object = PyObject_CallFunctionObjArgs(self->enabled, NULL);
|
1940
|
+
|
1941
|
+
if (!object)
|
1942
|
+
return NULL;
|
1943
|
+
|
1944
|
+
if (PyObject_Not(object)) {
|
1945
|
+
Py_DECREF(object);
|
1946
|
+
return PyObject_Call(self->object_proxy.wrapped, args, kwds);
|
1947
|
+
}
|
1948
|
+
|
1949
|
+
Py_DECREF(object);
|
1950
|
+
}
|
1951
|
+
else if (PyObject_Not(self->enabled)) {
|
1952
|
+
return PyObject_Call(self->object_proxy.wrapped, args, kwds);
|
1953
|
+
}
|
1954
|
+
}
|
1955
|
+
|
1956
|
+
if (!kwds) {
|
1957
|
+
param_kwds = PyDict_New();
|
1958
|
+
kwds = param_kwds;
|
1959
|
+
}
|
1960
|
+
|
1961
|
+
if (self->instance == Py_None && (self->binding == function_str ||
|
1962
|
+
PyObject_RichCompareBool(self->binding, function_str,
|
1963
|
+
Py_EQ) == 1)) {
|
1964
|
+
|
1965
|
+
PyObject *instance = NULL;
|
1966
|
+
|
1967
|
+
instance = PyObject_GetAttrString(self->object_proxy.wrapped,
|
1968
|
+
"__self__");
|
1969
|
+
|
1970
|
+
if (instance) {
|
1971
|
+
result = PyObject_CallFunctionObjArgs(self->wrapper,
|
1972
|
+
self->object_proxy.wrapped, instance, args, kwds, NULL);
|
1973
|
+
|
1974
|
+
Py_XDECREF(param_kwds);
|
1975
|
+
|
1976
|
+
Py_DECREF(instance);
|
1977
|
+
|
1978
|
+
return result;
|
1979
|
+
}
|
1980
|
+
else
|
1981
|
+
PyErr_Clear();
|
1982
|
+
}
|
1983
|
+
|
1984
|
+
result = PyObject_CallFunctionObjArgs(self->wrapper,
|
1985
|
+
self->object_proxy.wrapped, self->instance, args, kwds, NULL);
|
1986
|
+
|
1987
|
+
Py_XDECREF(param_kwds);
|
1988
|
+
|
1989
|
+
return result;
|
1990
|
+
}
|
1991
|
+
|
1992
|
+
/* ------------------------------------------------------------------------- */
|
1993
|
+
|
1994
|
+
static PyObject *WraptFunctionWrapperBase_descr_get(
|
1995
|
+
WraptFunctionWrapperObject *self, PyObject *obj, PyObject *type)
|
1996
|
+
{
|
1997
|
+
PyObject *bound_type = NULL;
|
1998
|
+
PyObject *descriptor = NULL;
|
1999
|
+
PyObject *result = NULL;
|
2000
|
+
|
2001
|
+
static PyObject *bound_type_str = NULL;
|
2002
|
+
static PyObject *function_str = NULL;
|
2003
|
+
|
2004
|
+
if (!bound_type_str) {
|
2005
|
+
#if PY_MAJOR_VERSION >= 3
|
2006
|
+
bound_type_str = PyUnicode_InternFromString(
|
2007
|
+
"__bound_function_wrapper__");
|
2008
|
+
#else
|
2009
|
+
bound_type_str = PyString_InternFromString(
|
2010
|
+
"__bound_function_wrapper__");
|
2011
|
+
#endif
|
2012
|
+
}
|
2013
|
+
|
2014
|
+
if (!function_str) {
|
2015
|
+
#if PY_MAJOR_VERSION >= 3
|
2016
|
+
function_str = PyUnicode_InternFromString("function");
|
2017
|
+
#else
|
2018
|
+
function_str = PyString_InternFromString("function");
|
2019
|
+
#endif
|
2020
|
+
}
|
2021
|
+
|
2022
|
+
if (self->parent == Py_None) {
|
2023
|
+
#if PY_MAJOR_VERSION < 3
|
2024
|
+
if (PyObject_IsInstance(self->object_proxy.wrapped,
|
2025
|
+
(PyObject *)&PyClass_Type) || PyObject_IsInstance(
|
2026
|
+
self->object_proxy.wrapped, (PyObject *)&PyType_Type)) {
|
2027
|
+
Py_INCREF(self);
|
2028
|
+
return (PyObject *)self;
|
2029
|
+
}
|
2030
|
+
#else
|
2031
|
+
if (PyObject_IsInstance(self->object_proxy.wrapped,
|
2032
|
+
(PyObject *)&PyType_Type)) {
|
2033
|
+
Py_INCREF(self);
|
2034
|
+
return (PyObject *)self;
|
2035
|
+
}
|
2036
|
+
#endif
|
2037
|
+
|
2038
|
+
if (Py_TYPE(self->object_proxy.wrapped)->tp_descr_get == NULL) {
|
2039
|
+
PyErr_Format(PyExc_AttributeError,
|
2040
|
+
"'%s' object has no attribute '__get__'",
|
2041
|
+
Py_TYPE(self->object_proxy.wrapped)->tp_name);
|
2042
|
+
return NULL;
|
2043
|
+
}
|
2044
|
+
|
2045
|
+
descriptor = (Py_TYPE(self->object_proxy.wrapped)->tp_descr_get)(
|
2046
|
+
self->object_proxy.wrapped, obj, type);
|
2047
|
+
|
2048
|
+
if (!descriptor)
|
2049
|
+
return NULL;
|
2050
|
+
|
2051
|
+
if (Py_TYPE(self) != &WraptFunctionWrapper_Type) {
|
2052
|
+
bound_type = PyObject_GenericGetAttr((PyObject *)self,
|
2053
|
+
bound_type_str);
|
2054
|
+
|
2055
|
+
if (!bound_type)
|
2056
|
+
PyErr_Clear();
|
2057
|
+
}
|
2058
|
+
|
2059
|
+
if (obj == NULL)
|
2060
|
+
obj = Py_None;
|
2061
|
+
|
2062
|
+
result = PyObject_CallFunctionObjArgs(bound_type ? bound_type :
|
2063
|
+
(PyObject *)&WraptBoundFunctionWrapper_Type, descriptor,
|
2064
|
+
obj, self->wrapper, self->enabled, self->binding,
|
2065
|
+
self, NULL);
|
2066
|
+
|
2067
|
+
Py_XDECREF(bound_type);
|
2068
|
+
Py_DECREF(descriptor);
|
2069
|
+
|
2070
|
+
return result;
|
2071
|
+
}
|
2072
|
+
|
2073
|
+
if (self->instance == Py_None && (self->binding == function_str ||
|
2074
|
+
PyObject_RichCompareBool(self->binding, function_str,
|
2075
|
+
Py_EQ) == 1)) {
|
2076
|
+
|
2077
|
+
PyObject *wrapped = NULL;
|
2078
|
+
|
2079
|
+
static PyObject *wrapped_str = NULL;
|
2080
|
+
|
2081
|
+
if (!wrapped_str) {
|
2082
|
+
#if PY_MAJOR_VERSION >= 3
|
2083
|
+
wrapped_str = PyUnicode_InternFromString("__wrapped__");
|
2084
|
+
#else
|
2085
|
+
wrapped_str = PyString_InternFromString("__wrapped__");
|
2086
|
+
#endif
|
2087
|
+
}
|
2088
|
+
|
2089
|
+
wrapped = PyObject_GetAttr(self->parent, wrapped_str);
|
2090
|
+
|
2091
|
+
if (!wrapped)
|
2092
|
+
return NULL;
|
2093
|
+
|
2094
|
+
if (Py_TYPE(wrapped)->tp_descr_get == NULL) {
|
2095
|
+
PyErr_Format(PyExc_AttributeError,
|
2096
|
+
"'%s' object has no attribute '__get__'",
|
2097
|
+
Py_TYPE(wrapped)->tp_name);
|
2098
|
+
Py_DECREF(wrapped);
|
2099
|
+
return NULL;
|
2100
|
+
}
|
2101
|
+
|
2102
|
+
descriptor = (Py_TYPE(wrapped)->tp_descr_get)(wrapped, obj, type);
|
2103
|
+
|
2104
|
+
Py_DECREF(wrapped);
|
2105
|
+
|
2106
|
+
if (!descriptor)
|
2107
|
+
return NULL;
|
2108
|
+
|
2109
|
+
if (Py_TYPE(self->parent) != &WraptFunctionWrapper_Type) {
|
2110
|
+
bound_type = PyObject_GenericGetAttr((PyObject *)self->parent,
|
2111
|
+
bound_type_str);
|
2112
|
+
|
2113
|
+
if (!bound_type)
|
2114
|
+
PyErr_Clear();
|
2115
|
+
}
|
2116
|
+
|
2117
|
+
if (obj == NULL)
|
2118
|
+
obj = Py_None;
|
2119
|
+
|
2120
|
+
result = PyObject_CallFunctionObjArgs(bound_type ? bound_type :
|
2121
|
+
(PyObject *)&WraptBoundFunctionWrapper_Type, descriptor,
|
2122
|
+
obj, self->wrapper, self->enabled, self->binding,
|
2123
|
+
self->parent, NULL);
|
2124
|
+
|
2125
|
+
Py_XDECREF(bound_type);
|
2126
|
+
Py_DECREF(descriptor);
|
2127
|
+
|
2128
|
+
return result;
|
2129
|
+
}
|
2130
|
+
|
2131
|
+
Py_INCREF(self);
|
2132
|
+
return (PyObject *)self;
|
2133
|
+
}
|
2134
|
+
|
2135
|
+
/* ------------------------------------------------------------------------- */
|
2136
|
+
|
2137
|
+
static PyObject *WraptFunctionWrapperBase_get_self_instance(
|
2138
|
+
WraptFunctionWrapperObject *self, void *closure)
|
2139
|
+
{
|
2140
|
+
if (!self->instance) {
|
2141
|
+
Py_INCREF(Py_None);
|
2142
|
+
return Py_None;
|
2143
|
+
}
|
2144
|
+
|
2145
|
+
Py_INCREF(self->instance);
|
2146
|
+
return self->instance;
|
2147
|
+
}
|
2148
|
+
|
2149
|
+
/* ------------------------------------------------------------------------- */
|
2150
|
+
|
2151
|
+
static PyObject *WraptFunctionWrapperBase_get_self_wrapper(
|
2152
|
+
WraptFunctionWrapperObject *self, void *closure)
|
2153
|
+
{
|
2154
|
+
if (!self->wrapper) {
|
2155
|
+
Py_INCREF(Py_None);
|
2156
|
+
return Py_None;
|
2157
|
+
}
|
2158
|
+
|
2159
|
+
Py_INCREF(self->wrapper);
|
2160
|
+
return self->wrapper;
|
2161
|
+
}
|
2162
|
+
|
2163
|
+
/* ------------------------------------------------------------------------- */
|
2164
|
+
|
2165
|
+
static PyObject *WraptFunctionWrapperBase_get_self_enabled(
|
2166
|
+
WraptFunctionWrapperObject *self, void *closure)
|
2167
|
+
{
|
2168
|
+
if (!self->enabled) {
|
2169
|
+
Py_INCREF(Py_None);
|
2170
|
+
return Py_None;
|
2171
|
+
}
|
2172
|
+
|
2173
|
+
Py_INCREF(self->enabled);
|
2174
|
+
return self->enabled;
|
2175
|
+
}
|
2176
|
+
|
2177
|
+
/* ------------------------------------------------------------------------- */
|
2178
|
+
|
2179
|
+
static PyObject *WraptFunctionWrapperBase_get_self_binding(
|
2180
|
+
WraptFunctionWrapperObject *self, void *closure)
|
2181
|
+
{
|
2182
|
+
if (!self->binding) {
|
2183
|
+
Py_INCREF(Py_None);
|
2184
|
+
return Py_None;
|
2185
|
+
}
|
2186
|
+
|
2187
|
+
Py_INCREF(self->binding);
|
2188
|
+
return self->binding;
|
2189
|
+
}
|
2190
|
+
|
2191
|
+
/* ------------------------------------------------------------------------- */
|
2192
|
+
|
2193
|
+
static PyObject *WraptFunctionWrapperBase_get_self_parent(
|
2194
|
+
WraptFunctionWrapperObject *self, void *closure)
|
2195
|
+
{
|
2196
|
+
if (!self->parent) {
|
2197
|
+
Py_INCREF(Py_None);
|
2198
|
+
return Py_None;
|
2199
|
+
}
|
2200
|
+
|
2201
|
+
Py_INCREF(self->parent);
|
2202
|
+
return self->parent;
|
2203
|
+
}
|
2204
|
+
|
2205
|
+
/* ------------------------------------------------------------------------- */;
|
2206
|
+
|
2207
|
+
static PyGetSetDef WraptFunctionWrapperBase_getset[] = {
|
2208
|
+
{ "__module__", (getter)WraptObjectProxy_get_module,
|
2209
|
+
(setter)WraptObjectProxy_set_module, 0 },
|
2210
|
+
{ "__doc__", (getter)WraptObjectProxy_get_doc,
|
2211
|
+
(setter)WraptObjectProxy_set_doc, 0 },
|
2212
|
+
{ "_self_instance", (getter)WraptFunctionWrapperBase_get_self_instance,
|
2213
|
+
NULL, 0 },
|
2214
|
+
{ "_self_wrapper", (getter)WraptFunctionWrapperBase_get_self_wrapper,
|
2215
|
+
NULL, 0 },
|
2216
|
+
{ "_self_enabled", (getter)WraptFunctionWrapperBase_get_self_enabled,
|
2217
|
+
NULL, 0 },
|
2218
|
+
{ "_self_binding", (getter)WraptFunctionWrapperBase_get_self_binding,
|
2219
|
+
NULL, 0 },
|
2220
|
+
{ "_self_parent", (getter)WraptFunctionWrapperBase_get_self_parent,
|
2221
|
+
NULL, 0 },
|
2222
|
+
{ NULL },
|
2223
|
+
};
|
2224
|
+
|
2225
|
+
PyTypeObject WraptFunctionWrapperBase_Type = {
|
2226
|
+
PyVarObject_HEAD_INIT(NULL, 0)
|
2227
|
+
"_FunctionWrapperBase", /*tp_name*/
|
2228
|
+
sizeof(WraptFunctionWrapperObject), /*tp_basicsize*/
|
2229
|
+
0, /*tp_itemsize*/
|
2230
|
+
/* methods */
|
2231
|
+
(destructor)WraptFunctionWrapperBase_dealloc, /*tp_dealloc*/
|
2232
|
+
0, /*tp_print*/
|
2233
|
+
0, /*tp_getattr*/
|
2234
|
+
0, /*tp_setattr*/
|
2235
|
+
0, /*tp_compare*/
|
2236
|
+
0, /*tp_repr*/
|
2237
|
+
0, /*tp_as_number*/
|
2238
|
+
0, /*tp_as_sequence*/
|
2239
|
+
0, /*tp_as_mapping*/
|
2240
|
+
0, /*tp_hash*/
|
2241
|
+
(ternaryfunc)WraptFunctionWrapperBase_call, /*tp_call*/
|
2242
|
+
0, /*tp_str*/
|
2243
|
+
0, /*tp_getattro*/
|
2244
|
+
0, /*tp_setattro*/
|
2245
|
+
0, /*tp_as_buffer*/
|
2246
|
+
#if PY_MAJOR_VERSION < 3
|
2247
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
|
2248
|
+
Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
|
2249
|
+
#else
|
2250
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE |
|
2251
|
+
Py_TPFLAGS_HAVE_GC, /*tp_flags*/
|
2252
|
+
#endif
|
2253
|
+
0, /*tp_doc*/
|
2254
|
+
(traverseproc)WraptFunctionWrapperBase_traverse, /*tp_traverse*/
|
2255
|
+
(inquiry)WraptFunctionWrapperBase_clear, /*tp_clear*/
|
2256
|
+
0, /*tp_richcompare*/
|
2257
|
+
offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
|
2258
|
+
0, /*tp_iter*/
|
2259
|
+
0, /*tp_iternext*/
|
2260
|
+
0, /*tp_methods*/
|
2261
|
+
0, /*tp_members*/
|
2262
|
+
WraptFunctionWrapperBase_getset, /*tp_getset*/
|
2263
|
+
0, /*tp_base*/
|
2264
|
+
0, /*tp_dict*/
|
2265
|
+
(descrgetfunc)WraptFunctionWrapperBase_descr_get, /*tp_descr_get*/
|
2266
|
+
0, /*tp_descr_set*/
|
2267
|
+
0, /*tp_dictoffset*/
|
2268
|
+
(initproc)WraptFunctionWrapperBase_init, /*tp_init*/
|
2269
|
+
0, /*tp_alloc*/
|
2270
|
+
WraptFunctionWrapperBase_new, /*tp_new*/
|
2271
|
+
0, /*tp_free*/
|
2272
|
+
0, /*tp_is_gc*/
|
2273
|
+
};
|
2274
|
+
|
2275
|
+
/* ------------------------------------------------------------------------- */
|
2276
|
+
|
2277
|
+
static PyObject *WraptBoundFunctionWrapper_call(
|
2278
|
+
WraptFunctionWrapperObject *self, PyObject *args, PyObject *kwds)
|
2279
|
+
{
|
2280
|
+
PyObject *param_args = NULL;
|
2281
|
+
PyObject *param_kwds = NULL;
|
2282
|
+
|
2283
|
+
PyObject *wrapped = NULL;
|
2284
|
+
PyObject *instance = NULL;
|
2285
|
+
|
2286
|
+
PyObject *result = NULL;
|
2287
|
+
|
2288
|
+
static PyObject *function_str = NULL;
|
2289
|
+
|
2290
|
+
if (self->enabled != Py_None) {
|
2291
|
+
if (PyCallable_Check(self->enabled)) {
|
2292
|
+
PyObject *object = NULL;
|
2293
|
+
|
2294
|
+
object = PyObject_CallFunctionObjArgs(self->enabled, NULL);
|
2295
|
+
|
2296
|
+
if (!object)
|
2297
|
+
return NULL;
|
2298
|
+
|
2299
|
+
if (PyObject_Not(object)) {
|
2300
|
+
Py_DECREF(object);
|
2301
|
+
return PyObject_Call(self->object_proxy.wrapped, args, kwds);
|
2302
|
+
}
|
2303
|
+
|
2304
|
+
Py_DECREF(object);
|
2305
|
+
}
|
2306
|
+
else if (PyObject_Not(self->enabled)) {
|
2307
|
+
return PyObject_Call(self->object_proxy.wrapped, args, kwds);
|
2308
|
+
}
|
2309
|
+
}
|
2310
|
+
|
2311
|
+
if (!function_str) {
|
2312
|
+
#if PY_MAJOR_VERSION >= 3
|
2313
|
+
function_str = PyUnicode_InternFromString("function");
|
2314
|
+
#else
|
2315
|
+
function_str = PyString_InternFromString("function");
|
2316
|
+
#endif
|
2317
|
+
}
|
2318
|
+
|
2319
|
+
/*
|
2320
|
+
* We need to do things different depending on whether we are likely
|
2321
|
+
* wrapping an instance method vs a static method or class method.
|
2322
|
+
*/
|
2323
|
+
|
2324
|
+
if (self->binding == function_str || PyObject_RichCompareBool(
|
2325
|
+
self->binding, function_str, Py_EQ) == 1) {
|
2326
|
+
|
2327
|
+
if (self->instance == Py_None) {
|
2328
|
+
/*
|
2329
|
+
* This situation can occur where someone is calling the
|
2330
|
+
* instancemethod via the class type and passing the
|
2331
|
+
* instance as the first argument. We need to shift the args
|
2332
|
+
* before making the call to the wrapper and effectively
|
2333
|
+
* bind the instance to the wrapped function using a partial
|
2334
|
+
* so the wrapper doesn't see anything as being different.
|
2335
|
+
*/
|
2336
|
+
|
2337
|
+
PyObject *module = NULL;
|
2338
|
+
PyObject *dict = NULL;
|
2339
|
+
PyObject *partial = NULL;
|
2340
|
+
|
2341
|
+
if (PyTuple_Size(args) == 0) {
|
2342
|
+
PyErr_SetString(PyExc_TypeError,
|
2343
|
+
"missing 1 required positional argument");
|
2344
|
+
return NULL;
|
2345
|
+
}
|
2346
|
+
|
2347
|
+
module = PyImport_ImportModule("functools");
|
2348
|
+
|
2349
|
+
if (!module)
|
2350
|
+
return NULL;
|
2351
|
+
|
2352
|
+
dict = PyModule_GetDict(module);
|
2353
|
+
partial = PyDict_GetItemString(dict, "partial");
|
2354
|
+
|
2355
|
+
if (!partial) {
|
2356
|
+
Py_DECREF(module);
|
2357
|
+
return NULL;
|
2358
|
+
}
|
2359
|
+
|
2360
|
+
Py_INCREF(partial);
|
2361
|
+
Py_DECREF(module);
|
2362
|
+
|
2363
|
+
instance = PyTuple_GetItem(args, 0);
|
2364
|
+
|
2365
|
+
if (!instance) {
|
2366
|
+
Py_DECREF(partial);
|
2367
|
+
return NULL;
|
2368
|
+
}
|
2369
|
+
|
2370
|
+
wrapped = PyObject_CallFunctionObjArgs(partial,
|
2371
|
+
self->object_proxy.wrapped, instance, NULL);
|
2372
|
+
|
2373
|
+
Py_DECREF(partial);
|
2374
|
+
|
2375
|
+
if (!wrapped)
|
2376
|
+
return NULL;
|
2377
|
+
|
2378
|
+
param_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args));
|
2379
|
+
|
2380
|
+
if (!param_args) {
|
2381
|
+
Py_DECREF(wrapped);
|
2382
|
+
return NULL;
|
2383
|
+
}
|
2384
|
+
|
2385
|
+
args = param_args;
|
2386
|
+
}
|
2387
|
+
else
|
2388
|
+
instance = self->instance;
|
2389
|
+
|
2390
|
+
if (!wrapped) {
|
2391
|
+
Py_INCREF(self->object_proxy.wrapped);
|
2392
|
+
wrapped = self->object_proxy.wrapped;
|
2393
|
+
}
|
2394
|
+
|
2395
|
+
if (!kwds) {
|
2396
|
+
param_kwds = PyDict_New();
|
2397
|
+
kwds = param_kwds;
|
2398
|
+
}
|
2399
|
+
|
2400
|
+
result = PyObject_CallFunctionObjArgs(self->wrapper, wrapped,
|
2401
|
+
instance, args, kwds, NULL);
|
2402
|
+
|
2403
|
+
Py_XDECREF(param_args);
|
2404
|
+
Py_XDECREF(param_kwds);
|
2405
|
+
Py_DECREF(wrapped);
|
2406
|
+
|
2407
|
+
return result;
|
2408
|
+
}
|
2409
|
+
else {
|
2410
|
+
/*
|
2411
|
+
* As in this case we would be dealing with a classmethod or
|
2412
|
+
* staticmethod, then _self_instance will only tell us whether
|
2413
|
+
* when calling the classmethod or staticmethod they did it via
|
2414
|
+
* an instance of the class it is bound to and not the case
|
2415
|
+
* where done by the class type itself. We thus ignore
|
2416
|
+
* _self_instance and use the __self__ attribute of the bound
|
2417
|
+
* function instead. For a classmethod, this means instance will
|
2418
|
+
* be the class type and for a staticmethod it will be None.
|
2419
|
+
* This is probably the more useful thing we can pass through
|
2420
|
+
* even though we loose knowledge of whether they were called on
|
2421
|
+
* the instance vs the class type, as it reflects what they have
|
2422
|
+
* available in the decoratored function.
|
2423
|
+
*/
|
2424
|
+
|
2425
|
+
instance = PyObject_GetAttrString(self->object_proxy.wrapped,
|
2426
|
+
"__self__");
|
2427
|
+
|
2428
|
+
if (!instance) {
|
2429
|
+
PyErr_Clear();
|
2430
|
+
Py_INCREF(Py_None);
|
2431
|
+
instance = Py_None;
|
2432
|
+
}
|
2433
|
+
|
2434
|
+
if (!kwds) {
|
2435
|
+
param_kwds = PyDict_New();
|
2436
|
+
kwds = param_kwds;
|
2437
|
+
}
|
2438
|
+
|
2439
|
+
result = PyObject_CallFunctionObjArgs(self->wrapper,
|
2440
|
+
self->object_proxy.wrapped, instance, args, kwds, NULL);
|
2441
|
+
|
2442
|
+
Py_XDECREF(param_kwds);
|
2443
|
+
|
2444
|
+
Py_DECREF(instance);
|
2445
|
+
|
2446
|
+
return result;
|
2447
|
+
}
|
2448
|
+
}
|
2449
|
+
|
2450
|
+
/* ------------------------------------------------------------------------- */
|
2451
|
+
|
2452
|
+
static PyGetSetDef WraptBoundFunctionWrapper_getset[] = {
|
2453
|
+
{ "__module__", (getter)WraptObjectProxy_get_module,
|
2454
|
+
(setter)WraptObjectProxy_set_module, 0 },
|
2455
|
+
{ "__doc__", (getter)WraptObjectProxy_get_doc,
|
2456
|
+
(setter)WraptObjectProxy_set_doc, 0 },
|
2457
|
+
{ NULL },
|
2458
|
+
};
|
2459
|
+
|
2460
|
+
PyTypeObject WraptBoundFunctionWrapper_Type = {
|
2461
|
+
PyVarObject_HEAD_INIT(NULL, 0)
|
2462
|
+
"BoundFunctionWrapper", /*tp_name*/
|
2463
|
+
sizeof(WraptFunctionWrapperObject), /*tp_basicsize*/
|
2464
|
+
0, /*tp_itemsize*/
|
2465
|
+
/* methods */
|
2466
|
+
0, /*tp_dealloc*/
|
2467
|
+
0, /*tp_print*/
|
2468
|
+
0, /*tp_getattr*/
|
2469
|
+
0, /*tp_setattr*/
|
2470
|
+
0, /*tp_compare*/
|
2471
|
+
0, /*tp_repr*/
|
2472
|
+
0, /*tp_as_number*/
|
2473
|
+
0, /*tp_as_sequence*/
|
2474
|
+
0, /*tp_as_mapping*/
|
2475
|
+
0, /*tp_hash*/
|
2476
|
+
(ternaryfunc)WraptBoundFunctionWrapper_call, /*tp_call*/
|
2477
|
+
0, /*tp_str*/
|
2478
|
+
0, /*tp_getattro*/
|
2479
|
+
0, /*tp_setattro*/
|
2480
|
+
0, /*tp_as_buffer*/
|
2481
|
+
#if PY_MAJOR_VERSION < 3
|
2482
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
|
2483
|
+
#else
|
2484
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
2485
|
+
#endif
|
2486
|
+
0, /*tp_doc*/
|
2487
|
+
0, /*tp_traverse*/
|
2488
|
+
0, /*tp_clear*/
|
2489
|
+
0, /*tp_richcompare*/
|
2490
|
+
offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
|
2491
|
+
0, /*tp_iter*/
|
2492
|
+
0, /*tp_iternext*/
|
2493
|
+
0, /*tp_methods*/
|
2494
|
+
0, /*tp_members*/
|
2495
|
+
WraptBoundFunctionWrapper_getset, /*tp_getset*/
|
2496
|
+
0, /*tp_base*/
|
2497
|
+
0, /*tp_dict*/
|
2498
|
+
0, /*tp_descr_get*/
|
2499
|
+
0, /*tp_descr_set*/
|
2500
|
+
0, /*tp_dictoffset*/
|
2501
|
+
0, /*tp_init*/
|
2502
|
+
0, /*tp_alloc*/
|
2503
|
+
0, /*tp_new*/
|
2504
|
+
0, /*tp_free*/
|
2505
|
+
0, /*tp_is_gc*/
|
2506
|
+
};
|
2507
|
+
|
2508
|
+
/* ------------------------------------------------------------------------- */
|
2509
|
+
|
2510
|
+
static int WraptFunctionWrapper_init(WraptFunctionWrapperObject *self,
|
2511
|
+
PyObject *args, PyObject *kwds)
|
2512
|
+
{
|
2513
|
+
PyObject *wrapped = NULL;
|
2514
|
+
PyObject *wrapper = NULL;
|
2515
|
+
PyObject *enabled = Py_None;
|
2516
|
+
PyObject *binding = NULL;
|
2517
|
+
PyObject *instance = NULL;
|
2518
|
+
|
2519
|
+
static PyObject *classmethod_str = NULL;
|
2520
|
+
static PyObject *staticmethod_str = NULL;
|
2521
|
+
static PyObject *function_str = NULL;
|
2522
|
+
|
2523
|
+
int result = 0;
|
2524
|
+
|
2525
|
+
static char *kwlist[] = { "wrapped", "wrapper", "enabled", NULL };
|
2526
|
+
|
2527
|
+
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|O:FunctionWrapper",
|
2528
|
+
kwlist, &wrapped, &wrapper, &enabled)) {
|
2529
|
+
return -1;
|
2530
|
+
}
|
2531
|
+
|
2532
|
+
if (!classmethod_str) {
|
2533
|
+
#if PY_MAJOR_VERSION >= 3
|
2534
|
+
classmethod_str = PyUnicode_InternFromString("classmethod");
|
2535
|
+
#else
|
2536
|
+
classmethod_str = PyString_InternFromString("classmethod");
|
2537
|
+
#endif
|
2538
|
+
}
|
2539
|
+
|
2540
|
+
if (!staticmethod_str) {
|
2541
|
+
#if PY_MAJOR_VERSION >= 3
|
2542
|
+
staticmethod_str = PyUnicode_InternFromString("staticmethod");
|
2543
|
+
#else
|
2544
|
+
staticmethod_str = PyString_InternFromString("staticmethod");
|
2545
|
+
#endif
|
2546
|
+
}
|
2547
|
+
|
2548
|
+
if (!function_str) {
|
2549
|
+
#if PY_MAJOR_VERSION >= 3
|
2550
|
+
function_str = PyUnicode_InternFromString("function");
|
2551
|
+
#else
|
2552
|
+
function_str = PyString_InternFromString("function");
|
2553
|
+
#endif
|
2554
|
+
}
|
2555
|
+
|
2556
|
+
if (PyObject_IsInstance(wrapped, (PyObject *)&PyClassMethod_Type)) {
|
2557
|
+
binding = classmethod_str;
|
2558
|
+
}
|
2559
|
+
else if (PyObject_IsInstance(wrapped, (PyObject *)&PyStaticMethod_Type)) {
|
2560
|
+
binding = staticmethod_str;
|
2561
|
+
}
|
2562
|
+
else if ((instance = PyObject_GetAttrString(wrapped, "__self__")) != 0) {
|
2563
|
+
#if PY_MAJOR_VERSION < 3
|
2564
|
+
if (PyObject_IsInstance(instance, (PyObject *)&PyClass_Type) ||
|
2565
|
+
PyObject_IsInstance(instance, (PyObject *)&PyType_Type)) {
|
2566
|
+
binding = classmethod_str;
|
2567
|
+
}
|
2568
|
+
#else
|
2569
|
+
if (PyObject_IsInstance(instance, (PyObject *)&PyType_Type)) {
|
2570
|
+
binding = classmethod_str;
|
2571
|
+
}
|
2572
|
+
#endif
|
2573
|
+
else
|
2574
|
+
binding = function_str;
|
2575
|
+
|
2576
|
+
Py_DECREF(instance);
|
2577
|
+
}
|
2578
|
+
else {
|
2579
|
+
PyErr_Clear();
|
2580
|
+
|
2581
|
+
binding = function_str;
|
2582
|
+
}
|
2583
|
+
|
2584
|
+
result = WraptFunctionWrapperBase_raw_init(self, wrapped, Py_None,
|
2585
|
+
wrapper, enabled, binding, Py_None);
|
2586
|
+
|
2587
|
+
return result;
|
2588
|
+
}
|
2589
|
+
|
2590
|
+
/* ------------------------------------------------------------------------- */
|
2591
|
+
|
2592
|
+
static PyGetSetDef WraptFunctionWrapper_getset[] = {
|
2593
|
+
{ "__module__", (getter)WraptObjectProxy_get_module,
|
2594
|
+
(setter)WraptObjectProxy_set_module, 0 },
|
2595
|
+
{ "__doc__", (getter)WraptObjectProxy_get_doc,
|
2596
|
+
(setter)WraptObjectProxy_set_doc, 0 },
|
2597
|
+
{ NULL },
|
2598
|
+
};
|
2599
|
+
|
2600
|
+
PyTypeObject WraptFunctionWrapper_Type = {
|
2601
|
+
PyVarObject_HEAD_INIT(NULL, 0)
|
2602
|
+
"FunctionWrapper", /*tp_name*/
|
2603
|
+
sizeof(WraptFunctionWrapperObject), /*tp_basicsize*/
|
2604
|
+
0, /*tp_itemsize*/
|
2605
|
+
/* methods */
|
2606
|
+
0, /*tp_dealloc*/
|
2607
|
+
0, /*tp_print*/
|
2608
|
+
0, /*tp_getattr*/
|
2609
|
+
0, /*tp_setattr*/
|
2610
|
+
0, /*tp_compare*/
|
2611
|
+
0, /*tp_repr*/
|
2612
|
+
0, /*tp_as_number*/
|
2613
|
+
0, /*tp_as_sequence*/
|
2614
|
+
0, /*tp_as_mapping*/
|
2615
|
+
0, /*tp_hash*/
|
2616
|
+
0, /*tp_call*/
|
2617
|
+
0, /*tp_str*/
|
2618
|
+
0, /*tp_getattro*/
|
2619
|
+
0, /*tp_setattro*/
|
2620
|
+
0, /*tp_as_buffer*/
|
2621
|
+
#if PY_MAJOR_VERSION < 3
|
2622
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
|
2623
|
+
#else
|
2624
|
+
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /*tp_flags*/
|
2625
|
+
#endif
|
2626
|
+
0, /*tp_doc*/
|
2627
|
+
0, /*tp_traverse*/
|
2628
|
+
0, /*tp_clear*/
|
2629
|
+
0, /*tp_richcompare*/
|
2630
|
+
offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
|
2631
|
+
0, /*tp_iter*/
|
2632
|
+
0, /*tp_iternext*/
|
2633
|
+
0, /*tp_methods*/
|
2634
|
+
0, /*tp_members*/
|
2635
|
+
WraptFunctionWrapper_getset, /*tp_getset*/
|
2636
|
+
0, /*tp_base*/
|
2637
|
+
0, /*tp_dict*/
|
2638
|
+
0, /*tp_descr_get*/
|
2639
|
+
0, /*tp_descr_set*/
|
2640
|
+
0, /*tp_dictoffset*/
|
2641
|
+
(initproc)WraptFunctionWrapper_init, /*tp_init*/
|
2642
|
+
0, /*tp_alloc*/
|
2643
|
+
0, /*tp_new*/
|
2644
|
+
0, /*tp_free*/
|
2645
|
+
0, /*tp_is_gc*/
|
2646
|
+
};
|
2647
|
+
|
2648
|
+
/* ------------------------------------------------------------------------- */
|
2649
|
+
|
2650
|
+
#if PY_MAJOR_VERSION >= 3
|
2651
|
+
static struct PyModuleDef moduledef = {
|
2652
|
+
PyModuleDef_HEAD_INIT,
|
2653
|
+
"_wrappers", /* m_name */
|
2654
|
+
NULL, /* m_doc */
|
2655
|
+
-1, /* m_size */
|
2656
|
+
NULL, /* m_methods */
|
2657
|
+
NULL, /* m_reload */
|
2658
|
+
NULL, /* m_traverse */
|
2659
|
+
NULL, /* m_clear */
|
2660
|
+
NULL, /* m_free */
|
2661
|
+
};
|
2662
|
+
#endif
|
2663
|
+
|
2664
|
+
static PyObject *
|
2665
|
+
moduleinit(void)
|
2666
|
+
{
|
2667
|
+
PyObject *module;
|
2668
|
+
|
2669
|
+
#if PY_MAJOR_VERSION >= 3
|
2670
|
+
module = PyModule_Create(&moduledef);
|
2671
|
+
#else
|
2672
|
+
module = Py_InitModule3("_wrappers", NULL, NULL);
|
2673
|
+
#endif
|
2674
|
+
|
2675
|
+
if (module == NULL)
|
2676
|
+
return NULL;
|
2677
|
+
|
2678
|
+
if (PyType_Ready(&WraptObjectProxy_Type) < 0)
|
2679
|
+
return NULL;
|
2680
|
+
|
2681
|
+
/* Ensure that inheritance relationships specified. */
|
2682
|
+
|
2683
|
+
WraptCallableObjectProxy_Type.tp_base = &WraptObjectProxy_Type;
|
2684
|
+
WraptFunctionWrapperBase_Type.tp_base = &WraptObjectProxy_Type;
|
2685
|
+
WraptBoundFunctionWrapper_Type.tp_base = &WraptFunctionWrapperBase_Type;
|
2686
|
+
WraptFunctionWrapper_Type.tp_base = &WraptFunctionWrapperBase_Type;
|
2687
|
+
|
2688
|
+
if (PyType_Ready(&WraptCallableObjectProxy_Type) < 0)
|
2689
|
+
return NULL;
|
2690
|
+
if (PyType_Ready(&WraptFunctionWrapperBase_Type) < 0)
|
2691
|
+
return NULL;
|
2692
|
+
if (PyType_Ready(&WraptBoundFunctionWrapper_Type) < 0)
|
2693
|
+
return NULL;
|
2694
|
+
if (PyType_Ready(&WraptFunctionWrapper_Type) < 0)
|
2695
|
+
return NULL;
|
2696
|
+
|
2697
|
+
Py_INCREF(&WraptObjectProxy_Type);
|
2698
|
+
PyModule_AddObject(module, "ObjectProxy",
|
2699
|
+
(PyObject *)&WraptObjectProxy_Type);
|
2700
|
+
Py_INCREF(&WraptCallableObjectProxy_Type);
|
2701
|
+
PyModule_AddObject(module, "CallableObjectProxy",
|
2702
|
+
(PyObject *)&WraptCallableObjectProxy_Type);
|
2703
|
+
Py_INCREF(&WraptFunctionWrapper_Type);
|
2704
|
+
PyModule_AddObject(module, "FunctionWrapper",
|
2705
|
+
(PyObject *)&WraptFunctionWrapper_Type);
|
2706
|
+
|
2707
|
+
Py_INCREF(&WraptFunctionWrapperBase_Type);
|
2708
|
+
PyModule_AddObject(module, "_FunctionWrapperBase",
|
2709
|
+
(PyObject *)&WraptFunctionWrapperBase_Type);
|
2710
|
+
Py_INCREF(&WraptBoundFunctionWrapper_Type);
|
2711
|
+
PyModule_AddObject(module, "BoundFunctionWrapper",
|
2712
|
+
(PyObject *)&WraptBoundFunctionWrapper_Type);
|
2713
|
+
|
2714
|
+
return module;
|
2715
|
+
}
|
2716
|
+
|
2717
|
+
#if PY_MAJOR_VERSION < 3
|
2718
|
+
PyMODINIT_FUNC init_wrappers(void)
|
2719
|
+
{
|
2720
|
+
moduleinit();
|
2721
|
+
}
|
2722
|
+
#else
|
2723
|
+
PyMODINIT_FUNC PyInit__wrappers(void)
|
2724
|
+
{
|
2725
|
+
return moduleinit();
|
2726
|
+
}
|
2727
|
+
#endif
|
2728
|
+
|
2729
|
+
/* ------------------------------------------------------------------------- */
|