comparison PyRealTime.cpp @ 34:c905122f79e7 vampy2

* Fixes from OpenSolaris build
author cannam
date Wed, 23 Sep 2009 12:07:32 +0000
parents 4f1894c7591b
children
comparison
equal deleted inserted replaced
33:c4da8d559872 34:c905122f79e7
43 if (self == NULL) return NULL; 43 if (self == NULL) return NULL;
44 44
45 self->rt = NULL; 45 self->rt = NULL;
46 46
47 if (sec == 0 && nsec == 0 && fmt == 0) 47 if (sec == 0 && nsec == 0 && fmt == 0)
48 self->rt = new RealTime::RealTime(); 48 self->rt = new RealTime();
49 else if (fmt == 0) 49 else if (fmt == 0)
50 self->rt = new RealTime::RealTime(sec,nsec); 50 self->rt = new RealTime(sec,nsec);
51 else { 51 else {
52 /// new RealTime from seconds or milliseconds: i.e. >>>RealTime('seconds',12.3) 52 /// new RealTime from seconds or milliseconds: i.e. >>>RealTime('seconds',12.3)
53 if (!string(fmt).compare("float") || 53 if (!string(fmt).compare("float") ||
54 !string(fmt).compare("seconds")) 54 !string(fmt).compare("seconds"))
55 self->rt = new RealTime::RealTime( 55 self->rt = new RealTime(
56 RealTime::fromSeconds((double) unary)); 56 RealTime::fromSeconds((double) unary));
57 57
58 if (!string(fmt).compare("milliseconds")) { 58 if (!string(fmt).compare("milliseconds")) {
59 self->rt = new RealTime::RealTime( 59 self->rt = new RealTime(
60 RealTime::fromSeconds((double) unary / 1000.0)); } 60 RealTime::fromSeconds((double) unary / 1000.0)); }
61 } 61 }
62 62
63 if (!self->rt) { 63 if (!self->rt) {
64 PyErr_SetString(PyExc_TypeError, 64 PyErr_SetString(PyExc_TypeError,
203 { 203 {
204 RealTimeObject *result = 204 RealTimeObject *result =
205 PyObject_New(RealTimeObject, &RealTime_Type); 205 PyObject_New(RealTimeObject, &RealTime_Type);
206 if (result == NULL) return NULL; 206 if (result == NULL) return NULL;
207 207
208 result->rt = new RealTime::RealTime( 208 result->rt = new RealTime(
209 *((RealTimeObject*)s)->rt + *((RealTimeObject*)w)->rt); 209 *((RealTimeObject*)s)->rt + *((RealTimeObject*)w)->rt);
210 return (PyObject*)result; 210 return (PyObject*)result;
211 } 211 }
212 212
213 static PyObject * 213 static PyObject *
215 { 215 {
216 RealTimeObject *result = 216 RealTimeObject *result =
217 PyObject_New(RealTimeObject, &RealTime_Type); 217 PyObject_New(RealTimeObject, &RealTime_Type);
218 if (result == NULL) return NULL; 218 if (result == NULL) return NULL;
219 219
220 result->rt = new RealTime::RealTime( 220 result->rt = new RealTime(
221 *((RealTimeObject*)s)->rt - *((RealTimeObject*)w)->rt); 221 *((RealTimeObject*)s)->rt - *((RealTimeObject*)w)->rt);
222 return (PyObject*)result; 222 return (PyObject*)result;
223 } 223 }
224 224
225 static PyNumberMethods realtime_as_number = 225 static PyNumberMethods realtime_as_number =
311 311
312 RealTimeObject *self = 312 RealTimeObject *self =
313 PyObject_New(RealTimeObject, &RealTime_Type); 313 PyObject_New(RealTimeObject, &RealTime_Type);
314 if (self == NULL) return NULL; 314 if (self == NULL) return NULL;
315 315
316 self->rt = new RealTime::RealTime(*rt); 316 self->rt = new RealTime(*rt);
317 return (PyObject*) self; 317 return (PyObject*) self;
318 }*/ 318 }*/
319 319
320 320
321 /*PyRealTime from RealTime*/ 321 /*PyRealTime from RealTime*/
324 324
325 RealTimeObject *self = 325 RealTimeObject *self =
326 PyObject_New(RealTimeObject, &RealTime_Type); 326 PyObject_New(RealTimeObject, &RealTime_Type);
327 if (self == NULL) return NULL; 327 if (self == NULL) return NULL;
328 328
329 self->rt = new RealTime::RealTime(rt); 329 self->rt = new RealTime(rt);
330 return (PyObject*) self; 330 return (PyObject*) self;
331 } 331 }
332 332
333 /*RealTime* from PyRealTime*/ 333 /*RealTime* from PyRealTime*/
334 const Vamp::RealTime::RealTime* 334 const Vamp::RealTime*
335 PyRealTime_AsRealTime (PyObject *self) { 335 PyRealTime_AsRealTime (PyObject *self) {
336 336
337 RealTimeObject *s = (RealTimeObject*) self; 337 RealTimeObject *s = (RealTimeObject*) self;
338 338
339 if (!PyRealTime_Check(s)) { 339 if (!PyRealTime_Check(s)) {