libc-eventmachine 0.12.5.42

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/Rakefile +195 -0
  2. data/docs/COPYING +60 -0
  3. data/docs/ChangeLog +211 -0
  4. data/docs/DEFERRABLES +138 -0
  5. data/docs/EPOLL +141 -0
  6. data/docs/GNU +281 -0
  7. data/docs/INSTALL +15 -0
  8. data/docs/KEYBOARD +38 -0
  9. data/docs/LEGAL +25 -0
  10. data/docs/LIGHTWEIGHT_CONCURRENCY +72 -0
  11. data/docs/PURE_RUBY +77 -0
  12. data/docs/README +74 -0
  13. data/docs/RELEASE_NOTES +96 -0
  14. data/docs/SMTP +9 -0
  15. data/docs/SPAWNED_PROCESSES +93 -0
  16. data/docs/TODO +10 -0
  17. data/ext/binder.cpp +126 -0
  18. data/ext/binder.h +48 -0
  19. data/ext/cmain.cpp +582 -0
  20. data/ext/cplusplus.cpp +177 -0
  21. data/ext/ed.cpp +1522 -0
  22. data/ext/ed.h +380 -0
  23. data/ext/em.cpp +1947 -0
  24. data/ext/em.h +186 -0
  25. data/ext/emwin.cpp +300 -0
  26. data/ext/emwin.h +94 -0
  27. data/ext/epoll.cpp +26 -0
  28. data/ext/epoll.h +25 -0
  29. data/ext/eventmachine.h +98 -0
  30. data/ext/eventmachine_cpp.h +96 -0
  31. data/ext/extconf.rb +129 -0
  32. data/ext/fastfilereader/extconf.rb +77 -0
  33. data/ext/fastfilereader/mapper.cpp +214 -0
  34. data/ext/fastfilereader/mapper.h +59 -0
  35. data/ext/fastfilereader/rubymain.cpp +127 -0
  36. data/ext/files.cpp +94 -0
  37. data/ext/files.h +65 -0
  38. data/ext/kb.cpp +82 -0
  39. data/ext/page.cpp +107 -0
  40. data/ext/page.h +51 -0
  41. data/ext/pipe.cpp +351 -0
  42. data/ext/project.h +119 -0
  43. data/ext/rubymain.cpp +858 -0
  44. data/ext/sigs.cpp +89 -0
  45. data/ext/sigs.h +32 -0
  46. data/ext/ssl.cpp +423 -0
  47. data/ext/ssl.h +90 -0
  48. data/java/src/com/rubyeventmachine/Application.java +196 -0
  49. data/java/src/com/rubyeventmachine/Connection.java +74 -0
  50. data/java/src/com/rubyeventmachine/ConnectionFactory.java +37 -0
  51. data/java/src/com/rubyeventmachine/DefaultConnectionFactory.java +46 -0
  52. data/java/src/com/rubyeventmachine/EmReactor.java +408 -0
  53. data/java/src/com/rubyeventmachine/EmReactorException.java +40 -0
  54. data/java/src/com/rubyeventmachine/EventableChannel.java +57 -0
  55. data/java/src/com/rubyeventmachine/EventableDatagramChannel.java +171 -0
  56. data/java/src/com/rubyeventmachine/EventableSocketChannel.java +244 -0
  57. data/java/src/com/rubyeventmachine/PeriodicTimer.java +38 -0
  58. data/java/src/com/rubyeventmachine/Timer.java +54 -0
  59. data/java/src/com/rubyeventmachine/tests/ApplicationTest.java +108 -0
  60. data/java/src/com/rubyeventmachine/tests/ConnectTest.java +124 -0
  61. data/java/src/com/rubyeventmachine/tests/EMTest.java +80 -0
  62. data/java/src/com/rubyeventmachine/tests/TestDatagrams.java +53 -0
  63. data/java/src/com/rubyeventmachine/tests/TestServers.java +74 -0
  64. data/java/src/com/rubyeventmachine/tests/TestTimers.java +89 -0
  65. data/lib/em/deferrable.rb +208 -0
  66. data/lib/em/eventable.rb +39 -0
  67. data/lib/em/future.rb +62 -0
  68. data/lib/em/messages.rb +66 -0
  69. data/lib/em/processes.rb +68 -0
  70. data/lib/em/spawnable.rb +88 -0
  71. data/lib/em/streamer.rb +112 -0
  72. data/lib/eventmachine.rb +1920 -0
  73. data/lib/eventmachine_version.rb +31 -0
  74. data/lib/evma/callback.rb +32 -0
  75. data/lib/evma/container.rb +75 -0
  76. data/lib/evma/factory.rb +77 -0
  77. data/lib/evma/protocol.rb +87 -0
  78. data/lib/evma/reactor.rb +48 -0
  79. data/lib/evma.rb +32 -0
  80. data/lib/jeventmachine.rb +140 -0
  81. data/lib/pr_eventmachine.rb +1017 -0
  82. data/lib/protocols/buftok.rb +127 -0
  83. data/lib/protocols/header_and_content.rb +129 -0
  84. data/lib/protocols/httpcli2.rb +803 -0
  85. data/lib/protocols/httpclient.rb +270 -0
  86. data/lib/protocols/line_and_text.rb +126 -0
  87. data/lib/protocols/linetext2.rb +161 -0
  88. data/lib/protocols/memcache.rb +293 -0
  89. data/lib/protocols/postgres.rb +261 -0
  90. data/lib/protocols/saslauth.rb +179 -0
  91. data/lib/protocols/smtpclient.rb +308 -0
  92. data/lib/protocols/smtpserver.rb +556 -0
  93. data/lib/protocols/stomp.rb +153 -0
  94. data/lib/protocols/tcptest.rb +57 -0
  95. data/tasks/cpp.rake +77 -0
  96. data/tasks/project.rake +78 -0
  97. data/tasks/tests.rake +193 -0
  98. data/tests/test_attach.rb +83 -0
  99. data/tests/test_basic.rb +231 -0
  100. data/tests/test_bind.rb +73 -0
  101. data/tests/test_connection_count.rb +35 -0
  102. data/tests/test_defer.rb +47 -0
  103. data/tests/test_epoll.rb +163 -0
  104. data/tests/test_error_handler.rb +32 -0
  105. data/tests/test_errors.rb +82 -0
  106. data/tests/test_eventables.rb +77 -0
  107. data/tests/test_exc.rb +58 -0
  108. data/tests/test_futures.rb +214 -0
  109. data/tests/test_handler_check.rb +37 -0
  110. data/tests/test_hc.rb +218 -0
  111. data/tests/test_httpclient.rb +215 -0
  112. data/tests/test_httpclient2.rb +155 -0
  113. data/tests/test_kb.rb +61 -0
  114. data/tests/test_ltp.rb +188 -0
  115. data/tests/test_ltp2.rb +320 -0
  116. data/tests/test_next_tick.rb +109 -0
  117. data/tests/test_processes.rb +56 -0
  118. data/tests/test_pure.rb +129 -0
  119. data/tests/test_running.rb +47 -0
  120. data/tests/test_sasl.rb +74 -0
  121. data/tests/test_send_file.rb +243 -0
  122. data/tests/test_servers.rb +80 -0
  123. data/tests/test_smtpclient.rb +83 -0
  124. data/tests/test_smtpserver.rb +93 -0
  125. data/tests/test_spawn.rb +329 -0
  126. data/tests/test_ssl_args.rb +68 -0
  127. data/tests/test_ssl_methods.rb +50 -0
  128. data/tests/test_timers.rb +148 -0
  129. data/tests/test_ud.rb +43 -0
  130. data/tests/testem.rb +31 -0
  131. metadata +230 -0
