Skip to content

Commit

Permalink
Add "final" marker to a number of classes
Browse files Browse the repository at this point in the history
Devirtualization is an optimization in the generated assembly: when a
class C is polymorphic but also final, ``((C *)ptr)->func()`` can be
turned from an indirect into a static call.
  • Loading branch information
jengelh committed Nov 3, 2024
1 parent a58c275 commit 71772b9
Show file tree
Hide file tree
Showing 68 changed files with 2,145 additions and 2,145 deletions.
6 changes: 3 additions & 3 deletions 2dlib/gr.h
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ class grSurface {
// this is a software bitmap not video driver dependant
// ----------------------------------------------------------------------------

class grMemorySurface : public grSurface {
class grMemorySurface final : public grSurface {
bool m_FirstTimeInit; // do special stuff if we are initializing for first time
bool m_AllowInit; // we only allow initialization if we didn't create it.

Expand All @@ -375,7 +375,7 @@ class grMemorySurface : public grSurface {
// this is a hardware bitmap allocated from the video driver
// ----------------------------------------------------------------------------

class grHardwareSurface : public grSurface {
class grHardwareSurface final : public grSurface {
public:
grHardwareSurface();
grHardwareSurface(int w, int h, int bpp, unsigned flags = 0, const char *name = NULL);
Expand All @@ -390,7 +390,7 @@ class grHardwareSurface : public grSurface {
// is used by the grViewport class to draw onto the screen
// ----------------------------------------------------------------------------

class grScreen : public grSurface {
class grScreen final : public grSurface {
friend class grViewport;

public:
Expand Down
2 changes: 1 addition & 1 deletion AudioEncode/adecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ using namespace AudioDecoder;

namespace {

class InternalAudioDecoder : public IAudioDecoder {
class InternalAudioDecoder final : public IAudioDecoder {
public:
InternalAudioDecoder(ReadDataFunction readerFunction, void *pReaderData);
~InternalAudioDecoder();
Expand Down
2 changes: 1 addition & 1 deletion Descent3/mmItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class tmmItemQueue {
//////////////////////////////////////////////////////////////////////
class mmInterface;
// class mmItem
class mmItem : public UIGadget {
class mmItem final : public UIGadget {
char *m_text; // text for item
int16_t m_alpha; // alpha for text item
int16_t m_satcount;
Expand Down
14 changes: 7 additions & 7 deletions Descent3/newui.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ const tUIClass newuiNewClass = 1000;
// NewUIGameWindow
// this draws a UI window, but with a not-so-cool faded background.

class NewUIWindow : public UIWindow {
class NewUIWindow final : public UIWindow {
chunked_bitmap m_Chunk;

public:
Expand Down Expand Up @@ -411,7 +411,7 @@ class NewUIGameWindow : public newuiTiledWindow {
// NewUIMessageBox
// this draws a UI window, but with the cool standard game dialog background.

class NewUIMessageBox : public NewUIGameWindow {
class NewUIMessageBox final : public NewUIGameWindow {
public:
NewUIMessageBox();

Expand All @@ -421,7 +421,7 @@ class NewUIMessageBox : public NewUIGameWindow {
// NewUISlider
// this draws a nicer loking slider.

class NewUISlider : public UISlider {
class NewUISlider final : public UISlider {
UIBitmapItem m_SliderBar;
UIBitmapItem m_Slider;

Expand All @@ -432,7 +432,7 @@ class NewUISlider : public UISlider {
// NewUIEdit
// this draws a nicer edit box

class NewUIEdit : public UIEdit {
class NewUIEdit final : public UIEdit {
UIBitmapItem m_EditLeft;
UIBitmapItem m_EditCen;
UIBitmapItem m_EditRight;
Expand All @@ -450,7 +450,7 @@ class NewUIEdit : public UIEdit {
// NewUIListBox
// this draws a nicer list box

class NewUIListBox : public UIListBox {
class NewUIListBox final : public UIListBox {
UIBitmapItem m_BackNW;
UIBitmapItem m_BackN;
UIBitmapItem m_BackNE;
Expand All @@ -475,7 +475,7 @@ class NewUIListBox : public UIListBox {
// NewUIComboBox
// displays a listbox just one item.

class NewUIComboBox : public UIComboBox {
class NewUIComboBox final : public UIComboBox {
UIBitmapItem m_CmbLeft;
UIBitmapItem m_CmbCen;
UIBitmapItem m_CmbRight;
Expand All @@ -493,7 +493,7 @@ class NewUIComboBox : public UIComboBox {
// NewUIButton
// a nicer fixed size button.

class NewUIButton : public UIButton {
class NewUIButton final : public UIButton {
UIBitmapItem m_BtnUpL, m_BtnUpC, m_BtnUpR;
UIBitmapItem m_BtnDownL, m_BtnDownC, m_BtnDownR;
UIBitmapItem m_BtnHiliteL, m_BtnHiliteC, m_BtnHiliteR;
Expand Down
14 changes: 7 additions & 7 deletions Descent3/newui_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class newuiButton : virtual public UIButton {

// CLASS a large option button used in menus.

class newuiMenuOptionButton : public newuiButton {
class newuiMenuOptionButton final : public newuiButton {
public:
void Create(newuiMenu *menu, newuiMenuOptionButton *last, int16_t id, const char *name, int16_t x, int16_t y,
bool m_mono_press);
Expand All @@ -376,14 +376,14 @@ class newuiMenuOptionButton : public newuiButton {
newuiMenuOptionButton *m_prev_btn, *m_next_btn;
};

class newuiTinyButton : public newuiButton {
class newuiTinyButton final : public newuiButton {
public:
void Create(UIWindow *wnd, int16_t id, const char *name, int16_t x, int16_t y);
};

// CLASS creates an arrow button that is sensitive to touch (when down, always select)

class newuiArrowButton : public newuiButton {
class newuiArrowButton final : public newuiButton {
public:
newuiArrowButton(){};

Expand All @@ -405,7 +405,7 @@ class newuiArrowButton : public newuiButton {
#define SUBGADGET_UP 0x3
#define SUBGADGET_DOWN 0x4

class newuiListBox : public UIGadget {
class newuiListBox final : public UIGadget {
public:
newuiListBox();

Expand Down Expand Up @@ -475,7 +475,7 @@ class newuiListBox : public UIGadget {

// CLASS newuiComboBox

class newuiComboBox : public UIGadget {
class newuiComboBox final : public UIGadget {
public:
newuiComboBox();

Expand Down Expand Up @@ -526,7 +526,7 @@ class newuiComboBox : public UIGadget {

// the new classic hotspot CLASS

class newuiHotspot : public UIGadget {
class newuiHotspot final : public UIGadget {
private:
char *m_title;
int16_t m_alpha, m_alpha_adjust;
Expand Down Expand Up @@ -624,7 +624,7 @@ class newuiMenu : public UIWindow {

// CLASS, large (fullscreen) menu

class newuiLargeMenu : public newuiMenu {
class newuiLargeMenu final : public newuiMenu {
public:
// creates a menu
void Create();
Expand Down
4 changes: 2 additions & 2 deletions Descent3/pilot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1804,15 +1804,15 @@ bool PltCopyKeyConfig(pilot *src, pilot *dest) {
// UI3DWindow class
//
// UI class for displaying a polymodel on the UIWindow, rotating 30 deg/sec
class UI3DWindow : public UIStatic {
class UI3DWindow final : public UIStatic {
public:
void OnDraw();
};

// UIBmpWindow class
//
// UI class for displaying a bitmap on a UIWindow
class UIBmpWindow : public UIStatic {
class UIBmpWindow final : public UIStatic {
public:
UIBmpWindow();
~UIBmpWindow();
Expand Down
4 changes: 2 additions & 2 deletions Descent3/sdlmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void install_signal_handlers() { SetUnhandledExceptionFilter(RecordExceptionInfo
// ---------------------------------------------------------------------------
// Define our operating system specific extensions to the gameos system
// ---------------------------------------------------------------------------
class oeD3LnxApp : public oeLnxApplication {
class oeD3LnxApp final : public oeLnxApplication {
bool shutdown, final_shutdown;
int old_screen_mode;

Expand All @@ -142,7 +142,7 @@ class oeD3LnxApp : public oeLnxApplication {
void run() { Descent3(); };
};

class oeD3LnxDatabase : public oeLnxAppDatabase {
class oeD3LnxDatabase final : public oeLnxAppDatabase {
public:
oeD3LnxDatabase() {
char path[_MAX_PATH];
Expand Down
4 changes: 2 additions & 2 deletions cfile/inffile.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ enum InfFileError {
INFFILE_SYMBOL = 1024,
};

class InfFile {
class InfFile final {
public:
InfFile();
virtual ~InfFile();
~InfFile();

// opens an inf file, pass in a lexical analyzer that will return a command index.
// tag_check is a string that must appear at the very beginning of the file.
Expand Down
2 changes: 1 addition & 1 deletion ddio/sdlcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const int CTID_KEYBOARD = -1, // always -1 for keyboards

const int CTID_EXTCONTROL0 = 0;

class sdlgameController : public gameController {
class sdlgameController final : public gameController {
public:
sdlgameController(int num_funcs, ct_function *funcs);
~sdlgameController();
Expand Down
4 changes: 2 additions & 2 deletions netgames/dmfc/dmfcinternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class PInfo {
int m_slot;
};

class MenuItem : public IMenuItem {
class MenuItem final : public IMenuItem {
public:
MenuItem();
MenuItem(const char *title, char type, uint8_t flags, void (*fp)(int), ...); // the last parameters are the state items, which
Expand Down Expand Up @@ -455,7 +455,7 @@ struct tBanItem {
};

// This class handles displaying and processing a customizable and detailed stats screen (in-game)
class CDmfcStats : public IDmfcStats {
class CDmfcStats final : public IDmfcStats {
public:
// constuctor/destructor
CDmfcStats();
Expand Down
Loading

0 comments on commit 71772b9

Please sign in to comment.