Creating Applications with Mozilla XPCOM

Creating Applications With Mozilla.pdf Mozilla firefox xpcom xul xulrunner gecko sdk 立即下载

Chapter 8. XPCOM

This chapter provides ahigh-levelintroduction to XPCOM component technology. XPCOM can be difficult tomaster, but after reading this chapter, you should have a good senseof what it is and the important part it plays asMozilla's core technology. You should be able tofind and use existing scriptable components in your own applicationsand create a simple XPCOM component by using JavaScript or C++.

XPCOM permits a reusable code module to be globally accessible to aMozilla-based application. You do not need to worry about includingexternal source files in your application distribution and you candistribute components by using XPInstall. This type of architecturemakes the development of core application services flexible andentirely modular.

The section Section 8.2.1 lets youcreate an interface from start to finish -- writing theimplementation for that interface, compiling it into a type library,registering it with Mozilla, and then testing the new component. Oneadvantage of using XPCOM is that you can create multipleimplementations for a single interface; following the JavaScriptcomponent section, we will take the same nsISimpleinterface and implement it in C++ as well.

The section Section 8.2.5 includessome techniques and programming tasks that are particular to C++components, such as handling return values and generating headerfiles and useful macros. The section Section 8.2.7 introduces the XPCOMbindingsforthe Python language (pyXPCOM). First, it provides an overview ofXPCOM and how it relates to other technologies used in Mozilla.

8.1. What Is XPCOM?

XPCOM is Mozilla's cross-platform component objectmodel. Although it is similar to Microsoft's COMtechnology, this chapter points out some important differences.

Essentially, when you program in a component-based environment, youdo one of three things: you create a new component using existingcomponents, write a component that implements other components, andestablish interdependencies and a service network.

8.1.1. What Is a Component?

You've already seen components used in thisbook.In some cases, you may have used the services of Mozilla componentswithout knowing it -- for example, when you created a XUL treewidget in the section Section 3.4.2in Chapter 3, and used its built-in layout andview capabilities. Some of this functionality is defined in aninterface called nsITreeView, which providesspecific methods and properties for a XUL tree, persisting its state,row, cell, and column properties, navigation, and other objectmetadata used in a tree object. Behind the scenes,you'll find an XPCOM-instantiated tree view objectwhere methods and properties associated with the XUL element areaccessed via DOM > JavaScript >XPConnect > XPCOM layers.

A component is a reusable or modular piece of code that implements aclearly defined interface. In Mozilla, this code can exist as asingleton service or an object instance. A singleton service is anobject instance that is created only once and then used by other code(usually called "callers,""clients," or"consumers"). An object instance isan object that is instantiated once or many times. Components arewritten as classes that typically have member variables and methods.The basic purpose of a component is to implement a clearly definedset of APIs that exist in a public interface. The interface existsseparately so that the implementation is abstracted away, and it canbe changed without affecting the interface or breaking binarycompatibility. When interfaces are deployed in a productionenvironment, they are frozen, which means they are held in animmutable state -- theoretically for as long as the applicationexists. While MSCOM provides a component-based programming model onMicrosoft platforms, XPCOM provides it on all platforms where Mozillais available.

Example 8-1 shows how simpleusing XPCOM components can be.In two lines, an XPConnect-wrappednsIBookmarksService object is instantiated, andone of its methods is called, providing easy access to this XPCOMcomponent from JavaScript.

Example 8-1. Using an XPCOM object in script

// create a bookmark service object in JS
var bmks = 
  Components.classes["@mozilla.org/browser/bookmarks-service;1"].
      getService(Components.interfaces.nsIBookmarksService);
// call one of the object's methods:
// flush the bookmarks to disk if they've been touched.
bmks.Flush( );

As you can see, the assignment of an XPCOM object to the variablebmks takes only a single line. Once you arecomfortable using XPCOM from JavaScript, you can use any ofMozilla's scriptable interfaces in your application.Once an object like bmks is created, as in Example 8-1, it can be used to call any method in thensIBookmarksService interface, of whichFlush( ) is an example.

8.1.2. XPConnect and the Component Object

As shown the previous example, the XPCOM object is called andinstantiated from script. For an interpreted language like JavaScriptto call and instantiate it, a bridge must bind JavaScript types toXPCOM types. These type bindings are part of a technology calledXPConnect.