data/docs/README ADDED
@@ -0,0 +1,74 @@
1
+ $Id$
2
+
3
+ = RUBY/EventMachine
4
+
5
+ Homepage:: http://rubyeventmachine.com
6
+ Copyright:: (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
7
+ Email:: gmail address: garbagecat10
8
+
9
+ EventMachine is copyrighted free software made available under the terms
10
+ of either the GPL or Ruby's License. See the file COPYING for full licensing
11
+ information.
12
+ See EventMachine and EventMachine::Connection for documentation and
13
+ usage examples.
14
+
15
+ EventMachine implements a fast, single-threaded engine for arbitrary network
16
+ communications. It's extremely easy to use in Ruby. EventMachine wraps all
17
+ interactions with IP sockets, allowing programs to concentrate on the
18
+ implementation of network protocols. It can be used to create both network
19
+ servers and clients. To create a server or client, a Ruby program only needs
20
+ to specify the IP address and port, and provide a Module that implements the
21
+ communications protocol. Implementations of several standard network protocols
22
+ are provided with the package, primarily to serve as examples. The real goal
23
+ of EventMachine is to enable programs to easily interface with other programs
24
+ using TCP/IP, especially if custom protocols are required.
25
+
26
+ A Ruby program uses EventMachine by registering the addresses and ports of
27
+ network servers and clients, and then entering an event-handling loop.
28
+ EventMachine contains glue code in Ruby which will execute callbacks to
29
+ user-supplied code for all significant events occurring in the clients
30
+ and servers. These events include connection acceptance, startup, data-receipt,
31
+ shutdown, and timer events. Arbitrary processing can be performed by user code
32
+ during event callbacks, including sending data to one or more remote network
33
+ peers, startup and shutdown of network connections, and installation of new
34
+ event handlers.
35
+
36
+ The EventMachine implements a very familiar model for network programming.
37
+ It emphasizes: 1) the maximum possible isolation of user code from network
38
+ objects like sockets; 2) maximum performance and scalability; and 3) extreme
39
+ ease-of-use for user code. It attempts to provide a higher-level interface
40
+ than similar projects which expose a variety of low-level event-handling
41
+ and networking objects to Ruby programs.
42
+
43
+ The design and implementation of EventMachine grows out of nearly ten years
44
+ of experience writing high-performance, high-scaling network server applications.
45
+ We have taken particular account of the challenges and lessons described as
46
+ the "C10K problem" by Dan Kegel and others.
47
+
48
+ EventMachine consists of an extension library written in C++ (which can be
49
+ accessed from languages other than Ruby), and a Ruby module which can be dropped
50
+ into user programs. On most platforms, EventMachine uses the
51
+ <tt>select(2)</tt> system call,
52
+ so it will run on a large range of Unix-like systems and on Microsoft
53
+ Windows with good performance and scalability. On Linux 2.6 kernels, EventMachine
54
+ automatically configures itself to use <tt>epoll(4)</tt> instead of
55
+ <tt>select(2),</tt> so scalability on that platform can be significantly
56
+ improved.
57
+
58
+ Here's a fully-functional echo server written with EventMachine:
59
+
60
+ require 'rubygems'
61
+ require 'eventmachine'
62
+
63
+ module EchoServer
64
+ def receive_data data
65
+ send_data ">>>you sent: #{data}"
66
+ close_connection if data =~ /quit/i
67
+ end
68
+ end
69
+
70
+ EventMachine::run {
71
+ EventMachine::start_server "192.168.0.100", 8081, EchoServer
72
+ }
73
+
74
+
@@ -0,0 +1,96 @@
1
+ $Id$
2
+
3
+ RUBY/EventMachine RELEASE NOTES
4
+
5
+ --------------------------------------------------
6
+ Version: 0.9.0, released xxXXX07
7
+ Added Erlang-like distributed-computing features
8
+
9
+ --------------------------------------------------
10
+ Version: 0.8.0, released 23Jun07
11
+ Added an epoll implementation for Linux 2.6 kernels.
12
+ Added evented #popen.
13
+
14
+ --------------------------------------------------
15
+ Version: 0.7.3, released 22May07
16
+ Added a large variety of small features. See the ChangeLog.
17
+
18
+ --------------------------------------------------
19
+ Version: 0.7.1, released xxNov06
20
+ Added protocol handlers for line-oriented protocols.
21
+ Various bug fixes.
22
+
23
+ --------------------------------------------------
24
+ Version: 0.7.0, released 20Nov06
25
+ Added a fix in em.cpp/ConnectToServer to fix a fatal exception that
26
+ occurred in FreeBSD when connecting successfully to a remote server.
27
+
28
+ --------------------------------------------------
29
+ Version: 0.6.0, released xxJul06
30
+ Added deferred operations, suggested by Don Stocks, amillionhitpoints@yahoo.com.
31
+
32
+ --------------------------------------------------
33
+ Version: 0.5.4, released xxJun06
34
+ Added get_peername support for streams and datagrams.
35
+
36
+ --------------------------------------------------
37
+ Version: 0.5.3, released 17May06
38
+ Fixed bugs in extconf.rb, thanks to Daniel Harple, dharple@generalconsumption.org.
39
+ Added proper setup.rb and rake tasks, thanks to Austin Ziegler.
40
+ Fixed a handful of reported problems with builds on various platforms.
41
+
42
+ --------------------------------------------------
43
+ Version: 0.5.2, released 05May06
44
+ Made several nonvisible improvements to the Windows
45
+ implementation.
46
+ Added an exception-handling patch contributed by Jeff Rose, jeff@rosejn.net.
47
+ Added a dir-config patch contributed anonymously.
48
+ Supported builds on Solaris.
49
+
50
+ --------------------------------------------------
51
+ Version: 0.5.1, released 05May06
52
+ Made it possible to pass a Class rather than a Module
53
+ to a protocol handler.
54
+ Added Windows port.
55
+
56
+ --------------------------------------------------
57
+ Version: 0.5.0, released 30Apr06
58
+ Added a preliminary SSL/TLS extension. This will probably
59
+ change over the next few releases.
60
+
61
+ --------------------------------------------------
62
+ Version: 0.4.5, released 29Apr06
63
+ Changed ext files so the ruby.h is installed after unistd.h
64
+ otherwise it doesn't compile on gcc 4.1
65
+
66
+ --------------------------------------------------
67
+ Version: 0.4.2, released 19Apr06
68
+ Changed the Ruby-glue so the extension will play nicer
69
+ in the sandbox with Ruby threads.
70
+ Added an EventMachine::run_without_threads API to
71
+ switch off the thread-awareness for better performance
72
+ in programs that do not spin any Ruby threads.
73
+
74
+ --------------------------------------------------
75
+ Version: 0.4.1, released 15Apr06
76
+ Reworked the shared-object interface to make it easier to
77
+ use EventMachine from languages other than Ruby.
78
+
79
+ --------------------------------------------------
80
+ Version: 0.3.2, released 12Apr06
81
+ Added support for a user-supplied block in EventMachine#connect.
82
+
83
+ --------------------------------------------------
84
+ Version: 0.3.1, released 11Apr06
85
+ Fixed bug that prevented EventMachine from being run multiple
86
+ times in a single process.
87
+
88
+ --------------------------------------------------
89
+ Version: 0.3.0, released 10Apr06
90
+ Added method EventHandler::Connection::post_init
91
+
92
+ --------------------------------------------------
93
+ Version: 0.2.0, released 10Apr06
94
+ Added method EventHandler::stop
95
+
96
+
data/docs/SMTP ADDED
@@ -0,0 +1,9 @@
1
+ $Id$
2
+
3
+
4
+ [DOCUMENT UNDER CONSTRUCTION]
5
+
6
+ This note details the usage of EventMachine's built-in support for SMTP. EM supports both client and server connections, which will be described in separate sections.
7
+
8
+
9
+
@@ -0,0 +1,93 @@
1
+ $Id$
2
+
3
+ [DOCUMENT UNDER CONSTRUCTION]
4
+
5
+ EventMachine (EM) adds two different formalisms for lightweight concurrency to the Ruby programmer's toolbox: spawned processes and deferrables. This note will show you how to use spawned processes. For more information, see the separate document LIGHTWEIGHT_CONCURRENCY.
6
+
7
+
8
+ === What are Spawned Processes?
9
+
10
+ Spawned Processes in EventMachine are inspired directly by the "processes" found in the Erlang programming language. EM deliberately borrows much (but not all) of Erlang's terminology. However, EM's spawned processes differ from Erlang's in ways that reflect not only Ruby style, but also the fact that Ruby is not a functional language like Erlang.
11
+
12
+ Let's proceed with a complete, working code sample that we will analyze line by line. Here's an EM implementation of the "ping-pong" program that also appears in the Erlang tutorial:
13
+
14
+
15
+ require 'eventmachine'
16
+
17
+ EM.run {
18
+ pong = EM.spawn {|x, ping|
19
+ puts "Pong received #{x}"
20
+ ping.notify( x-1 )
21
+ }
22
+
23
+ ping = EM.spawn {|x|
24
+ if x > 0
25
+ puts "Pinging #{x}"
26
+ pong.notify x, self
27
+ else
28
+ EM.stop
29
+ end
30
+ }
31
+
32
+ ping.notify 3
33
+ }
34
+
35
+ If you run this program, you'll see the following output:
36
+
37
+ Pinging 3
38
+ Pong received 3
39
+ Pinging 2
40
+ Pong received 2
41
+ Pinging 1
42
+ Pong received 1
43
+
44
+ Let's take it step by step.
45
+
46
+ EventMachine#spawn works very much like the built-in function spawn in Erlang. It returns a reference to a Ruby object of class EventMachine::SpawnedProcess, which is actually a schedulable entity. In Erlang, the value returned from spawn is called a "process identifier" or "pid." But we'll refer to the Ruby object returned from EM#spawn simply as a "spawned process."
47
+
48
+ You pass a Ruby block with zero or more parameters to EventMachine#spawn. Like all Ruby blocks, this one is a closure, so it can refer to variables defined in the local context when you call EM#spawn.
49
+
50
+ However, the code block passed to EM#spawn does NOT execute immediately by default. Rather, it will execute only when the Spawned Object is "notified." In Erlang, this process is called "message passing," and is done with the operator !, but in Ruby it's done simply by calling the #notify method of a spawned-process object. The parameters you pass to #notify must match those defined in the block that was originally passed to EM#spawn.
51
+
52
+ When you call the #notify method of a spawned-process object, EM's reactor core will execute the code block originally passed to EM#spawn, at some point in the future. (#notify itself merely adds a notification to the object's message queue and ALWAYS returns immediately.)
53
+
54
+ When a SpawnedProcess object executes a notification, it does so in the context of the SpawnedProcess object itself. The notified code block can see local context from the point at which EM#spawn was called. However, the value of "self" inside the notified code block is a reference to the SpawnedProcesss object itself.
55
+
56
+ An EM spawned process is nothing more than a Ruby object with a message queue attached to it. You can have any number of spawned processes in your program without compromising scalability. You can notify a spawned process any number of times, and each notification will cause a "message" to be placed in the queue of the spawned process. Spawned processes with non-empty message queues are scheduled for execution automatically by the EM reactor. Spawned processes with no visible references are garbage-collected like any other Ruby object.
57
+
58
+ Back to our code sample:
59
+
60
+ pong = EM.spawn {|x, ping|
61
+ puts "Pong received #{x}"
62
+ ping.notify( x-1 )
63
+ }
64
+
65
+ This simply creates a spawned process and assigns it to the local variable pong. You can see that the spawned code block takes a numeric parameter and a reference to another spawned process. When pong is notified, it expects to receive arguments corresponding to these two parameters. It simply prints out the number it receives as the first argument. Then it notifies the spawned process referenced by the second argument, passing it the first argument minus 1.
66
+
67
+ And then the block ends, which is crucial because otherwise nothing else can run. (Remember that in LC, scheduled entities run to completion and are never preempted.)
68
+
69
+ On to the next bit of the code sample:
70
+
71
+ ping = EM.spawn {|x|
72
+ if x > 0
73
+ puts "Pinging #{x}"
74
+ pong.notify x, self
75
+ else
76
+ EM.stop
77
+ end
78
+ }
79
+
80
+ Here, we're spawning a process that takes a single (numeric) parameter. If the parameter is greater than zero, the block writes it to the console. It then notifies the spawned process referenced by the pong local variable, passing as arguments its number argument, and a reference to itself. The latter reference, as you saw above, is used by pong to send a return notification.
81
+
82
+ If the ping process receives a zero value, it will stop the reactor loop and end the program.
83
+
84
+ Now we've created a pair of spawned processes, but nothing else has happened. If we stop now, the program will spin in the EM reactor loop, doing nothing at all. Our spawned processes will never be scheduled for execution.
85
+
86
+ But look at the next line in the code sample:
87
+
88
+ ping.notify 3
89
+
90
+ This line gets the ping-pong ball rolling. We call ping's #notify method, passing the argument 3. This causes a message to be sent to the ping spawned process. The message contains the single argument, and it causes the EM reactor to schedule the ping process. And this in turn results in the execution of the Ruby code block passed to EM#spawn when ping was created. Everything else proceeds as a result of the messages that are subsequently passed to each other by the spawned processes.
91
+
92
+ [TODO, present the outbound network i/o use case, and clarify that spawned processes are interleaved with normal i/o operations and don't interfere with them at all. Also, blame Erlang for the confusing term "process"]
93
+
data/docs/TODO ADDED
@@ -0,0 +1,10 @@
1
+ $Id$
2
+
3
+ TODO List:
4
+
5
+ 12Aug06: Noticed by Don Stocks. A TCP connect-request that results
6
+ in a failed DNS resolution fires a fatal error back to user code.
7
+ Uuuuuugly. We should probably cause an unbind event to get fired
8
+ instead, and add some parameterization so the caller can detect
9
+ the nature of the failure.
10
+
data/ext/binder.cpp ADDED
@@ -0,0 +1,126 @@
1
+ /*****************************************************************************
2
+
3
+ $Id$
4
+
5
+ File: binder.cpp
6
+ Date: 07Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+ #include "project.h"
21
+
22
+ #define DEV_URANDOM "/dev/urandom"
23
+
24
+
25
+ map<string, Bindable_t*> Bindable_t::BindingBag;
26
+
27
+
28
+ /********************************
29
+ STATIC Bindable_t::CreateBinding
30
+ ********************************/
31
+
32
+ string Bindable_t::CreateBinding()
33
+ {
34
+ static int index = 0;
35
+ static string seed;
36
+
37
+ if ((index >= 1000000) || (seed.length() == 0)) {
38
+ #ifdef OS_UNIX
39
+ int fd = open (DEV_URANDOM, O_RDONLY);
40
+ if (fd < 0)
41
+ throw std::runtime_error ("No entropy device");
42
+
43
+ unsigned char u[16];
44
+ size_t r = read (fd, u, sizeof(u));
45
+ if (r < sizeof(u))
46
+ throw std::runtime_error ("Unable to read entropy device");
47
+
48
+ unsigned char *u1 = (unsigned char*)u;
49
+ char u2 [sizeof(u) * 2 + 1];
50
+
51
+ for (size_t i=0; i < sizeof(u); i++)
52
+ sprintf (u2 + (i * 2), "%02x", u1[i]);
53
+
54
+ seed = string (u2);
55
+ #endif
56
+
57
+
58
+ #ifdef OS_WIN32
59
+ UUID uuid;
60
+ UuidCreate (&uuid);
61
+ unsigned char *uuidstring = NULL;
62
+ UuidToString (&uuid, &uuidstring);
63
+ if (!uuidstring)
64
+ throw std::runtime_error ("Unable to read uuid");
65
+ seed = string ((const char*)uuidstring);
66
+
67
+ RpcStringFree (&uuidstring);
68
+ #endif
69
+
70
+ index = 0;
71
+
72
+
73
+ }
74
+
75
+ stringstream ss;
76
+ ss << seed << (++index);
77
+ return ss.str();
78
+ }
79
+
80
+
81
+ /*****************************
82
+ STATIC: Bindable_t::GetObject
83
+ *****************************/
84
+
85
+ Bindable_t *Bindable_t::GetObject (const char *binding)
86
+ {
87
+ string s (binding ? binding : "");
88
+ return GetObject (s);
89
+ }
90
+
91
+ /*****************************
92
+ STATIC: Bindable_t::GetObject
93
+ *****************************/
94
+
95
+ Bindable_t *Bindable_t::GetObject (const string &binding)
96
+ {
97
+ map<string, Bindable_t*>::const_iterator i = BindingBag.find (binding);
98
+ if (i != BindingBag.end())
99
+ return i->second;
100
+ else
101
+ return NULL;
102
+ }
103
+
104
+
105
+ /**********************
106
+ Bindable_t::Bindable_t
107
+ **********************/
108
+
109
+ Bindable_t::Bindable_t()
110
+ {
111
+ Binding = Bindable_t::CreateBinding();
112
+ BindingBag [Binding] = this;
113
+ }
114
+
115
+
116
+
117
+ /***********************
118
+ Bindable_t::~Bindable_t
119
+ ***********************/
120
+
121
+ Bindable_t::~Bindable_t()
122
+ {
123
+ BindingBag.erase (Binding);
124
+ }
125
+
126
+
data/ext/binder.h ADDED
@@ -0,0 +1,48 @@
1
+ /*****************************************************************************
2
+
3
+ $Id$
4
+
5
+ File: binder.h
6
+ Date: 07Apr06
7
+
8
+ Copyright (C) 2006-07 by Francis Cianfrocca. All Rights Reserved.
9
+ Gmail: blackhedd
10
+
11
+ This program is free software; you can redistribute it and/or modify
12
+ it under the terms of either: 1) the GNU General Public License
13
+ as published by the Free Software Foundation; either version 2 of the
14
+ License, or (at your option) any later version; or 2) Ruby's License.
15
+
16
+ See the file COPYING for complete licensing information.
17
+
18
+ *****************************************************************************/
19
+
20
+ #ifndef __ObjectBindings__H_
21
+ #define __ObjectBindings__H_
22
+
23
+
24
+ class Bindable_t
25
+ {
26
+ public:
27
+ static string CreateBinding();
28
+ static Bindable_t *GetObject (const string&);
29
+ static Bindable_t *GetObject (const char*);
30
+ static map<string, Bindable_t*> BindingBag;
31
+
32
+ public:
33
+ Bindable_t();
34
+ virtual ~Bindable_t();
35
+
36
+ const string &GetBinding() {return Binding;}
37
+ const char *GetBindingChars() {return Binding.c_str();}
38
+
39
+ private:
40
+ string Binding;
41
+ };
42
+
43
+
44
+
45
+
46
+
47
+ #endif // __ObjectBindings__H_
48
+