Displaying 11 results from an estimated 11 matches for "rb_block_given_p".
2007 Mar 21
4
Problem with PaintDC(MSW)
When implementing EVT_PAINT handlers in c++ the PaintDC object is
constructed at the beginning of the function,
and auto destructed at it''s end, which informs wxwidgets that "invalid
regions in the window have been repainted".
Under ruby, this is not the case and causes a stream of EVT_PAINT events
to be sent to the given window (until one
of PaintDC objects is destructed by
2006 May 02
1
Converting rb_protect + ruby_stop to pure Ruby
Hi,
Within process.c, in the fork method, there''s this bit of code:
if(rb_block_given_p()){
int status;
rb_protect(rb_yield, Qundef, &status);
ruby_stop(status);
}
I translated that as this:
if block_given?
status = 0
begin
yield
rescue Exception
status = -1 # Any non-zero result is failure
end
exit(status)
end
Is there a way to ge...
2004 Oct 23
0
win32-ipc, with blocks (code review please)
...for(i=0; i<len; i++) {
handles[i] = (HANDLE)NUM2UINT(RARRAY(arr)->ptr[i]);
}
dwWait = WaitForMultipleObjects(len,handles,fWaitAll,dwTimeOut);
// Yield block if signalled and block is provided
if((dwWait >= WAIT_OBJECT_0) && (dwWait < WAIT_OBJECT_0 + len)){
if(rb_block_given_p()){
rb_yield(klass);
}
return INT2NUM(dwWait - WAIT_OBJECT_0 + 1); // signalled
}
if((dwWait >= WAIT_ABANDONED_0) && (dwWait < WAIT_ABANDONED_0 + len)){
return INT2NUM(-(dwWait - WAIT_ABANDONED_0 + 1)); // an abandoned
mutex
}
if(dwWait == WAIT_TIME...
2007 May 31
0
[1039] trunk/wxruby2/swig/Events.i: Remove some debugging output
...@@
</span><span class="cx">
</span><span class="cx"> int idStart = NUM2INT(argv[0]);
</span><span class="cx"> int idEnd = NUM2INT(argv[1]);
</span><del>- //printf("evt_with_id(%d) %s\n", id, rb_block_given_p() ? "with block" : "");
</del><span class="cx">
</span><span class="cx"> internal_connect(self, idStart, idEnd, eventType);
</span><span class="cx"> return Qnil;
</span><span class="lines&qu...
2007 Apr 29
0
[983] branches/wxruby2/wxwidgets_282: Make Window#paint work both inside and outside a paint event handler,
...intDC if used within a evt_paint handler
+ // (recommended) or else a ClientDC.
</ins><span class="cx"> VALUE paint()
</span><span class="cx"> {
</span><ins>+        if ( ! rb_block_given_p() )
+         rb_raise(rb_eArgError, "No block given for Window#paint");
+
</ins><span class="cx">         wxWindow *ptr = self;
</span...
2004 Mar 13
0
Quick thought on win32-mmap
I suggest getting rid of the hash style arguments fior new() for this
package. In this particular case, you already have a class and accessors,
so you can just use the yield trick, e.g. rb_yield(self) if
rb_block_given_p(). Thus you can do:
mm = Mmap.new do |m|
m.namespace = file
m.swapfile = sfile
m.size = 1024
end
Looks just as nice, and is a lot less code on the C side of things. I only
use the hash-style keys when I don''t feel like creating separate objects, or
where separate objects don...
[707] trunk/wxruby2/swig/classes/Window.i: Window-paint method now implemented in Ruby (Alex Fenton)
2006 Oct 22
0
[707] trunk/wxruby2/swig/classes/Window.i: Window-paint method now implemented in Ruby (Alex Fenton)
...turn Qnil;
- }
-
- VALUE paint()
- {
-         wxWindow *ptr = self;
-        
-         if(rb_block_given_p())
-         {
-         wxPaintDC dc(ptr);
-        
-    &a...
2007 May 29
0
[1035] trunk/wxruby2/swig/classes/EvtHandler.i: Removed a heap of redundant stuff that''s been #if 0''d for a while
...atic VALUE internal_evt_with_id(int argc, VALUE *argv, VALUE self,
- wxEventType eventType)
-{
- if (argc != 1)
- rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc);
-
- int id = NUM2INT(argv[0]);
- //printf("evt_with_id(%d) %s\n", id, rb_block_given_p() ? "with block" : "");
-
- internal_connect(self, id, id, eventType);
- return Qnil;
-}
-
-static VALUE internal_evt_with_id_range(int argc, VALUE *argv, VALUE self,
- wxEventType eventType)
-{
- if (argc != 2)
- rb_raise(rb_eArgError, "wrong # of a...
2007 May 31
0
[1038] trunk/wxruby2/swig/Events.i: Add missing EVT_COMMAND_TREE constants
...ments(%d for 0)",argc);
</span><del>-
</del><ins>+        puts("Called in Events");
</ins><span class="cx"> //printf("evt_no_parameters() %s\n", rb_block_given_p() ? "with block" : "");
</span><span class="cx"> internal_connect(self, -1, -1, eventType);
</span><span class="cx"> return Qnil;
</span></span></pre>
</div>
</div>
</body>
</html>
2007 Mar 22
0
[910] branches/wxruby2/wxwidgets_282: Moved paint() method back into C++, so DC object is destroyed in timely
...return returnVal;
</span><span class="cx"> }
</span><ins>+ VALUE paint()
+ {
+        wxWindow *ptr = self;
+        if ( rb_block_given_p() )
+         {
+                wxPaintDC dc(ptr);
+     &nbs...
2007 May 31
0
[1040] trunk/wxruby2/swig/Events.i: Add List and Splitter constants, also EVT_SIZING and EVT_MOVING
...uot;> rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)",argc);
</span><span class="cx">
</span><span class="cx"> int id = NUM2INT(argv[0]);
</span><del>- //printf("evt_with_id(%d) %s\n", id, rb_block_given_p() ? "with block" : "");
</del><span class="cx">
</span><span class="cx"> internal_connect(self, id, id, eventType);
</span><span class="cx"> return Qnil;
</span></span></pre>
</div>...