Skip to content
Permalink
Browse files

Merge pull request #671 from topazproject/tim/Process.times

Add Process.times
  • Loading branch information
timfel committed Aug 16, 2013
2 parents 3acaeb9 + bfab884 commit a43eca966dca070d0af39ccf9cbe3a95041a6129
Showing with 34 additions and 2 deletions.
  1. +12 −0 lib-topaz/struct.rb
  2. +0 −2 spec/tags/core/process/times_tags.txt
  3. +12 −0 topaz/modules/process.py
  4. +10 −0 topaz/objects/moduleobject.py
@@ -212,4 +212,16 @@ def to_s
return "[...]" if recursion
end
alias inspect to_s

Struct.new('Tms', :utime, :stime, :cutime, :cstime, :tutime, :tstime) do
def initialize(utime=nil, stime=nil, cutime=nil, cstime=nil,
tutime=nil, tstime=nil)
@utime = utime
@stime = stime
@cutime = cutime
@cstime = cstime
@tutime = tutime
@tstime = tstime
end
end
end

This file was deleted.

@@ -80,6 +80,18 @@ def method_fork(self, space, block):
else:
return space.newint(pid)

@moduledef.function("times")
def method_times(self, space):
tms = space.find_const(
space.find_const(space.w_object, "Struct"),
"Tms"
)
return space.send(
tms,
"new",
[space.newfloat(t) for t in list(os.times()[0:4])]
)

@moduledef.function("kill")
def method_kill(self, space, w_signal, args_w):
if not args_w:
@@ -19,6 +19,11 @@ def __init__(self, varname):
W_FunctionObject.__init__(self, varname)
self.varname = varname

def __deepcopy__(self, memo):
obj = super(W_FunctionObject, self).__deepcopy__(memo)
obj.varname = self.varname
return obj

def call(self, space, w_obj, args_w, block):
return space.find_instance_var(w_obj, self.varname)

@@ -30,6 +35,11 @@ def __init__(self, varname):
W_FunctionObject.__init__(self, varname)
self.varname = varname

def __deepcopy__(self, memo):
obj = super(W_FunctionObject, self).__deepcopy__(memo)
obj.varname = self.varname
return obj

def call(self, space, w_obj, args_w, block):
[w_value] = args_w
space.set_instance_var(w_obj, self.varname, w_value)

0 comments on commit a43eca9

Please sign in to comment.