In XPConnect, XPCOM interfaces, classIDs, andprogIDs are stored as global JavaScript objectsand properties that can be manipulated directly through a top-levelobject called Components. This object accesses any component that is declared"scriptable" in an XPCOM IDLinterface. Through the Components object, you canaccess and use the services that these interfaces provide. TheComponent object's top-levelproperties and methods include:

QueryInterface

A method used to match an interface with a desired implementation.The implementation can be in C, C++, JavaScript, Python, and otherlanguages for which appropriate bindings are created. You can havemultiple implementations for an interface. ThroughQueryInterface, you can ask for and assign thedesired interface to its implementation. Each XPCOM object needs toimplement QueryInterface in order to return aninstance of that object's class:

js> var clz  = Components.classes['@mozilla.org/file/local;1'];
js> var inst = clz.getService( );
js> inst.QueryInterface(C.interfaces.nsILocalFile);
[xpconnect wrapped nsILocalFile @ 0x81b7040]
interfaces

A read-only object arraycontainingall the interfaces declared scriptable in the IDL file. The objectname has the same name as the interface it represents.

Components.interfaces.nsILocalFile

The source file for this particular interface, for example, isnsILocalFile.idl. This XPIDL compiler compilesthis file to produce a cross-platform binary type library,nsILocalFile.xpt, which contains tokenized IDLin an efficiently parsed form.

classes

A read-only array of all the XPCOMcomponent classes indexed by the ProgID (orhuman-readable name) of the component class. Theclasses object has these properties associatedwith it:

toString       Returns the string progID.           
QueryInterface Used to QI this interface.           
name           Returns the string progid name.      
number         Returns the string components uuid   
               number.                              
valid          Boolean verifies if the instance is  
               valid.                               
equals         The Boolean used to match identical  
               instances.                           
initialize     I don't know what this does.         
createInstance Will create an instance of the       
               component; you can have many         
               instances.                           
getService     Will instantiate the component as a  
               service; you can have only one       
               instance of a service.               
classesByID

The same as classes, except this time the array is indexed by the"canonical" or"well-established" form of theirCLSID:

Components.classesByID['{dea98e50-1dd1-11b2-9344-8902b4805a2e}'];

The classesByID object has the same propertiesobject associated with it as the class object. Theproperties are also used in the same way:

toString
QueryInterface
name
number
valid
equals
initialize
createInstance
getService
stack

A read-only property that represents a snapshot of the currentJavaScript call stack. JavaScript handles each code interpretationone call at a time and then places that code onto a call stack. Thisproperty can be used for recondite diagnostic purposes:

js> var C=Components;
js> C.stack;
JS frame :: typein :: <TOP_LEVEL> :: line 2
js>  C.stack;
JS frame :: typein :: <TOP_LEVEL> :: line 3
results

An object array ofnserror results:

 Components.results.NS_ERROR_FILE_ACCESS_DENIED;
  2152857621
manager

A reflection of the XPCOM global native component manager service.Using the component manager is the only way for a component to actuallybe created. It uses the components factory to create an instance ofthe class object.

ID

A constructor used for a componentwritten in JavaScript This component needs to register itself withthe component manager by using its own nsID (an IDthat is not already registered and thus does not appear inComponents.classes).

Exception

A JavaScript constructor used tocreate exception objects. When implementing XPCOM interfaces inJavaScript, these exception objects are the preferred types ofexceptions. When an XPCOM exception is thrown in your JS code, ittakes the form of an Exception object that hasproperties associated with this object. Exceptions are usually caughtin a "catch" block.

Constructor

A JavaScript constructor object that constructs new instances ofXPCOM components:

js> var File=new Components.Constructor(
  "@mozilla.org/file/local;1", "nsILocalFile", "initWithPath");

The interface nsILocalFile and the methodinitWithPath are optional. This example createsand initializes the nsILocalFile component.

isSucessCode

A function that determines if the results code argument issuccessful. It takes an argument of nsresult andreturns the Boolean values true or false:

js> Components.isSuccessCode(Components.results.NS_OK);
  true
js> Components.isSuccessCode(Components.results.NS_ERROR_FAILURE);
  false

