Author: Tim Felgentreff <timfelgentr...@gmail.com> Branch: Changeset: r155:7b8972a221d1 Date: 2013-03-08 15:57 +0100 http://bitbucket.org/pypy/lang-smalltalk/changeset/7b8972a221d1/
Log: (tfel, krono) add INTERRUPT_SEMAPHORE diff --git a/spyvm/constants.py b/spyvm/constants.py --- a/spyvm/constants.py +++ b/spyvm/constants.py @@ -133,6 +133,7 @@ "special_selectors": SO_SPECIAL_SELECTORS_ARRAY, "smalltalkdict" : SO_SMALLTALK, "display" : SO_DISPLAY_OBJECT, + "interrupt_semaphore" : SO_USER_INTERRUPT_SEMAPHORE, } LONG_BIT = 32 diff --git a/spyvm/primitives.py b/spyvm/primitives.py --- a/spyvm/primitives.py +++ b/spyvm/primitives.py @@ -675,11 +675,11 @@ # ___________________________________________________________________________ -# Squeak Miscellaneous Primitives (128-149) +# Squeak Miscellaneous Primitives (128-134) BECOME = 128 FULL_GC = 130 INC_GC = 131 -CLONE = 148 +INTERRUPT_SEMAPHORE = 134 @expose_primitive(BECOME, unwrap_spec=[object, object]) def func(interp, s_frame, w_rcvr, w_new): @@ -710,12 +710,16 @@ rgc.collect() return fake_bytes_left(interp) -@expose_primitive(CLONE, unwrap_spec=[object]) -def func(interp, s_frame, w_arg): - return w_arg.clone(interp.space) +@expose_primitive(INTERRUPT_SEMAPHORE, unwrap_spec=[object, object]) +def func(interp, s_frame, w_rcvr, w_semaphore): + if w_semaphore.getclass(interp.space).is_same_object(interp.space.w_Semaphore): + interp.space.objtable['w_interrupt_semaphore'] = w_semaphore + else: + interp.space.objtable['w_interrupt_semaphore'] = interp.space.w_nil + return w_rcvr #____________________________________________________________________________ -# Time Primitives +# Time Primitives (135 - 137) MILLISECOND_CLOCK = 135 SECONDS_CLOCK = 137 @@ -735,6 +739,16 @@ sec_since_1901 = sec_since_epoch + secs_between_1901_and_1970 return interp.space.wrap_uint(sec_since_1901) + +#____________________________________________________________________________ +# Misc Primitives (138 - 149) +CLONE = 148 + +@expose_primitive(CLONE, unwrap_spec=[object]) +def func(interp, s_frame, w_arg): + return w_arg.clone(interp.space) + + # ___________________________________________________________________________ # File primitives (150-169) # (XXX they are obsolete in Squeak and done with a plugin) diff --git a/spyvm/test/test_primitives.py b/spyvm/test/test_primitives.py --- a/spyvm/test/test_primitives.py +++ b/spyvm/test/test_primitives.py @@ -403,6 +403,17 @@ # Should not fail :-) prim(primitives.FULL_GC, [42]) # Dummy arg +def test_interrupt_semaphore(): + prim(primitives.INTERRUPT_SEMAPHORE, [1, space.w_true]) + assert space.objtable["w_interrupt_semaphore"] is space.w_nil + + class SemaphoreInst(model.W_Object): + def getclass(self, space): + return space.w_Semaphore + w_semaphore = SemaphoreInst() + prim(primitives.INTERRUPT_SEMAPHORE, [1, w_semaphore]) + assert space.objtable["w_interrupt_semaphore"] is w_semaphore + def test_seconds_clock(): import time now = int(time.time()) @@ -442,7 +453,7 @@ assert space.unwrap_int(w_v.at0(space, 0)) == 1 def test_file_open_write(monkeypatch): - def open_write(filename, mode): + def open_write(filename, mode, perm): assert filename == "nonexistant" assert mode == os.O_RDWR | os.O_CREAT | os.O_TRUNC return 42 @@ -454,7 +465,7 @@ assert space.unwrap_int(w_c) == 42 def test_file_open_read(monkeypatch): - def open_read(filename, mode): + def open_read(filename, mode, perm): assert filename == "file" assert mode == os.O_RDONLY return 42 _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit