Ticket #8789: scummvm_beos.patch

File scummvm_beos.patch, 5.2 KB (added by SF/begasus, 16 years ago)

BeOS port for scummvm

  • common/hashmap.h

    diff -Nur scummvm_org/common/hashmap.h scummvm_beos/common/hashmap.h
    old new  
    8686template <class Key, class Val, class HashFunc = Hash<Key>, class EqualFunc = EqualTo<Key> >
    8787class HashMap {
    8888private:
    89 #if defined (PALMOS_MODE)
     89#if defined (PALMOS_MODE) || defined (__BEOS__)
    9090public:
    9191#endif
    9292
     
    119119        /**
    120120         * Simple HashMap iterator implementation.
    121121         */
     122        template <class NodeType>
    122123        class Iterator {
    123         protected:
    124                 typedef const HashMap hashmap_t;
    125                 friend class HashMap;
    126 
    127                 // Allow ConstIterator to read member vars, so that Iterators can be converted to ConstIterator
    128                 friend class HashMap::ConstIterator;
    129 
     124                typedef const HashMap<Key, Val, HashFunc, EqualFunc> *hashmap_t;
     125                friend class HashMap<Key, Val, HashFunc, EqualFunc>;
    130126                uint _idx;
    131                 hashmap_t *_hashmap;
    132 
     127                hashmap_t _hashmap;
    133128        protected:
    134                 Iterator(uint idx, hashmap_t *hashmap) : _idx(idx), _hashmap(hashmap) {}
     129                Iterator(uint idx, hashmap_t hashmap) : _idx(idx), _hashmap(hashmap) {}
    135130
    136                 Node *deref() const {
     131                NodeType *deref() const {
    137132                        assert(_hashmap != 0);
    138                         Node *node = _hashmap->_arr[_idx];
     133                        NodeType *node = _hashmap->_arr[_idx];
    139134                        assert(node != 0);
    140135                        return node;
    141136                }
     
    143138        public:
    144139                Iterator() : _idx(0), _hashmap(0) {}
    145140
    146                 Node &operator *() const { return *deref(); }
    147                 Node *operator->() const { return deref(); }
     141                // HACK: to allow non const/const begin, end and find to work.
     142                friend class Iterator<const NodeType>;
     143                Iterator(const Iterator<Node> &iter) : _idx(iter._idx), _hashmap(iter._hashmap) {}
     144
     145                NodeType &operator *() const { return *deref(); }
     146                NodeType *operator->() const { return deref(); }
    148147
    149148                bool operator ==(const Iterator &iter) const { return _idx == iter._idx && _hashmap == iter._hashmap; }
    150149                bool operator !=(const Iterator &iter) const { return !(*this == iter); }
     
    167166                }
    168167        };
    169168
    170         /**
    171          * Simple HashMap const iterator implementation.
    172          * This is almost completely identical to the normal iterator class, only
    173          * with some const keywords added here and there, plus a conversion
    174          * operator which makes it possible to transparently convert iterators to
    175          * const iterators.
    176          * It is sadly not really possible to reduce this code duplication using
    177          * template, unless one is willing to accept various warnings on certain
    178          * compilers. Note that many (most? all?) implementations of the standard
    179          * C++ library use a similar approach for their implementations.
    180          */
    181         class ConstIterator {
    182         protected:
    183                 typedef const HashMap hashmap_t;
    184                 friend class HashMap;
    185 
    186                 uint _idx;
    187                 hashmap_t *_hashmap;
    188 
    189         protected:
    190                 ConstIterator(uint idx, hashmap_t *hashmap) : _idx(idx), _hashmap(hashmap) {}
    191 
    192                 const Node *deref() const {
    193                         assert(_hashmap != 0);
    194                         const Node *node = _hashmap->_arr[_idx];
    195                         assert(node != 0);
    196                         return node;
    197                 }
    198 
    199         public:
    200                 ConstIterator() : _idx(0), _hashmap(0) {}
    201 
    202                 // Converting a non-const iterator to a const one is allowed
    203                 ConstIterator(const Iterator &iter) : _idx(iter._idx), _hashmap(iter._hashmap) {}
    204 
    205                 const Node &operator *() const { return *deref(); }
    206                 const Node *operator->() const { return deref(); }
    207 
    208                 bool operator ==(const ConstIterator &iter) const { return _idx == iter._idx && _hashmap == iter._hashmap; }
    209                 bool operator !=(const ConstIterator &iter) const { return !(*this == iter); }
    210 
    211                 ConstIterator &operator ++() {
    212                         assert(_hashmap);
    213                         do {
    214                                 _idx++;
    215                         } while (_idx < _hashmap->_arrsize && _hashmap->_arr[_idx] == 0);
    216                         if (_idx >= _hashmap->_arrsize)
    217                                 _idx = (uint)-1;
    218 
    219                         return *this;
    220                 }
    221169
    222                 ConstIterator operator ++(int) {
    223                         ConstIterator old = *this;
    224                         operator ++();
    225                         return old;
    226                 }
    227         };
    228170
    229171public:
    230         typedef Iterator iterator;
    231         typedef ConstIterator const_iterator;
     172        typedef Iterator<Node> iterator;
     173        typedef Iterator<const Node> const_iterator;
    232174
    233175        HashMap();
    234176        HashMap(const HM_t& map);
  • configure

    diff -Nur scummvm_org/configure scummvm_beos/configure
    old new  
    955955echo_n "Checking hosttype... "
    956956echo $_host_os
    957957case $_host_os in
    958         linux* | uclinux* | openbsd* | freebsd* | netbsd* | bsd* | sunos* | hpux* | beos*)
     958        linux* | uclinux* | openbsd* | freebsd* | netbsd* | bsd* | sunos* | hpux* )
    959959                DEFINES="$DEFINES -DUNIX"
    960960                ;;
     961        beos*)
     962                DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE -DSCUMMVM_USE_LONG_INT"
     963                LIBS="$LIBS -lbind -lsocket"
     964                ;;
    961965        solaris*)
    962966                DEFINES="$DEFINES -DUNIX -DSYSTEM_NOT_SUPPORTING_D_TYPE"
    963967                ;;
     
    12761280int main(void) { vorbis_packet_blocksize(0,0); return 0; }
    12771281EOF
    12781282        cc_check $LDFLAGS $CXXFLAGS $OGG_CFLAGS $OGG_LIBS $VORBIS_CFLAGS $VORBIS_LIBS \
    1279                 -lvorbisfile -lvorbis -logg -lm && _vorbis=yes
     1283                -lvorbisfile -lvorbis -logg && _vorbis=yes
    12801284fi
    12811285if test "$_vorbis" = yes ; then
    12821286        _def_vorbis='#define USE_VORBIS'
     
    13281332int main(void) { return FLAC__STREAM_SYNC_LEN >> 30; /* guaranteed to be 0 */ }
    13291333EOF
    13301334        cc_check $LDFLAGS $CXXFLAGS $FLAC_CFLAGS $FLAC_LIBS $OGG_CFLAGS $OGG_LIBS \
    1331                 -lFLAC -logg -lm && _flac=yes
     1335                -lFLAC -logg && _flac=yes
    13321336fi
    13331337if test "$_flac" = yes ; then
    13341338        _def_flac='#define USE_FLAC'