wrap bound methods of attrs in a InstanceMethod proxies
166492
def _wrap_attr(self, attrs, context=None):
        """"""
        for attr in attrs:
            if isinstance(attr, UnboundMethod):
                if _is_property(attr):
                    yield from attr.infer_call_result(self, context)
                else:
                    yield BoundMethod(attr, self)
            elif hasattr(attr, "name") and attr.name == "<lambda>":
                if attr.args.args and attr.args.args[0].name == "self":
                    yield BoundMethod(attr, self)
                    continue
                yield attr
            else:
                yield attr
992189
def _make_bound_method(func, self):
    """"""
    class Foo(object):
        def meth(self): pass
    f = Foo()
    bound_method = type(f.meth)
    try:
        return bound_method(func, self, self.__class__)
    except TypeError: # python3
        return bound_method(func, self)
504008
function (interfaceMethods, interceptor, allInterceptors) {
        var interceptedMethods = allInterceptors || {};
        // for a class object, intercept specific methods
        for (var m in interfaceMethods) {
            if (interfaceMethods.hasOwnProperty(m) && __hasBeenIntercepted(m, interceptor)) {
                (interceptedMethods[m] || (interceptedMethods[m] = [])).push({
                    fn : __callInterceptorMethod,
                    scope : interceptor
                });
            }
        }
        return interceptedMethods;
    }
132368
function bindMethods(obj, scope) {
  return Object.keys(obj).reduce((bound, key) => {
    if (typeof obj[key] === 'function') {
      bound[key] = obj[key].bind(scope);
    } else if (_lodash2.default.isObject(obj[key])) {
      bound[key] = bindMethods(obj[key], scope);
    }
    return bound;
  }, {});
}
180037
function wrapANodeMethods (obj) {
  var newObj = {};
  var ANodeMethods = [
    'attachedCallback',
    'attributeChangedCallback',
    'createdCallback',
    'detachedCallback'
  ];
  wrapMethods(newObj, ANodeMethods, obj, ANode.prototype);
  copyProperties(obj, newObj);
  return newObj;
}
331138
function bindMethod(
  target: DecoratorTarget,
  name: string,
  descriptor: Descriptor,
): Descriptor {
  const func = getValueFunc('bind', descriptor);

  return {
    configurable: true,
    enumerable: false,
    get() {
      // This happens if someone accesses the property directly on the prototype
      // Thanks to jayphelps/core-decorators.js for the snippet
      if (this === target) {
        return func;
      }

      // The `this` here is the current class prototype
      // While `target` is the parent class prototype
      const boundFunc = func.bind(this);

      // Define a function on the target so that `get()` is only called once
      // Inherit the original methods descriptor as well
      Object.defineProperty(this, name, {
        ...descriptor,
        enumerable: true,
        value: boundFunc,
      });

      return boundFunc;
    },
    set(value) {
      Object.defineProperty(this, name, {
        ...descriptor,
        value,
      });
    },
  };
}
7676
function defineMethods(sugarNamespace, methods, type, args, flags) {
  forEachProperty(methods, function(method, methodName) {
    var instanceMethod, staticMethod = method;
    if (args) {
      staticMethod = wrapMethodWithArguments(method);
    }
    if (flags) {
      staticMethod.flags = flags;
    }

    // A method may define its own custom implementation, so
    // make sure that's not the case before creating one.
    if (type & INSTANCE && !method.instance) {
      instanceMethod = wrapInstanceMethod(method, args);
      setProperty(staticMethod, 'instance', instanceMethod);
    }

    if (type & STATIC) {
      setProperty(staticMethod, 'static', true);
    }

    setMethod(sugarNamespace, methodName, staticMethod);

    if (sugarNamespace.active) {
      // If the namespace has been activated (.extend has been called),
      // then map this method as well.
      sugarNamespace.extend(methodName);
    }
  });
}
175137
function protectMethod(name, meta, instance) {
        instance[cacheKeyword].methods[name] = meta.implementation;

        if (meta.isPrivate) {
            Object.defineProperty(instance, name, {
                get: function get() {
                    var method = instance[cacheKeyword].methods[name],
                        isConstructor = name === 'initialize',
                        currCaller;

                    currCaller = caller;

                    if (instance.$initializing || (currCaller && (currCaller.method[$name] || currCaller.method[$anonymous]) && meta.allowed === currCaller.constructorId)) {
                        return method;
                    }

                    if (!isConstructor) {
                        throw new Error('Cannot access private method "' + name + '" of class "' + instance.$name + '".');
                    } else {
                        throw new Error('Constructor of class "' + instance.$name + '" is private.');
                    }
                },
                set: function set(newVal) {
                    if (instance.$initializing || !instance.$static[$class].locked || instance.$static[$class].forceUnlocked) {
                        instance[cacheKeyword].methods[name] = newVal;
                        instance[redefinedCacheKeyword].methods[name] = true; // This is just for the inspect
                    } else {
                        throw new Error('Cannot set private method "' + name + '" of class "' + instance.$name + '".');
                    }
                },
                configurable: false,
                enumerable: true
            });
        } else if (meta.isProtected) {
            Object.defineProperty(instance, name, {
                get: function get() {
                    var method = instance[cacheKeyword].methods[name],
                        isConstructor = name === 'initialize',
                        currCaller;

                    currCaller = caller;

                    if (instance.$initializing || (currCaller && (currCaller.method[$name] || currCaller.method[$anonymous]) && (contains(meta.allowed, currCaller.constructorId) || instance instanceof currCaller.constructor))) {
                        return method;
                    }

                    if (!isConstructor) {
                        throw new Error('Cannot access protected method "' + name + '" of class "' + instance.$name + '".');
                    } else {
                        throw new Error('Constructor of class "' + instance.$name + '" is protected.');
                    }
                },
                set: function set(newVal) {
                    if (instance.$initializing || !instance.$static[$class].locked || instance.$static[$class].forceUnlocked) {
                        instance[cacheKeyword].methods[name] = newVal;
                        instance[redefinedCacheKeyword].methods[name] = true; // This is just for the inspect
                    } else {
                        throw new Error('Cannot set protected method "' + name + '" of class "' + instance.$name + '".');
                    }
                },
                configurable: false,
                enumerable: true
            });
        } else {
            Object.defineProperty(instance, name, {
                get: function get() {
                    return instance[cacheKeyword].methods[name];
                },
                set: function set(newVal) {
                    if (instance.$initializing || !instance.$static[$class].locked || instance.$static[$class].forceUnlocked) {
                        instance[cacheKeyword].methods[name] = newVal;
                        instance[redefinedCacheKeyword].methods[name] = true;
                    } else {
                        throw new Error('Cannot set public method "' + name + '" of class "' + instance.$name + '".');
                    }
                },
                configurable: false,
                enumerable: true
            });
        }
    }