The methods and properties of the Componentsobject listed above provide the only means to instantiate and accessXPCOM objects from JavaScript. They are found often in the Mozillacodebase. In the sections that follow, they will be used frequently.

8.1.3. XPCOM Interfaces and the IDL

All XPCOM interfaces are definedwith the Interface Definition Language(IDL). IDL provides a language-neutral way to describe the publicmethods and properties of a component. Mozilla actually uses amodified, cross-platform version of IDL called XPIDL to compileinterface source files.

The separation of interface and implementation is a key distinctionof COM programming. If the application programming interface (API) isabstracted from the implementation language and then frozen,consumers of that API will receive a guaranteed, established contractwith the interface that ensures it will not be changed. This isperhaps the main reason why COM was invented: to maintaincompatibility on a binary level so the client code can find and usethe library it needs without worrying about linking to it. To makethis sort of modularity possible at runtime, IDL interfaces arecompiled into binary files called type libraries, which are describedlater in the section Section 8.1.4.

8.1.3.1. Interfaces versus components

It is important to understand thatmost XPCOM components implement at leasttwo interfaces. Like COM, each component needs theQueryInterface, AddRef, andRelease functions to be available as an XPCOM object. These methodsare derived from a basic interface callednsISupports, which isthe XPCOM equivalent to MicrosoftCOM's IUnknown, shown in Table 8-1.

Table 8-1. The IUnknown interface

Name

Type

Description

Parameters / return value

AddRef

ULONG AddRef(void)

Increments the reference count on the COM object.

Returns:

int, which is the new incremented reference count on the object. Thisvalue may be useful for diagnostics or testing.

QueryInterface

