~ubuntu-branches/ubuntu/karmic/pypy/karmic

« back to all changes in this revision

Viewing changes to pypy/objspace/std/default.py

  • Committer: Bazaar Package Importer
  • Author(s): Alexandre Fayolle
  • Date: 2007-04-13 09:33:09 UTC
  • Revision ID: james.westby@ubuntu.com-20070413093309-yoojh4jcoocu2krz
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
"""Default implementation for some operation."""
 
2
 
 
3
from pypy.objspace.std.objspace import *
 
4
 
 
5
 
 
6
# The following default implementations are used before delegation is tried.
 
7
# 'id' is normally the address of the wrapper.
 
8
 
 
9
def id__ANY(space, w_obj):
 
10
    #print 'id:', w_obj
 
11
    return space.wrap(id(w_obj))
 
12
 
 
13
# __init__ should succeed if called internally as a multimethod
 
14
 
 
15
def init__ANY(space, w_obj, __args__):
 
16
    pass
 
17
 
 
18
def typed_unwrap_error_msg(space, expected, w_obj):
 
19
    type_name = space.type(w_obj).getname(space, '?')
 
20
    return space.wrap("expected %s, got %s object" % (expected, type_name))
 
21
 
 
22
def int_w__ANY(space,w_obj):
 
23
    raise OperationError(space.w_TypeError,
 
24
                         typed_unwrap_error_msg(space, "integer", w_obj))
 
25
 
 
26
def str_w__ANY(space,w_obj):
 
27
    raise OperationError(space.w_TypeError,
 
28
                         typed_unwrap_error_msg(space, "string", w_obj))
 
29
 
 
30
def float_w__ANY(space,w_obj):
 
31
    raise OperationError(space.w_TypeError,
 
32
                         typed_unwrap_error_msg(space, "float", w_obj))
 
33
 
 
34
def uint_w__ANY(space,w_obj):
 
35
    raise OperationError(space.w_TypeError,
 
36
                         typed_unwrap_error_msg(space, "integer", w_obj))
 
37
 
 
38
register_all(vars())