Emit NS_NO_VTABLE in xpidl-generated interface files.  NS_NO_VTABLE is defined in nsISupportsUtils.h, and on windows generates __declspec(novtable).

This saves us some code space, and may also be a runtime win.

Initial version of this fix courtesy Adam Lock <adamlock@netscape.com>.

r=jband
a=beard


NOTE this change will cause the world to recompile.
This commit is contained in:
mccabe%netscape.com 2000-08-25 09:58:35 +00:00
Родитель 73d9fa0c42
Коммит a11931fc6a
3 изменённых файлов: 47 добавлений и 3 удалений

Просмотреть файл

@ -70,6 +70,17 @@ typedef unsigned long nsrefcnt;
typedef PRUint32 nsrefcnt;
#endif
/**
* NS_NO_VTABLE is emitted by xpidl in interface declarations whenever xpidl
* can determine that the interface can't contain a constructor. This results
* in some space savings and possible runtime savings - see bug 49416.
*/
#if defined(_MSC_VER) && _MSC_VER >= 1100
#define NS_NO_VTABLE __declspec(novtable)
#else
#define NS_NO_VTABLE
#endif
#include "nsTraceRefcnt.h"
/**
@ -78,7 +89,7 @@ typedef PRUint32 nsrefcnt;
* and a reference counted memory model (AddRef/Release). This is
* modelled after the win32 IUnknown API.
*/
class nsISupports {
class NS_NO_VTABLE nsISupports {
public:
/**

Просмотреть файл

@ -70,6 +70,17 @@ typedef unsigned long nsrefcnt;
typedef PRUint32 nsrefcnt;
#endif
/**
* NS_NO_VTABLE is emitted by xpidl in interface declarations whenever xpidl
* can determine that the interface can't contain a constructor. This results
* in some space savings and possible runtime savings - see bug 49416.
*/
#if defined(_MSC_VER) && _MSC_VER >= 1100
#define NS_NO_VTABLE __declspec(novtable)
#else
#define NS_NO_VTABLE
#endif
#include "nsTraceRefcnt.h"
/**
@ -78,7 +89,7 @@ typedef PRUint32 nsrefcnt;
* and a reference counted memory model (AddRef/Release). This is
* modelled after the win32 IUnknown API.
*/
class nsISupports {
class NS_NO_VTABLE nsISupports {
public:
/**

Просмотреть файл

@ -113,6 +113,7 @@ interface(TreeState *state)
char *classNameImpl = NULL;
char *cp;
gboolean ok = TRUE;
gboolean keepvtable;
const char *iid;
const char *name_space;
struct nsID id;
@ -175,8 +176,29 @@ interface(TreeState *state)
if (doc_comments != NULL)
printlist(state->file, doc_comments);
/*
* NS_NO_VTABLE is defined in nsISupportsUtils.h, and defined on windows
* to __declspec(novtable) on windows. This optimization is safe
* whenever the constructor calls no virtual methods. Writing in IDL
* almost guarantees this, except for the case when a %{C++ block occurs in
* the interface. We detect that case, and emit a macro call that disables
* the optimization.
*/
keepvtable = FALSE;
for (iter = IDL_INTERFACE(state->tree).body;
iter != NULL;
iter = IDL_LIST(iter).next)
{
IDL_tree data = IDL_LIST(iter).data;
if (IDL_NODE_TYPE(data) == IDLN_CODEFRAG)
keepvtable = TRUE;
}
/* The interface declaration itself. */
fprintf(state->file, "class %s", className);
fprintf(state->file,
"class %s%s",
(keepvtable ? "" : "NS_NO_VTABLE "), className);
if ((iter = IDL_INTERFACE(iface).inheritance_spec)) {
fputs(" : ", state->file);
if (IDL_LIST(iter).next != NULL) {