TAILIEUCHUNG - Creating Applications with Mozilla-Chapter 8. XPCOM- P2

Tham khảo tài liệu 'creating applications with mozilla-chapter 8. xpcom- p2', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 8. XPCOM- P2 . Root interfaces Queryinterface Addref and Release are required methods that are implemented by every component. Queryinterface matches a specific interface with its implementation class module. Addref and Release are methods used for reference counting. When an instance of a component is created one or more pointers may reference that object. For each reference a count is incremented by one. When a reference is no longer used Release is called to decrement the count. You must hold a reference count to ensure that no pointers reference an object after it is deleted. When pointers try to access objects that are deleted the application core dumps. Reference counting can get tricky which is why smart pointers manage Addref and Release for you as described in the later section Section . Defining Queryinterface Addref and Release every time an interface is created is clearly not very efficient. Instead these methods are defined in the base interface called nsISupports. All interfaces inherit from this mother of all interfaces and don t need to redefine these three basic functions. XPIDL supports the C style syntax preparser directive include to include other IDL files -- not unlike MSCOM which uses the import statement. At the top of any IDL file that you create you need to include nsISupports include interface nsISimple nsISupports readonly attribute string value Core IDL Types The core types used in IDL interface files are listed in the file xpcom base . This file is included in nsISupports. This means it is included in every interface file since all interfaces inherit from nsISupports. All interfaces used in a system are valid IDL types. For example nsISimple is a valid type to use as a method parameter or a method return type. Some of the main types listed in this interface are typedef boolean PRBool typedef octet PRUint8 typedef unsigned short PRUint16 typedef unsigned short PRUnichar typedef unsigned .

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.