HRESULT QueryInterface(/* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject)

Retrieves a pointer to the requested interface.

Parameters:

iid, which is an [in] identifier of the requested interface.

ppvObject, which is an [out] pointer to the interface pointeridentified by iid. If the object does not support this interface,ppvObject is set to NULL.

Returns:

HRESULT, which is the standard HRESULT value.

Release

ULONG Release(void)

Decrements the reference count on the COM object.

Returns:

int, which is the new decremented reference count on the object. Thisvalue may be useful for diagnostics or testing.

Tables 8-1 and 8-2 illustrate the minor differences betweenMicrosoft's nsIUnknown andMozilla's nsISupports rootinterfaces. The usage is covered in detail throughout this chapter.

Table 8-2. The nsISupports interface

Name

Type

Description

Parameters / return value

AddRef

NS_IMETHOD_(nsrefcnt)

AddRef(void)

Increases the reference count for this interface.

The associated instance will not be deleted unless the referencecount is returned to zero.

Returns:

The resulting reference count.

QueryInterface

NS_IMETHOD QueryInterface(REFNSIID aIID, void**aInstancePtr)

A runtime mechanism for interface discovery.

Parameters:

param aIID [in], which is a requested interface IID.

param aInstancePtr [out], which is a pointer to an interface pointerthat receives the result.

Returns:

NS_OK if the interface is supported by the associated instance;NS_NOINTERFACE if it is not; and NS_ERROR_INVALID_POINTER ifaInstancePtr is NULL.

Release

NS_IMETHOD_(nsrefcnt) Release(void) = 0;

Decreases the reference count for this interface. Generally, if thereference count returns to zero, the associated instance is deleted.

Returns:

The resulting reference count.

8.1.3.2. Root interfaces

QueryInterface, Addref, andRelease are required methods that are implemented byevery component. QueryInterface matches a specificinterface with its implementation class module.Addref and Release are methodsused for reference counting. When an instance of a component iscreated, one or more pointers may reference that object. For eachreference, a count is incremented by one. When a reference is nolonger used, Release is called to decrement thecount. You must hold a reference count to ensure that no pointersreference an object after it is deleted. When pointers try to accessobjects that are deleted, the application core dumps. Referencecounting can get tricky, which is why smart pointers manageAddref and Release for you, asdescribed in the later section Section 8.2.4.

Defining QueryInterface,Addref, and Release every timean interface is created is clearly not very efficient. Instead, thesemethods are defined in the base interface callednsISupports. All interfaces inherit from thismother of all interfaces and don't need to redefinethese three basic functions.

XPIDL supports the C style syntax preparser directive#include to include other IDL files -- notunlike MSCOM, which uses the import statement. At the top of any IDLfile that you create, you need to includensISupports:

#include "nsISupports.idl"
interface nsISimple : nsISupports {
  readonly attribute string value; 
};

8.1.3.3. The XPIDL compiler

An IDL compiler is a tool thatcreates a binary distribution filecalled a type library from an interfacedescription source file. Since support for many different platformsis a requirement for Mozilla, a modified version of the libIDLcompiler from the Gnome project is used. This variant is called theXPIDL compiler and is primarily used to compileMozilla's own dialect of IDL, conveniently calledXPIDL. The XPIDL compiler generates XPCOM interface information,headers for XPCOM objects, and XPT type libraries from which objectsmay be accessed dynamically through XPConnect. It can also generateHTML files for documentation and Java class stubs. Another feature ofthe XPIDL compiler is the option to generate C++ code stubs. Thisfeature creates nearly all the declaratory C++ code you need when youstart a new project, which makes XPIDL useful as a coding wizard thathelps you get started. Code generation is covered later in thischapter in the section Section 8.2.5.

The XPIDL compiler is located inxpcom/typelib/xpidl/ in the Mozilla sources. Ifyou built Mozilla, you can add this directory to yourPATH:

$ PATH=$PATH:/usr/src/mozilla/xpcom/typelib/xpidl

Using the compiler is fairly easy. If you use the help command, youcan see the usage syntax and other basic information about thecompiler:

$ ./xpidl --help
Usage: xpidl [-m mode] [-w] [-v] [-I path] [-o basename] filename.idl
       -a emit annotations to typelib
       -w turn on warnings (recommended)
       -v verbose mode (NYI)
       -I add entry to start of include path for ``#include "nsIThing.idl"''
       -o use basename (e.g. ``/tmp/nsIThing'') for output
       -m specify output mode:
          header        Generate C++ header            (.h)
          typelib       Generate XPConnect typelib     (.xpt)
          doc           Generate HTML documentation    (.html)
          java          Generate Java interface        (.java)

8.1.4. XPCOM Type Libraries

The key to the component architecture of XPCOM is the presence ofbinary-independent interface files that are used uniformly acrossplatforms, languages, and programming environments. These interfacefiles are compiled into .xpt files by the XPIDLcompiler. The Mozilla components subdirectory iswhere type libraries and modules are typically stored. If you createa cross-platform type library for your component, you must place itin this directory for it to be accessible to XPCOM.

8.1.4.1. Creating a type library file from an IDL interface

To create a (.xpt) typelib file, usethe flag -mtypelib with warning (-w) and verbose(-v) modes turned on. -o isused for the name of the output file and -I isused to specify paths to other IDL files you want to include. Tosuccessfully compile your interface, you must always point to thedirectory where nsISupports is located.

# include path to nsISupports.idl
$ $XPIDL_INC = /usr/src/mozilla/xpcom/base
#compile nsISimple.idl 
$ xpidl -m typelib -w -v -I $XPIDL_INC \
> -o nsISimple nsISimple.idl

The file created after compilation isnsISimple.xpt. It provides the necessary typeinformation about your interface at runtime. Typelib files enumeratethe methods of interfaces and provide detailed type information foreach method parameter.

8.1.5. XPCOM Identifiers

To simplify the process ofdynamicallyfinding, loading, and binding interfaces, all classes and interfacesare assigned IDs. An ID is a unique 128-bit number that is based onuniversally unique identifiers (UUIDs) generated byvarious toolssuch as uuidgen (which we will cover later inthis chapter). They are stored in the structure format defined below:

struct nsID {
  PRUint32 m0;
  PRUint16 m1, m2;
  PRUint8 m3[8];
};

To initialize an ID struct, declare it like this:

ID = {0x221ffe10, 0xae3c, 0x11d1,
       {0xb6, 0x6c, 0x00, 0x80, 0x5f, 0x8a, 0x26, 0x76}};

One thing that gives XPCOM its modularity is the dynamic allocationof objects through the use of unique identifiers at runtime. Thissystem of canonical identifiers is used for interface querying andcomponent instantiation. Having an interface is important because itensures that an immutable binary holds a semantic contract definedfor a specific interface class.

The two types of identifiers used in XPCOM are the contract ID andthe class identifier. These identifiers are shuttled to the ComponentManager's createInstance( ) orthe Service Manager's getService() methods in order to instantiate a component.

8.1.5.1. The Contract ID

The program ID (progID), also knownas the Contract ID, is a uniquehuman-readable string. Example 8-2 shows variousprogIDs for different components. This example canbe used to instantiate an XPCOM component through the use of aContract ID.

Example 8-2. progIDs

// progID: @mozilla.org/file/local;1
var f = Components.classes[`@mozilla.org/file/local;1'];
// progID: @mozilla.org/browser/bookmarks-service;1
var bmks = 
  Components.classes["@mozilla.org/browser/bookmarks-service;1"].
      getService(Components.interfaces.nsIBookmarksService);

8.1.5.2. The class identifier

The other type of identifier is theclassID,or CLSID. The interface and implementation are identified by this128-bit numerical identifier string:

// clsid: {2e23e220-60be-11d3-8c4a-000064657374}
var f = Components.classesByID["{2e23e220-60be-11d3-8c4a-000064657374}"];

Using XPConnect, XPCOM interfaces,classIDs, andprogIDs are stored as global JavaScript objectsand properties and can be manipulated directly through the top-levelComponents object discussed earlier.

8.1.5.3. Generating identifiers

To obtain a UUID on Unix, you canusea command-lineprogram called uuidgen that generates a uniquenumber for you:

$ uuidgen 
ce32e3ff-36f8-425f-94be-d85b26e634ee

On Windows, a program called guidgen.exe doesthe same thing and also provides agraphical user interface if you'd rather point andclick.

Or you can use one of the special"bots" on IRC at theirc.mozilla.org server.

irc irc.mozilla.org
/join #mozilla
/msg mozbot uuid

This command makes the bot generate and return a uuid, which you canthen copy into your component source code. The information can thenbe used to uniquely identify your component.

8.1.6. Component Manager

One major goal of XPCOM modularizationis the removal of link-time dependencies,or dependencies that arise when you link libraries duringcompilation. The achievement of this goal allows you to access anduse modules at runtime. The trouble then becomes finding thosemodules and figuring out which of their interfaces you want to use.This problem is solved through the use of the Component Manager.

The Component Manager is a special set of component managementclasses and implementation classes that reside in object libraries(.dll, .so,.js, .py, etc.). Theseclasses also include factories, which let youcreate objects without having access to their class declarations.When you bind to objects at runtime, as you do in XPCOM, you needfunctionality like this to help you discover and use objects withoutlooking at their code. The Component Manageralso includes the Component Manager classitself, known as nsComponentManager, which is amapping of class IDs to factories for the libraries they contain. TheComponent Manager is responsible for the autoregistration of all newor add-on modules locatedin the components directory. Thisautoregistration happens behind the scenes and allows you to use newcomponents as they become available without having to register themyourself.

A component author first creates an interface file thatdefines all APIs that will be publicly available for a component. Thecomponent author then creates an implementation for the methods andattributes in a separate implementation class. For example, annsILocalFile interface may have annsLocalFile implementation class. Then a factoryor module is needed to abstract the implementation class, and reducecompile and link-time dependencies. It then creates instances of theimplementation class through its own implementation ofQueryInterface. For example:

// create an instance of the implementation class 
var f = Components.classes[`@mozilla.org/file/local;1'].createInstance( );

The variable f is assigned an instance of ansLocalFile implementation class using thensIFactory method createInstance(). To match the correct interface(nsILocalFile in this case) to theimplementation, you need a class instance to be created before youcan call on its member method QueryInterface( ):

// QI for nsILocalFile interface
var f = f.QueryInterface(Components.interfaces.nsILocalFile);

Once you do this, the variable f is ready to usethe nsILocalFile interface to access the newlycreated instance of the nsLocalFile class fromscript.

Simply put, a factory or module is a set of classes used by theComponent Manager to register and create an instance of thecomponent's implementation class. A factory can makeits way into the Mozilla component repository in several ways. Themost direct is through using the Component Manager methodRegisterFactory( ), which supports two differentregistration mechanisms. The first mechanism, which takes a class IDand a pointer to a factory, can be used on factories that areactually linked into the executable. The second, which takes a classID and the path to a dynamically loadable library, can be used bothinside an executable at runtime and externally by using theaPersist flag to tell the repository to store theclass ID/library relationship in its permanent store. The ComponentManager discovers new factories or modules placed in thecomponents directory and queries those modulesfor the XPCOM components they provide. The name, contract IDs, andclass IDs are placed into a small component registry database forquick retrieval. The factory provides this information through asimple set of APIs required by every XPCOM module. Module creation,covered later in this chapter, describes the process through whichall components contain an implementation of a module or factory.

8.1.7. Getting and Using XPCOM

Mozilla is a client application that implements XPCOM, so everythingyou need to use or build new XPCOM components is already included inthe source code and/or the binaries. Whenever you use the JavaScriptComponents object, as described earlier, you useXPCOM.

If you'd rather not build the entire Mozilla browserand you have no interest in existing Mozilla components or the largefootprint that comes with an entire distribution, then standaloneXPCOM is for you. Topullthe XPCOM source on Unix using Mac OS X orcygwin on Windows, invoke the followingcommands:

cvs -z 3 co mozilla/client.mk
cd mozilla
gmake -f client.mk pull_all BUILD_MODULES=xpcom

To build the XPCOM Stand Alone version, type:

configure --enable-modules=xpcom
gmake

When you buildstandaloneXPCOM, the directory xpcom/sample contains thesource code for a sample application and ansTestSample component. The sample applicationbuilt from these sources, also callednsTestSample, is installed in the Mozillabin directory. libsample.so(Unix), which is the component that the sample application tries toinstantiate, should have been installed inbin/components. To run the test that indicateswhether standalone XPCOM is installed successfully, change to themozilla/dist/bin directory and run the followingcommands:

./run-mozilla.sh ./nsTestSample

You should see the following output. If you do not, there is aproblem with the installation of standalone XPCOM:

Type Manifest File: /D/STAND_ALONE_XPCOM/mozilla/dist/bin/components/xpti.dat
nsNativeComponentLoader: autoregistering begins.
nsNativeComponentLoader: autoregistering succeeded
nNCL: registering deferred (0)
Inital print: initial value
Set value to: XPCOM defies gravity
Final print : XPCOM defies gravity
Test passed.

Using standalone XPCOM is a powerful way to use the Mozilla frameworkof cross-platform COM. Even if you're just hackingon Mozilla, standalone XPCOM is a great way to learn about and useXPCOM for application development.

【UG/NX二次开发】记录在二次开发中遇到的坑 阅读详情

相关推荐

【AutoDL + Langchain-Chatchat】从零构建高效本地 RAG 知识库问答系统:实战保姆级教程(含避坑指南)

本文详细阐述如何在AutoDL云平台,如何利用Langchain-Chatchat构建高效的本地RAG知识库问答系统,并深入解析RAG架构。从环境搭建到实战部署,从问题排查到性能优化,提供一份全面实用的指南,助力开发者快速构建智能问答应用。

拾光夕拾的博客 1812

绝大多数新技术的学习,都是浪费生命

很多程序员,在很多的时间,都会说出很多相同的话来,其中最为引起共鸣的就是这么一句话:“每天都要学习新知识,不然就会被淘汰”。 嗯,这真是件很辛苦的事情,你看,老中医就过得很轻松,收银员也过得很轻松,官员当然过得更轻松。没别的,绝大多数正常的人类,学会一种技能,则无需进一步学习其他的,大致上就能够或轻松或艰难的生活下去。这个所谓绝大多数,应该是90%。 那么,程序...

weixin_30835923的博客 182

zabbix6.0.4拓扑图链路显示流量

1. 背景介绍 网络流量监控是网络管理员必备功课,以前研究cacti的weathermap插件,网络流量大小和拥塞情况一清二楚,随着cacti的没落,weathermap插件也不能再继续使用,此时就需要学习了解新的替代方案。 经过研究和实际测试,发现zabbix的拓扑图有这个功能。 以下验证了zabbix的拓扑图显示线路流量的功能。 2. Zabbix 6显示拓扑图流量过程 选择监测-拓扑图 点进Local ne...

u013930899的博客 8500

C#动态执行代码(改编)

<br />http://www.cnblogs.com/zlinke/archive/2011/01/28/1946785.html<br /> <br />/* 初学C#,好多概念不太清晰,手头项目需要用到动态代码执行,网上搜了一堆,觉得下面这个比较合我用,就拿过来改了一下. <br />本来还应该加上代码正确性检测的(目前的情况是,如果动态代码有错误,实际反映出来的错误信息有可能是"未能加载程序或文件集....或它的某一个依赖项,系统找不到指定的文件", 结果造成被误导了,汗.)<br />先凑合着用

gahetgidt的专栏 628

激光器安规详细解读 - 一级 - 并以940波长为例

前言: 作为人工智能的重要解决方案,激光作为不可或缺的一个选项。但是,激光的安规问题始终是要得到关注。尤其是3D识别技术在人脸上的使用的时候,如何判读激光器的安全使用规范,变得非常重要。本文,尝试从欧洲激光标准IEC 60825-1:2014,以及国家激光产品规则标准GB 7247.1,抛砖引玉,写出自己的理解。 本节,主要讨论,人脸识别需要符合的安全等级1: 1 激光标准的分类 激光国际...

山云的专栏 5042

linux系统宝塔服务器temp文件夹里总是被上传病毒php脚本

服务器时不时的会发送短信说你服务器有病毒,找到了这个tmp文件,删除了之后又有了。确实是有很多人就这么无聊,每天都攻击你的服务器。找了很久的原因,网上也提供了一大堆方法,但都是很简陋的答案,具体怎么操作并没有说。没办法只能自己去排查这个问题。从两个角度来考虑,第一是服务器系统问题,比如宝塔的漏洞。但一时半会看不出问题来。只能去排查自己的项目代码。最后了解到代码确实是存在漏洞的。但代码中也确实了很多的校验,为什么会存在漏洞了?这就不得不从上传的过程开始说起。

guiplan 1499

Mozilla XPCOM组件开发常见错误解决方法

最近做Firefox的开发,一直在用javascript写XPCOM组件,javascript这个东东来写XPCOM非常痛苦,有一点错误都无法注册成功,许多时候基本靠肉眼一个单词一个单词的找,当然也有一些技巧。Firefox开发最常用的工具有firebug和XPCOMViewer,使用XPCOMViewer来查看已注册的组件。常见的错误:一、死活注册不上:注释掉其他方法和成员变量,

fuliangliang的Blog 3011

电路板保险丝如何选型

在电路板保险丝选型过程中,需要考虑多个因素以确保其适合特定的电路需求。最后,经过以上程序选定的样品需要在实际的电路中进行测试,以验证所选择的保险丝是否合适。

weixin_57010826的博客 1313

Mozilla研究—XPCOM语言无关性的实现原理

Mozilla研究—XPCOM语言无关性的实现原理

jggyff的博客 168

「UG/NX」Block UI 曲线收集器CurveCollector

曲线收集器块用于选择一条或多条曲线,包括通过选择意图连接的末端曲线链。曲线选择意图用于此块,但它不支持“交点处停止”、“跟随圆角”、“中间链”和“特征内链”等规则选项。

何曾参静谧的博客 1094

SOI LDMOS器件的Sentaurus TCAD建模与关键电学特性仿真研究

本文研究了SOI LDMOS器件的TCAD建模与电学特性仿真。通过Sentaurus TCAD平台建立了单RESURF结构的SOI LDMOS模型,详细阐述了器件结构原理和RESURF耐压机制。研究采用SDE进行几何定义和掺杂配置,在Sentaurus Device中构建了完整的物理模型体系,包括迁移率、复合和碰撞电离模型。通过系统仿真提取了器件的转移特性、输出特性和击穿特性等关键参数,分析了各参数对性能的影响规律。研究结果为功率半导体器件的仿真建模提供了规范化参考,有助于优化SOI LDMOS的性能设计。

huanghm88的专栏 136

创建windows下的第一个C++ XPCOM组件

这是一个step-by-step的入门教程,讲述在Windows下创建,构建和注册一个XPCOM 组件的过程。 本文涉及的源代码可以从我的资源里面下载。 创建组件 1. 下载 gecko-sdk-i586-pc-msvc-1.7.zip,解压到本地。 2. 为主接口创建GUID: Windows下用guidgen (Visual Studio 2003/2005 工具->创建GU

HITXuQin的专栏 1636

使用机器学习算法预测黄金价格

在本文中,我们将使用线性回归、XGBoost和LSTM这三种不同的机器学习算法来预测黄金价格。接下来,我们使用线性回归、XGBoost和LSTM分别建立了模型,并进行了训练和预测。这些机器学习算法可以帮助我们对黄金价格进行预测,但请注意,市场价格受多种因素影响,因此预测结果可能并不完全准确。接下来,我们需要对数据进行一些预处理,以便用于机器学习模型的训练和测试。我们将使用80%的数据作为训练集,20%的数据作为测试集。最后,我们将绘制每个模型的预测结果,并将其与实际价格进行比较,以评估模型的性能。

QromMatlab的博客 1319

XPCOM LINKS

XPCOM PAGE:https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Guide/Creating_components/An_Overview_of_XPCOMXPCOM API: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/I...

hunter 400

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

xpcom组件开发总结

1) 安装好XPCOM Wizard。使用专门的XPCOM 开发插件,方便开发 2) 使用与Mozilla浏览器相应的开发包,这一点很重要,之前就是因为版本问题,一直试不通。 3) 将生成的dll和xpt 文件拷贝到Mozilla/components 目录 4) 使用regxpcom -x "Mozilla Path" dllname 注册控件,一定要在"Mozilla Path"上

it_fly的专栏 942

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

gecko: xpcom: 利用C++创建XPCOM组件(英文)

转自:http://www.iosart.com/firefox/xpcom/About This is a step-by-step tutorial on creating, building and registering an XPCOM component on Linux and MS Wi...

hunter 461

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

FireFox插件和扩展开发(二)——编写和使用XPCOM组件

用C++编写XPCOM组件 还是先开看看官网给的例子,下载示例程序 xpcom-test 配置方法见文章 https://developer.mozilla.org/en/How_to_build_a_binary_XPCOM_component_using_Visual_Studio没有必要下载该文章中的Gecko-SDK,如果使用较新版本的xul-runner,使用

雨的程序人生 3842

xpcom:create js xpcom

8.2. Creating XPCOM ComponentsAs we mentioned, oneadvantageof using XPCOM is that it separates the implementation from theinterface so you can write a component in a language-agnostic manner.The servi...

hunter 477

组件内部

Creating Components in C++ 让我们开始检查怎么用C++写XPCOM组件,最常见的组件类型是用C++写,然后编译成dll。下图显示了你实现的动态库和XPCOM框架之间的关系。 当你创建一个组件或模块,并编译成库时,必须要导出一个NSGetModule方法,NSGetModule方法是访问库的入口。在注册或注销组件时,或XPCOM需要查询组件或库实现哪些接口时

hai200501019的专栏 607

【转】我的书架:COM组件开发

原文:http://www.cnblogs.com/phinecos/archive/2008/08/08/1263756.html  推荐几本个人读过的比较不错的COM组件相关的书籍,按我的阅读感受排名如下:1,《Visual C++实践与提高-COM和COM+篇》       这本书我放在第一位,倒不是它有多么出色,但我却认为它是最适合新手的。它的内容基本都是抄袭下面潘

code09的专栏 508

Creating Python GUI Applications using XULRunner

Creating Python GUI Applications using XULRunner Python XULRunner applicationCreating Python GUI Applications using XULRunner Abou...

123

开发你的第一个Firefox插件【转】

搭建你的应用开发环境 Firefox相关设置的调节 创建Profile 新建一个Firefox的Profile,以便拥有一个纯净的开发环境,另外易于安装开发者插件。 使用以下方法创建一个新的Profile:UNIX用户 firefox -no-remote -P develop Windows NT用户 创建Firefox的快捷方式,传入参数 -no-...

一条鱼 + 一条鱼 289

整合ssh时候,因为对某个操作加入了事务,采用aop的形式爆出的异常

Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or speci

千年祸害万年牢 621

C# PowerPoint操作的基本用法

<br />http://www.cnblogs.com/hyruur/archive/2011/02/14/1954118.html<br /> <br />1 using System;<br />  2 using System.Collections.Generic;<br />  3 using System.Linq;<br />  4 using System.Text;<br />  5 using OFFICECORE = Microsoft.Office.Core;<br />  6 u

gahetgidt的专栏 6250
上一篇: xpcom:create js xpcom
下一篇: create xpcom,long detail old document
nedwons
博客等级 码龄9年 311粉丝 572原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值