Click here to Skip to main content
15,887,746 members
Articles / All Topics

Multi-Language Programming : Common Object’s Event_6

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
1 Nov 2011CPOL2 min read 4.2K   1  
Multi-language programming: Common object's Event_6

Object may generate or handle events. This feature should continue to be supported in common object environment. Event is not an entity. It is a set of information. If the event information is described by special language, then it cannot be triggered or handled by other languages. Therefore, environment should present a common model to describe events and provide a dispatcher to schedule these events. 

In the environment, event may be identified by UUID or name. UUID uniquely corresponds to an event. Different languages can use interface of environment to find the event defined, and then trigger the event. Event may also have parameters or have response results from the handler. These parameters should be converted by the environment when passed to different languages.

Common object environment should support to define object’s event and event handler. Object’s event may be handled by itself. For example, we click button, trigger a click event, then the button’s click function is called to process the event. Object’s event may also be handled by other objects. These objects can register handler function to capture events interested. These two kinds of event handling methods should be supported.

Using UUID to identify an event enables events defined in one language to be found or triggered by other defined languages. For events, environment is responsible for parameter conversion between different languages, and dispatching event to objects which may be defined by different languages.

In the above figure, Click event and its handler are defined for class object of Java. If a C/C++ module needs to trigger the event, it finds the event first. Then it triggers “OnClick” event. Event dispatcher is responsible for routing the event to correct handler, which will call OnClick_Handler of Java. The handler returns results. The dispatcher translates results to C/C++ language format, and then return the results to C/C++ module.

Summary

Common object environment supports defining object attributes, functions, and events. It also supports function overloading, event dispatching, and parameters/arguments conversion between different languages. It is an object-oriented runtime environment.

This article was originally posted at http://blog.yahoo.com/srplab/articles/86478

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --