Ticket #8391: makeInstance.patch

File makeInstance.patch, 6.1 KB (added by fingolfin, 19 years ago)
  • base/plugins.h

    RCS file: /cvsroot/scummvm/scummvm/base/plugins.h,v
    retrieving revision 1.24
    diff -u -d -r1.24 plugins.h
     
    117117       
    118118        bool tryLoadPlugin(Plugin *plugin);
    119119       
    120         friend SingletonBaseType *makeInstance<>();
     120        friend class Common::Singleton<SingletonBaseType>;
    121121        PluginManager();
    122122
    123123public:
  • common/config-manager.h

    RCS file: /cvsroot/scummvm/scummvm/common/config-manager.h,v
    retrieving revision 1.21
    diff -u -d -r1.21 config-manager.h
     
    114114*/
    115115
    116116private:
    117         friend SingletonBaseType *makeInstance<>();
     117        friend class Singleton<SingletonBaseType>;
    118118        ConfigManager();
    119119
    120120        void                    loadFile(const String &filename);
  • common/singleton.h

    RCS file: /cvsroot/scummvm/scummvm/common/singleton.h,v
    retrieving revision 1.9
    diff -u -d -r1.9 singleton.h
     
    2323#ifndef COMMON_SINGLETON_H
    2424#define COMMON_SINGLETON_H
    2525
    26 /**
    27  * The default object factory used by the template class Singleton.
    28  * By specialising this template function, one can make a singleton use a
    29  * custom object factory. For example, to support encapsulation, your
    30  * singleton class might be pure virtual (or "abstract" in Java terminology),
    31  * and you specialise makeInstance to return an instance of a subclass.
    32  */
    33 template <class T>
    34 T* makeInstance() {
    35         return new T();
    36 }
    37 
    3826namespace Common {
    3927
    4028/**
     
    4937       
    5038        static T* _singleton;
    5139
     40        /**
     41         * The default object factory used by the template class Singleton.
     42         * By specialising this template function, one can make a singleton use a
     43         * custom object factory. For example, to support encapsulation, your
     44         * singleton class might be pure virtual (or "abstract" in Java terminology),
     45         * and you specialise makeInstance to return an instance of a subclass.
     46         */
     47        //template <class T>
     48        static T* makeInstance() {
     49                return new T();
     50        }
     51       
     52
    5253public:
    5354        static T& instance() {
    5455                // TODO: We aren't thread safe. For now we ignore it since the
     
    5960                // order might become an issue. There are various approaches
    6061                // to solve that problem, but for now this is sufficient
    6162                if (!_singleton)
    62                         _singleton = makeInstance<T>();
     63                        _singleton = makeInstance();
     64//                      _singleton = makeInstance<T>();
    6365                return *_singleton;
    6466        }
    6567protected:
  • common/system.cpp

    RCS file: /cvsroot/scummvm/scummvm/common/system.cpp,v
    retrieving revision 1.16
    diff -u -d -r1.16 system.cpp
     
    3434DECLARE_SINGLETON(OSystem);
    3535
    3636template <>
    37 OSystem *makeInstance<>() {
     37OSystem *Common::Singleton<OSystem>::makeInstance() {
    3838        // Attention: Do not call parseGraphicsMode() here, nor any other function
    3939        // which needs to access the OSystem instance, else you get stuck in an
    4040        // endless loop.
  • common/system.h

    RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
    retrieving revision 1.78
    diff -u -d -r1.78 system.h
     
    3535 * Custome object factory for OSystem.
    3636 */
    3737template <>
    38 OSystem *makeInstance<>();
     38OSystem *Common::Singleton<OSystem>::makeInstance();
    3939
    4040
    4141/**
  • gui/newgui.h

    RCS file: /cvsroot/scummvm/scummvm/gui/newgui.h,v
    retrieving revision 1.49
    diff -u -d -r1.49 newgui.h
     
    5656class NewGui : public Common::Singleton<NewGui> {
    5757        typedef Common::String String;
    5858        friend class Dialog;
    59         friend SingletonBaseType *makeInstance<>();
     59        friend class Common::Singleton<SingletonBaseType>;
    6060        NewGui();
    6161public:
    6262
  • scumm/smush/smush_player.cpp

    RCS file: /cvsroot/scummvm/scummvm/scumm/smush/smush_player.cpp,v
    retrieving revision 1.141
    diff -u -d -r1.141 smush_player.cpp
     
    172172        }
    173173};
    174174
    175 static StringResource *getStrings(const char *file, bool is_encoded) {
     175static StringResource *getStrings(ScummEngine *vm, const char *file, bool is_encoded) {
    176176        debugC(DEBUG_SMUSH, "trying to read text ressources from %s", file);
    177         File theFile;
     177        ScummFile theFile;
    178178
    179         theFile.open(file);
     179        vm->openFile(theFile, file);
    180180        if (!theFile.isOpen()) {
    181181                return 0;
    182182        }
     
    195195
    196196                if (type != TYPE_ETRS) {
    197197                        delete [] filebuffer;
    198                         return getStrings(file, false);
     198                        return getStrings(vm, file, false);
    199199                }
    200200
    201201                char *old = filebuffer;
     
    651651        char fname[260];
    652652        memcpy(fname, file, i - file);
    653653        strcpy(fname + (i - file), ".trs");
    654         if ((_strings = getStrings(fname, false)) != 0) {
     654        if ((_strings = getStrings(_vm, fname, false)) != 0) {
    655655                return true;
    656656        }
    657657
    658         if ((_strings = getStrings("digtxt.trs", true)) != 0) {
     658        if ((_strings = getStrings(_vm, "digtxt.trs", true)) != 0) {
    659659                return true;
    660660        }
    661661        return false;
  • sound/audiocd.h

    RCS file: /cvsroot/scummvm/scummvm/sound/audiocd.h,v
    retrieving revision 1.7
    diff -u -d -r1.7 audiocd.h
     
    5454        Status getStatus() const;
    5555
    5656private:
    57         friend SingletonBaseType *makeInstance<>();
     57        friend class Common::Singleton<SingletonBaseType>;
    5858        AudioCDManager();
    5959
    6060        int getCachedTrack(int track);