Changeset 3296

Show
Ignore:
Timestamp:
04/27/08 14:51:58 (3 months ago)
Author:
dgollub
Message:

Ported (paritial) swig port for latest hashtable API changes.
TODO: Please, review if port is complete

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wrapper/opensync-helper.i

    r3167 r3296  
    2626 
    2727        ~HashTable() { 
    28                 osync_hashtable_free(self); 
     28                osync_hashtable_unref(self); 
    2929        } 
    3030 
    31         void reset_reports() { 
    32                 osync_hashtable_reset_reports(self); 
    33         } 
     31        bool load() { 
     32                Error *err = NULL; 
     33                osync_hashtable_load(self, &err); 
     34 
     35                if (raise_exception_on_error(err)) 
     36                        return FALSE; 
     37 
     38                return TRUE; 
     39        } 
     40 
     41        bool save() { 
     42                Error *err = NULL; 
     43                osync_hashtable_save(self, &err); 
     44 
     45                if (raise_exception_on_error(err)) 
     46                        return FALSE; 
     47 
     48                return TRUE; 
     49        } 
    3450 
    3551        bool slowsync() { 
     
    4763        } 
    4864 
    49         /* returns a tuple of (uid, hash) strings */ 
    50         PyObject *nth_entry(int nth) { 
    51                 char *uid, *hash; 
    52  
    53                 if (!osync_hashtable_nth_entry(self, nth, &uid, &hash)) { 
    54                         wrapper_exception("osync_hashtable_nth_entry failed"); 
    55                         return NULL; 
    56                 } 
    57  
    58                 return Py_BuildValue("(ss)", uid, hash); 
    59         } 
    60  
    61         void write(const char *uid, const char *hash) { 
    62                 osync_hashtable_write(self, uid, hash); 
    63         } 
    64  
    65         void delete(const char *uid) { 
    66                 osync_hashtable_delete(self, uid); 
    67         } 
    68  
    69         void update_hash(ChangeType type, const char *uid, const char *hash) { 
    70                 osync_hashtable_update_hash(self, type, uid, hash); 
    71         } 
    72  
    73         void report(const char *uid) { 
    74                 osync_hashtable_report(self, uid); 
     65        void update_change(Change *change) { 
     66                osync_hashtable_update_change(self, change); 
    7567        } 
    7668 
    7769        /* returns a list of deleted UIDs as strings */ 
    7870        PyObject *get_deleted() { 
    79                 char **uids = osync_hashtable_get_deleted(self); 
     71                OSyncList *uids = osync_hashtable_get_deleted(self); 
    8072                if (uids == NULL) { 
    8173                        wrapper_exception("osync_hashtable_get_deleted failed"); 
     
    8678                if (ret != NULL) { 
    8779                        int i; 
    88                         for (i = 0; uids[i] != NULL; i++) { 
    89                                 PyObject *item = PyString_FromString(uids[i]); 
     80                        OSyncList *u; 
     81                        for (u = uids; u; u = u->next) { 
     82                                char *uid = u->data; 
     83                                PyObject *item = PyString_FromString(uid); 
    9084                                if (item == NULL || PyList_Append(ret, item) != 0) { 
    9185                                        Py_XDECREF(item); 
     
    9791                } 
    9892 
    99                 free(uids); 
    10093                return ret; 
    10194        } 
    10295 
    103         ChangeType get_changetype(const char *uid, const char *hash) { 
    104                 return osync_hashtable_get_changetype(self, uid, hash); 
     96        ChangeType get_changetype(Change *change) { 
     97                return osync_hashtable_get_changetype(self, change); 
    10598        } 
    10699