How to implement a small "discussion" of the operational environment of the COM component under UNIX

xiaoxiao2021-03-06  69

This posting: How to implement a small "discussion" of the running environment of COM components under Unix

---- Welcome C , COM, UNIX master ----

As for how to implement the code, it is a very complex project. We don't talk about whether there is any existing project. We can refer to their approach, but don't make a careful investigation, this discussion focuses on the beginning of building such a COM operating environment. What do we need to do in UNIX?

In order to say, please, I will give this topic of this discussion: Comx

Standing: COMX features: 1 Do not consider the existing DLL2 below Windows does not need to be compatible with COM component specification 3 to implement a component binary excuse specification 4 written other C programs on UNIX, 1 can initialize the COM environment to call others COMX Component 2 can implement your own code into a COMX component

Hope to gather

Note: 1 This discussion will not last for a long time, around a weekend, because, do not want to take up much time. 2 Continue Thinking Will Bessorified Three Problem Solution Solution The number will be published in succession 4 and then hope that the final document will be organized into a COM other article with reference value.

Not a very detailed first step, the next post issued the continuing thinking based on this thinking, each with more continuing thinking, I will give the number, I am not able to check the premise without consulting the reference If you have questions, I will post the number "problem solving"

Thinking from here START HERE1 project submission form: libcomx.so2 UNIX C Customer code access method? #include // Initialization COMX Environment COMXRUNTIME COMRUNTIME; // Creating a COMX Component Object Instance Continue Thinking 1 Implementing Components Progid, GUID, IID This 丫 丫 om cTime.Newcombject ("lib.classname"); "lib.classname"); "lib.classname"); // Start using the COMX component object comObject-> shout (); // destroy the COMX component object, from here you can continue thinking 2 Implementing the application count This 丫 丫 omTime.Destroycomobject ("); // destroycomx (comRuntime); 3 Realize COM interface? Reflections: To implement the COM interface, it is said that the COMOBJECT this pointer to access the component in the annotation of 2, and the COMX running environment can find the physical location of the COMX component according to a progid (continue thinking 3: Location according to ProgID, Then dynamically load the memory), after the dynamic loads a SO file, find the relevant class according to ClassID (Problem 1: Is there a mechanism to support) binary code entry point, boot, then transfer to memory, return to COMX object The pointer, if such problems can be achieved smoothly, then the COMX interface can be implemented smoothly. The remaining problem is to use this pointer.

====================================

A post above produced some questions:

1 Continue thinking 1 Realize the component progid, guid, IID this is something

2 Continue thinking 2 to implement the application count this 丫

3 Continue Think 3: Find the .so according to PROGID, then dynamically load memory 4 problem solving 1: Is there a mechanism to support some objects, functions in dynamic loading dynamic libraries

Question solve your support, I hope to get some of your valuable suggestions and guidance, thank you

Thoughts on continuing thinking 1:

1 Implement component progid, guid, IID this is something

The program runs here in memory, discovers a string, then find a specific COMX database

The relevant dynamic library has previously registered information, such as an entry may be like this:

Progid = "adodb.connection"

Dllpath = "/ usr / lib / libadodb.so"

Other (continuing thinking 4: What information is needed) (Question Solving 2: What information is needed)

Leading questions: (continue thinking 5)

Registration method of the COMX component: use the regcomx utility so

Regcomx libadodb.so install

Regcomx libadodb.so uninstall

Continue to lead the problem: (continue thinking 6)

Libadodb.so files need to provide text information about binary class

When a suitable entry is found in the database, you can load the binary COMX object smoothly, and smooth

Return pointer. This problem is solved.

=========================================

Continue to think 2 to implement the application count this 丫

I think, implementing the reference count is to let the COMX run environment yourself to uninstall the COMX Binary object that is no longer used in memory.

If each COMX customer is willing to destroy the object itself, such as (Delete Comobject;), or our COMX run

The environment will not intend to achieve this feature, I think it is not necessary to implement the reference count, but since it is discussed here,

Taking this question, there is of course a special paragraph to give a way to think about the function of continuing to expand COMX.

The primer (called the primary is because I have already understood these problems, and it is not prepared to truly implement such a system, so

I probably not much may continue to write)

First, define an int variable: refcount (enough, our COMX server object is not possible in the memory

More than Maxint's customer access), (thinking to modify 1: COMX running environment should only have one entity in memory, others

COMX customers must pass a pointer to access the same operating environment, I have no good explanation of this problem in front of the code)

, COMX running the environment, counts a COMX server object for the customer's request, if there is no object in memory

Entity, go to the SO file, if you already have, Refcount , if the customer no longer uses this object

(Closed Thinking 1 Do not think about closed thinking, to this point, how to find customers no longer apply to objects),

Refcount ==, if 0, destroy this object.refcount should be implemented by the COMX server, why? COMX running the environment to save this variable too much?

Problem

Continue Think 3: Find. So location according to ProgID, then dynamically load memory

Continue to think about this problem with this problem, how to determine this in a SO file containing this

An interface (continue thinking about 7: queryinterface), and this queryinterface function should be best

The COMX server is provided, and if each COMX server class provides the queryinterface method, then must be in any

A SO file contains a QueryInterface code in a SO file (supporting COMX), returning to whether to implement COMX in this SO

The interface (interface and implementation interface of the operating environment) (interface and implementation of the interface are confused here, it seems to be one

The side focus of COMX is to reuse the binary code, not inheritance, etc., you can use the polymerization method to reuse the code, completely abandon

Inherited method Reusal code) (continue thinking 8: A SO contains several Class binary code, implement the COMX server,

Or you need other ways to let QueryInterface functions know the location of a class, return a pointer, if Class

Not in this SO, you need to provide a mechanism for continuing search), there is a return pointer (of course, there will be a pointer after memory),

No failure information is returned, everything is over. (Continue thinking 9: What is the QueryinterFace? Class is

The offset in the file? ). After the customer gets a pointer, you can access the code contained in that memory.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Continue thinking 4: What information still needs to be saved

Continue to think 5: libadodb.so provides information on the regcomx program

Continue thinking about 6: libadodb.so files need to provide relevant binary text information

Continue to think 7: QueryInterface is born

Continue thinking 8: One SO contains several Class binary code, implement the program of the COMX server,

Or you need other ways to let Queryinterface functions know the location of a class,

Returns the pointer, if the class is not in this SO, you need to provide a mechanism for continuing search.

Continue to think 9: What is the return in the QueryinterFace? Offset in the file in the file

Thinking to modify 1: The COMX running environment should only have an entity in memory, and other COMX customers must pass one.

Pointer Access the same operating environment, my previous code is not a good description of this problem

Question Solving 2: What information is needed?

Closed Thinking 1 Do not think about closed thinking, to this point, how to find customers no longer apply to objects

转载请注明原文地址:https://www.9cbs.com/read-91963.html

New Post(0)