Guest User

Untitled

a guest
Jun 21st, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. D:ruby_extendpronmake>irb
  2. irb(main):001:0> require 'pro1'
  3. => true
  4. irb(main):002:0> include Pro
  5. => Object
  6. irb(main):003:0> Pro::load
  7. => false
  8. irb(main):004:0>
  9.  
  10. #include "windows.h"
  11. #include "ruby.h"
  12. #include "pro.h"
  13. #define _D(string) {OutputDebugString(string);}
  14. VALUE Pro;
  15. HINSTANCE hlibrary;
  16.  
  17. void _textline(const char *s, int len)
  18. //************************************
  19. {
  20. _D(s);
  21. }
  22.  
  23. static VALUE p_load(VALUE self )
  24. //******************************
  25. {
  26. return pro_load();
  27. }
  28.  
  29. static VALUE p_init(VALUE self)
  30. //*****************************
  31. {
  32. _D("-> init");
  33. pro_set_textline_callback(_textline);
  34. pro_renderInit();
  35. }
  36.  
  37. static VALUE p_parse(VALUE self, VALUE string_to_parse)
  38. //*****************************************************
  39. {
  40. _D(StringValuePtr(string_to_parse));
  41. return pro_parse(StringValuePtr(string_to_parse));
  42. }
  43.  
  44. void proeventcallback(proRenderEventType type, proRenderEventData data)
  45. //************************************************************************
  46. {
  47. switch(type){
  48. case proRenderEventDone:
  49. _D("-> cleanup");
  50. pro_renderCleanUp();
  51. //if (vWindow)
  52. //{
  53. // SendMessage((HWND)NUM2INT(vWindow), WM_USER+2, 0, 0);
  54. //}
  55. }
  56. }
  57.  
  58. static VALUE pro_render( VALUE self )
  59. //**********************************
  60. {
  61. _D("-> render");
  62. pro_set_renderevent_callback(proeventcallback);
  63. SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_ABOVE_NORMAL);
  64. pro_render(PRO_RENDERASYNC);
  65. return Qtrue;
  66. }
  67.  
  68. void Init_pro1()
  69. //***************
  70. {
  71. pro = rb_define_module( "Pro" );
  72. rb_define_method(Pro, "load", p_load, 0);
  73. rb_define_method( Pro, "init_engine", p_init, 0 );
  74. rb_define_method(Pro, "parse", p_parse, 1);
  75. rb_define_method(Pro, "render", pr_render, 0);
  76. }
Add Comment
Please, Sign In to add comment