Skip to content
Permalink
Browse files

Revert "start tracking method visibility"

This reverts commit 15ec282.
  • Loading branch information
alex committed Jun 15, 2013
1 parent f3f74bb commit 9c95be03b837ef1afc978f81d08dbde3af79ba91
Showing with 11 additions and 24 deletions.
  1. +2 −2 tests/objects/test_moduleobject.py
  2. +4 −12 topaz/objects/functionobject.py
  3. +5 −10 topaz/objects/moduleobject.py
@@ -452,7 +452,7 @@ class X
def test_private_class_method(self, space):
space.execute("""
class X
def self.m
def m
end
private_class_method :m
end
@@ -461,7 +461,7 @@ def self.m
def test_public_class_method(self, space):
space.execute("""
class X
def self.m
def m
end
public_class_method :m
end
@@ -5,16 +5,11 @@


class W_FunctionObject(W_BaseObject):
_immutable_fields_ = ["name", "w_class", "visibility"]
_immutable_fields_ = ["name", "w_class"]

PUBLIC = 0
PROTECTED = 1
PRIVATE = 2

def __init__(self, name, w_class=None, visibility=PUBLIC):
def __init__(self, name, w_class=None):
self.name = name
self.w_class = w_class
self.visibility = visibility

def __deepcopy__(self, memo):
obj = super(W_FunctionObject, self).__deepcopy__(memo)
@@ -29,8 +24,8 @@ def arity(self, space):
class W_UserFunction(W_FunctionObject):
_immutable_fields_ = ["bytecode", "lexical_scope"]

def __init__(self, name, bytecode, lexical_scope, visibility=W_FunctionObject.PUBLIC):
W_FunctionObject.__init__(self, name, visibility)
def __init__(self, name, bytecode, lexical_scope):
W_FunctionObject.__init__(self, name)
self.bytecode = bytecode
self.lexical_scope = lexical_scope

@@ -40,9 +35,6 @@ def __deepcopy__(self, memo):
obj.lexical_scope = copy.deepcopy(self.lexical_scope, memo)
return obj

def change_visibility(self, visibility):
return W_UserFunction(self.name, self.bytecode, self.lexical_scope, self.visibility)

def call(self, space, w_receiver, args_w, block):
frame = space.create_frame(
self.bytecode,
@@ -323,13 +323,7 @@ def set_default_visibility(self, space, visibility):
pass

def set_method_visibility(self, space, name, visibility):
w_method = self.find_method(space, name)
if w_method is None or isinstance(w_method, UndefMethod):
cls_name = space.obj_to_s(self)
raise space.error(space.w_NameError,
"undefined method `%s' for class `%s'" % (name, cls_name)
)
self.define_method(space, name, w_method.change_visibility(visibility))
pass

def method_added(self, space, w_name):
space.send(self, "method_added", [w_name])
@@ -502,15 +496,15 @@ def method_name(self, space):

@classdef.method("private")
def method_private(self, space, args_w):
self.set_visibility(space, args_w, W_FunctionObject.PRIVATE)
self.set_visibility(space, args_w, "private")

@classdef.method("public")
def method_public(self, space, args_w):
self.set_visibility(space, args_w, W_FunctionObject.PUBLIC)
self.set_visibility(space, args_w, "public")

@classdef.method("protected")
def method_protected(self, space, args_w):
self.set_visibility(space, args_w, W_FunctionObject.PROTECTED)
self.set_visibility(space, args_w, "protected")

@classdef.method("private_constant")
def method_private_constant(self, space, args_w):
@@ -679,6 +673,7 @@ def method_comparison(self, space, w_other):
else:
return space.newint(1)


@classdef.method("instance_method", name="symbol")
def method_instance_method(self, space, name):
return space.newmethod(name, self)

0 comments on commit 9c95be0

Please sign in to comment.