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

Tham khảo tài liệu 'creating applications with mozilla-chapter 8. xpcom- p4', 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- P4 As you can see the macro is made up of other macros that implement basic methods of the nsISupports interface. Unless you need to modify these macros they should be left as is. This macro is used later on when we create our C component. Example 8-6 shows a reference implementation of the Queryinterface method in C . Example 8-6. Reference implementation of Queryinterface NS_IMETHODIMP nsMyImplementation QueryInterface REFNSIID aIID void aInstancePtr NS_ASSERTION aInstancePtr QueryInterface requires a non-NULL destination if aInstancePtr return NS_ERROR_NULL_POINTER nsISupports foundInterface if nsCOMTypeInfo nsIX GetIID foundInterface NS_STATIC_CAST nsIX this else if nsCOMTypeInfo nsIY GetIID foundInterface NS_STATIC_CAST nsIY this else if nsCOMTypeInfo nsISupports GetIID foundInterface NS_STATIC_CAST nsISupports NS_STATIC_CAST nsIX this else foundInterface 0 nsresult status if foundInterface status NS_NOINTERFACE else NS_ADDREF foundInterface status NS_OK aInstancePtr foundInterface return status . The results macros Since all XPCOM methods return result codes called nsresults another useful macro is the NSSUCCEEDED macro. This indicates whether an XPCOM accessor has returned a successful result. It is defined in define NS_SUCCEEDED _nsresult _nsresult 0x80000000 A related macro NS_FAILED is indicates whether an XPCOM accessor returned a failure code result. It too is defined in . The following code demonstrates the typical use of these two macros nsresult rv nsCOMPtr nsILocalFile file do_CreateInstance @ file local 1 rv if NS_FAILED rv printf FAILED n return rv if NS_SUCCEEDED rv printf SUCCEEDED n return rv You may have noticed that the declaration of the identifier rv as the type nsresult. nsresult is a 32-bit unsigned integer declared in typedef PRUint32 nsresult

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.