NPAPI: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Gsdefender2 (discussione | contributi)
m +2 righe+Da tradurre
Gsdefender2 (discussione | contributi)
+fine sezione
Riga 31:
LiveConnect si rivelò estremamente problematico per Mozilla. La dipendenza da un runtime Java obsoleto e proprietario e dall'API JRI implicava l'impossibilità per LiveConnect di funzionare.
 
Mozilla stava già utilizzando [[XPCOM]] per definire le interfacce a molti oggetti implementati in C++. Ogni interfaccia veniva definita tramite un file [[IDL]] (Interface Definition Language), e passata ad un compilatore IDL che produceva file d'intestazione ed una libreria indipendente dal linguaggio di programmazione che costituiva la rappresentazione binaria dell'interfaccia: quest'ultima descriveva l'interfaccia, i metodi, i parametri, le strutture dati e le enumerazioni.
<!--
=== XPConnect ===
LiveConnect proved extremely problematic for Mozilla. The dependency on an obsolete and proprietary Java runtime and the JRI API meant that LiveConnect never really worked.
 
[[XPCOM]] usa le informazioni sul tipo di libreria per regolamentare le chiamate tra diversi contesti di thread e tra JavaScript codice nativo C++ compilato. Dal momento che XPConnect viene utilizzato pesantemente da Mozilla, è molto robusto, supportato e documentato. A partire da Netscape 6.1 e Mozilla 0.9.2, la NPAPI è stata estesa in modo tale che un plugin potesse restituire un'interfaccia a se stesso gestibile tramite script, mentre XPConnect si occupa di gestire le chiamate a detto plugin da JavaScript e dal codice C++.
Mozilla was already using [[XPCOM]] to define the interfaces to many objects implemented in C++. Each interface was defined by an [[IDL]] (Interface Definition Language) file, and run through an IDL compiler that produced header files and a language neutral type library that was a binary representation of the interface. This binary described the interface, the methods, the parameters, the data structures and enumerations.
 
Ciò rese non più necessaria la dipendenza da Java, ma provocò alcuni problemi. In particolare, poichè l'implementazione viene effettuata utilizzando componenti XPCOM, una tecnologia simile a [[Component Object Model|Microsoft COM]], lo sviluppatore del plugin deve saper gestire il reference counting, le interfacce, l'IDL e così via per poter implementare lo scripting. Inoltre, la dipendenza da XPCOM comportava alcuni problemi nel collegamento dinamico delle librerie (ad esempio il problema della [[classe base fragile]]) che dovevano essere risolti per permettere al plugin di funzionare correttamente con browser differenti. XPCOM è stato in seguito modificato in modo tale da fornire una versione collegata staticamente per risolvere tali problemi. Quest'approccio richiede anche l'installazione di un file .xpt nella stessa locazione scelta per la DLL, altrimenti il plugin sembrerà funzionare, mentre la funzionalità di scripting non sara disponibile.
[[XPConnect]] uses the type library information to marshal calls between different thread contexts and between JavaScript and natively compiled C++. As XPConnect is used extensively throughout Mozilla, it is extremely robust, supported and well understood. Starting with Netscape 6.1 and Mozilla 0.9.2, the NPAPI was extended so that a plugin could return a scriptable interface to itself and XPConnect would marshal calls to it from JavaScript and the C++ implementation.
<!--
 
This removed the Java dependency, however there are issues with XPConnect. In particular, the technology is heavily based on XPCOM, which is similar to [[Component Object Model|Microsoft COM]]. Thus the plugin developer must be familiar with reference counting, interfaces, IDL and so forth to implement scripting. Additionally, the dependency on XPCOM led to certain dynamic linking issues (e.g. the [[fragile base class|fragile base class problem]]) which had to be solved before the plugin would work correctly with different browsers. XPCOM has since been changed so that it supplies a statically linked version to address such issues. This approach also requires to have an .xpt file installed next to the DLL, otherwise the plugin will appear to work, but scripting won't, causing confusion.
 
=== npruntime ===