469228
def dir_instance(inst):
    
    # Skip instance attributes; __slots__ is automatically defined, and
    # descriptors are used to define attributes. Instead, go straight to class
    # attributes (including methods).
    for name, value in vars_class(type(inst)).items():
        if isinstance(value, ObjectMethod):
            if value.has_instancemethod:
                yield name
        elif isinstance(value, Disabled):
            pass  # Hide this; disabled.
        elif isinstance(value, (classmethod, staticmethod)):
            pass  # Hide this; not interesting here.
        else:
            yield name
396504
def is_class_method_bound(method, arg_name=BOUND_METHOD_ARGUMENT_NAME):
    
    if not method.args.args:
        return False

    first_arg = method.args.args[0]

    first_arg_name = get_object_name(first_arg)

    return first_arg_name == arg_name
1161301
def _proxy(method):
    
    @functools.wraps(method)
    def memoizer(self, context):
        return method(context)

    return memoizer
781110
function bindAll(obj) {
    extend.apply(null, arguments) 
    Object.keys(obj).filter(isMethod).forEach(bindMethods)
    return obj
    
    function isMethod(name) {
        return obj[name] && obj[name].bind === isMethod.bind
    }
    
    function bindMethods(name) {
        obj[name] = obj[name].bind(obj)
    }
}
1192172
function (method, options) {
    var self = this,
        bind = function(){
          var $this = S(this),
              should_bind_events = !$this.data(self.attr_name(true) + '-init');
          $this.data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options($this)));

          if (should_bind_events) {
            self.events(this);
          }
        };

    if (S(this.scope).is('[' + this.attr_name() +']')) {
      bind.call(this.scope);
    } else {
      S('[' + this.attr_name() +']', this.scope).each(bind);
    }
    // # Patch to fix #5043 to move this *after* the if/else clause in order for Backbone and similar frameworks to have improved control over event binding and data-options updating.
    if (typeof method === 'string') {
      return this[method].call(this, options);
    }

  }
959562
def is_bound(method):
    
    @functools.wraps(method)
    def wrapper(self, *args, **kwargs):
        if not self._is_bound:
            raise ValueError("%r must be bound to call %s()" % (self, method.__name__))
        return method(self, *args, **kwargs)
    return wrapper
257887
def delegate(attribute_name, method_names):
    
    call_attribute_method = partial(_call_delegated_method, attribute_name)

    def decorate(class_):
        for method in method_names:
            setattr(class_, method, partialmethod(call_attribute_method, method))

        return class_
    return decorate
1020754
function Mixin_setInstanceKey(hostClass, method, instanceKey) {
    check(hostClass, Function);
    check(instanceKey, Match.IdentifierString);

    var prop = INSTANCE_PROPERTIES_MAP,
        instanceKeys = hostClass[prop] = hostClass[prop] || {};

    if (instanceKeys[method.name])
        throw new Error('Mixin: instance property for method with name '
            + method.name + ' is already set');

    instanceKeys[method.name] = instanceKey;
}
709237
function boundMethod(target, key, descriptor) {
    // console.log('target, key, descriptor', target, key, descriptor)
    let fn = descriptor.value

    if (typeof fn !== 'function') {
        throw new Error(`@autobind decorator can only be applied to methods not: ${typeof fn}`)
    }

    // In IE11 calling Object.defineProperty has a side-effect of evaluating the
    // getter for the property which is being replaced. This causes infinite
    // recursion and an "Out of stack space" error.
    let definingProperty = false

    return {
        configurable: true,
        get() {
            if (definingProperty || this === target.prototype || this.hasOwnProperty(key)
                || typeof fn !== 'function') {
                return fn
            }

            let boundFn = bind(fn, this)//fn.bind(this)
            definingProperty = true
            Object.defineProperty(this, key, {
                configurable: true,
                get() {
                    return boundFn
                },
                set(value) {
                    fn = value
                    delete this[key]
                }
            })
            definingProperty = false
            return boundFn
        },
        set(value) {
            fn = value
        }
    }
}