summaryrefslogtreecommitdiff
path: root/qmake/tools/qucom.cpp
Unidiff
Diffstat (limited to 'qmake/tools/qucom.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/tools/qucom.cpp668
1 files changed, 668 insertions, 0 deletions
diff --git a/qmake/tools/qucom.cpp b/qmake/tools/qucom.cpp
new file mode 100644
index 0000000..6086a79
--- a/dev/null
+++ b/qmake/tools/qucom.cpp
@@ -0,0 +1,668 @@
1/****************************************************************************
2** $Id$
3**
4** Implementation of the QUcom classes
5**
6** Created : 990101
7**
8** Copyright (C) 1992-2002 Trolltech AS. All rights reserved.
9**
10** This file is part of the tools module of the Qt GUI Toolkit.
11**
12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file.
15**
16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file.
20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software.
24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32**
33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you.
35**
36**********************************************************************/
37
38#include "qucom_p.h"
39
40// Standard types
41
42// {DE56510E-4E9F-4b76-A3C2-D1E2EF42F1AC}
43const QUuid TID_QUType_Null( 0xde56510e, 0x4e9f, 0x4b76, 0xa3, 0xc2, 0xd1, 0xe2, 0xef, 0x42, 0xf1, 0xac );
44const QUuid *QUType_Null::uuid() const { return &TID_QUType_Null; }
45const char *QUType_Null::desc() const { return "null"; }
46bool QUType_Null::canConvertFrom( QUObject *, QUType * ) { return FALSE; }
47bool QUType_Null::canConvertTo( QUObject *, QUType * ) { return FALSE; }
48bool QUType_Null::convertFrom( QUObject *, QUType * ) { return FALSE; }
49bool QUType_Null::convertTo( QUObject *, QUType * ) { return FALSE; }
50void QUType_Null::clear( QUObject *) {};
51int QUType_Null::serializeTo( QUObject *, QUBuffer * ) { return 0; }
52int QUType_Null::serializeFrom( QUObject *, QUBuffer * ) { return 0; };
53QUType_Null static_QUType_Null;
54
55
56// {7EE17B08-5419-47e2-9776-8EEA112DCAEC}
57const QUuid TID_QUType_enum( 0x7ee17b08, 0x5419, 0x47e2, 0x97, 0x76, 0x8e, 0xea, 0x11, 0x2d, 0xca, 0xec );
58QUType_enum static_QUType_enum;
59const QUuid *QUType_enum::uuid() const { return &TID_QUType_enum; }
60const char *QUType_enum::desc() const { return "enum"; }
61void QUType_enum::set( QUObject *o, int v )
62{
63 o->payload.i = v;
64 o->type = this;
65}
66
67bool QUType_enum::canConvertFrom( QUObject *o, QUType *t )
68{
69 if ( isEqual( t, &static_QUType_int ) ) // ## todo unsigned int?
70 return TRUE;
71
72 return t->canConvertTo( o, this );
73}
74
75bool QUType_enum::canConvertTo( QUObject * /*o*/, QUType *t )
76{
77 return isEqual( t, &static_QUType_int );
78}
79
80bool QUType_enum::convertFrom( QUObject *o, QUType *t )
81{
82 if ( isEqual( t, &static_QUType_int ) ) // ## todo unsigned int?
83 ;
84 else
85 return t->convertTo( o, this );
86
87 o->type = this;
88 return TRUE;
89}
90
91bool QUType_enum::convertTo( QUObject *o, QUType *t )
92{
93 if ( isEqual( t, &static_QUType_int ) ) {
94 o->type = &static_QUType_int;
95 return TRUE;
96 }
97 return FALSE;
98}
99
100int QUType_enum::serializeTo( QUObject *, QUBuffer * )
101{
102 return 0;
103}
104
105int QUType_enum::serializeFrom( QUObject *, QUBuffer * )
106{
107 return 0;
108}
109
110// {8AC26448-5AB4-49eb-968C-8F30AB13D732}
111const QUuid TID_QUType_ptr( 0x8ac26448, 0x5ab4, 0x49eb, 0x96, 0x8c, 0x8f, 0x30, 0xab, 0x13, 0xd7, 0x32 );
112QUType_ptr static_QUType_ptr;
113const QUuid *QUType_ptr::uuid() const { return &TID_QUType_ptr; }
114const char *QUType_ptr::desc() const { return "ptr"; }
115
116void QUType_ptr::set( QUObject *o, const void* v )
117{
118 o->payload.ptr = (void*) v;
119 o->type = this;
120}
121
122bool QUType_ptr::canConvertFrom( QUObject *o, QUType *t )
123{
124 return t->canConvertTo( o, this );
125}
126
127bool QUType_ptr::canConvertTo( QUObject *, QUType * )
128{
129 return FALSE;
130}
131
132bool QUType_ptr::convertFrom( QUObject *o, QUType *t )
133{
134 return t->convertTo( o, this );
135}
136
137bool QUType_ptr::convertTo( QUObject *, QUType * )
138{
139 return FALSE;
140}
141
142int QUType_ptr::serializeTo( QUObject *, QUBuffer * )
143{
144 return 0;
145}
146
147int QUType_ptr::serializeFrom( QUObject *, QUBuffer * )
148{
149 return 0;
150}
151
152// {97A2594D-6496-4402-A11E-55AEF2D4D25C}
153const QUuid TID_QUType_iface( 0x97a2594d, 0x6496, 0x4402, 0xa1, 0x1e, 0x55, 0xae, 0xf2, 0xd4, 0xd2, 0x5c );
154QUType_iface static_QUType_iface;
155const QUuid *QUType_iface::uuid() const { return &TID_QUType_iface; }
156const char *QUType_iface::desc() const { return "UnknownInterface"; }
157
158void QUType_iface::set( QUObject *o, QUnknownInterface* iface )
159{
160 o->payload.iface = iface;
161 o->type = this;
162}
163
164bool QUType_iface::canConvertFrom( QUObject *o, QUType *t )
165{
166 return t->canConvertTo( o, this );
167}
168
169bool QUType_iface::canConvertTo( QUObject *, QUType * )
170{
171 return FALSE;
172}
173
174bool QUType_iface::convertFrom( QUObject *o, QUType *t )
175{
176 return t->convertTo( o, this );
177}
178
179bool QUType_iface::convertTo( QUObject *, QUType * )
180{
181 return FALSE;
182}
183
184int QUType_iface::serializeTo( QUObject *, QUBuffer * )
185{
186 return 0;
187}
188
189int QUType_iface::serializeFrom( QUObject *, QUBuffer * )
190{
191 return 0;
192}
193
194// {2F358164-E28F-4bf4-9FA9-4E0CDCABA50B}
195const QUuid TID_QUType_idisp( 0x2f358164, 0xe28f, 0x4bf4, 0x9f, 0xa9, 0x4e, 0xc, 0xdc, 0xab, 0xa5, 0xb );
196QUType_idisp static_QUType_idisp;
197const QUuid *QUType_idisp::uuid() const { return &TID_QUType_idisp; }
198const char *QUType_idisp::desc() const { return "DispatchInterface"; }
199
200void QUType_idisp::set( QUObject *o, QDispatchInterface* idisp )
201{
202 o->payload.idisp = idisp;
203 o->type = this;
204}
205
206bool QUType_idisp::canConvertFrom( QUObject *o, QUType *t )
207{
208 return t->canConvertTo( o, this );
209}
210
211bool QUType_idisp::canConvertTo( QUObject * /*o*/, QUType *t )
212{
213 return isEqual( t, &static_QUType_iface );
214}
215
216bool QUType_idisp::convertFrom( QUObject *o, QUType *t )
217{
218 return t->convertTo( o, this );
219}
220
221bool QUType_idisp::convertTo( QUObject *o, QUType *t )
222{
223#ifndef QT_NO_COMPONENT
224 if ( isEqual( t, &static_QUType_iface ) ) {
225 o->payload.iface = (QUnknownInterface*)o->payload.idisp;
226 o->type = &static_QUType_iface;
227 return TRUE;
228 }
229#endif
230 return FALSE;
231}
232
233int QUType_idisp::serializeTo( QUObject *, QUBuffer * )
234{
235 return 0;
236}
237
238int QUType_idisp::serializeFrom( QUObject *, QUBuffer * )
239{
240 return 0;
241}
242
243// {CA42115D-13D0-456c-82B5-FC10187F313E}
244const QUuid TID_QUType_bool( 0xca42115d, 0x13d0, 0x456c, 0x82, 0xb5, 0xfc, 0x10, 0x18, 0x7f, 0x31, 0x3e );
245QUType_bool static_QUType_bool;
246const QUuid *QUType_bool::uuid() const { return &TID_QUType_bool; }
247const char *QUType_bool::desc() const { return "bool"; }
248
249void QUType_bool::set( QUObject *o, bool v )
250{
251 o->payload.b = v;
252 o->type = this;
253}
254
255bool QUType_bool::canConvertFrom( QUObject *o, QUType *t )
256{
257 return t->canConvertTo( o, this );
258}
259
260bool QUType_bool::canConvertTo( QUObject *, QUType * )
261{
262 return FALSE;
263}
264
265bool QUType_bool::convertFrom( QUObject *o, QUType *t )
266{
267 return t->convertTo( o, this );
268}
269
270bool QUType_bool::convertTo( QUObject *, QUType * )
271{
272 return FALSE;
273}
274
275int QUType_bool::serializeTo( QUObject *, QUBuffer * )
276{
277 return 0;
278}
279
280int QUType_bool::serializeFrom( QUObject *, QUBuffer * )
281{
282 return 0;
283}
284
285// {53C1F3BE-73C3-4c7d-9E05-CCF09EB676B5}
286const QUuid TID_QUType_int( 0x53c1f3be, 0x73c3, 0x4c7d, 0x9e, 0x5, 0xcc, 0xf0, 0x9e, 0xb6, 0x76, 0xb5 );
287QUType_int static_QUType_int;
288const QUuid *QUType_int::uuid() const { return &TID_QUType_int; }
289const char *QUType_int::desc() const { return "int"; }
290
291void QUType_int::set( QUObject *o, int v )
292{
293 o->payload.i = v;
294 o->type = this;
295}
296
297bool QUType_int::canConvertFrom( QUObject *o, QUType *t )
298{
299 if ( isEqual( t, &static_QUType_double ) ||
300 isEqual( t, &static_QUType_float ) )
301 return TRUE;
302
303 return t->canConvertTo( o, this );
304}
305
306bool QUType_int::canConvertTo( QUObject * /*o*/, QUType *t )
307{
308 return isEqual( t, &static_QUType_double ) ||
309 isEqual( t, &static_QUType_float );
310}
311
312bool QUType_int::convertFrom( QUObject *o, QUType *t )
313{
314 if ( isEqual( t, &static_QUType_double ) )
315 o->payload.i = (long)o->payload.d;
316 else if ( isEqual( t, &static_QUType_float ) )
317 o->payload.i = (long)o->payload.f;
318 else
319 return t->convertTo( o, this );
320
321 o->type = this;
322 return TRUE;
323}
324
325bool QUType_int::convertTo( QUObject *o, QUType *t )
326{
327 if ( isEqual( t, &static_QUType_double ) ) {
328 o->payload.d = (double)o->payload.i;
329 o->type = &static_QUType_double;
330 } else if ( isEqual( t, &static_QUType_float ) ) {
331 o->payload.f = (float)o->payload.i;
332 o->type = &static_QUType_float;
333 } else
334 return FALSE;
335 return TRUE;
336}
337
338int QUType_int::serializeTo( QUObject *, QUBuffer * )
339{
340 return 0;
341}
342
343int QUType_int::serializeFrom( QUObject *, QUBuffer * )
344{
345 return 0;
346}
347
348// {5938712A-C496-11D5-8CB2-00C0F03BC0F3}
349const QUuid TID_QUType_uint( 0x5938712a, 0xc496, 0x11d5, 0x8c, 0xb2, 0x00, 0xc0, 0xf0, 0x3b, 0xc0, 0xf3);
350QUType_uint static_QUType_uint;
351const QUuid *QUType_uint::uuid() const { return &TID_QUType_uint; }
352const char *QUType_uint::desc() const { return "uint"; }
353
354void QUType_uint::set( QUObject *o, uint v )
355{
356 o->payload.ui = v;
357 o->type = this;
358}
359
360bool QUType_uint::canConvertFrom( QUObject *o, QUType *t )
361{
362 return t->canConvertTo( o, this );
363}
364
365bool QUType_uint::canConvertTo( QUObject * /*o*/, QUType * /*t*/ )
366{
367 return FALSE;
368}
369
370bool QUType_uint::convertFrom( QUObject *o, QUType *t )
371{
372 return t->convertTo( o, this );
373}
374
375bool QUType_uint::convertTo( QUObject * /*o*/, QUType * /*t*/ )
376{
377 return FALSE;
378}
379
380int QUType_uint::serializeTo( QUObject *, QUBuffer * )
381{
382 return 0;
383}
384
385int QUType_uint::serializeFrom( QUObject *, QUBuffer * )
386{
387 return 0;
388}
389
390// {2D0974E5-0BA6-4ec2-8837-C198972CB48C}
391const QUuid TID_QUType_double( 0x2d0974e5, 0xba6, 0x4ec2, 0x88, 0x37, 0xc1, 0x98, 0x97, 0x2c, 0xb4, 0x8c );
392QUType_double static_QUType_double;
393const QUuid *QUType_double::uuid() const { return &TID_QUType_double; }
394const char *QUType_double::desc() const {return "double"; }
395
396void QUType_double::set( QUObject *o, double v )
397{
398 o->payload.d = v;
399 o->type = this;
400}
401
402bool QUType_double::canConvertFrom( QUObject *o, QUType *t )
403{
404 if ( isEqual( t, &static_QUType_int ) ||
405 isEqual( t, &static_QUType_float) )
406 return TRUE;
407
408 return t->canConvertTo( o, this );
409}
410
411bool QUType_double::canConvertTo( QUObject * /*o*/, QUType *t )
412{
413 return isEqual( t, &static_QUType_int ) ||
414 isEqual( t, &static_QUType_float );
415}
416
417bool QUType_double::convertFrom( QUObject *o, QUType *t )
418{
419 if ( isEqual( t, &static_QUType_int ) )
420 o->payload.d = (double)o->payload.i;
421 else if ( isEqual( t, &static_QUType_float ) )
422 o->payload.d = (double)o->payload.f;
423 else
424 return t->convertTo( o, this );
425
426 o->type = this;
427 return TRUE;
428}
429
430bool QUType_double::convertTo( QUObject *o, QUType *t )
431{
432 if ( isEqual( t, &static_QUType_int ) ) {
433 o->payload.i = (int) o->payload.d;
434 o->type = &static_QUType_int;
435 } else if ( isEqual( t, &static_QUType_double ) ) {
436 o->payload.d = (double) o->payload.f;
437 o->type = &static_QUType_double;
438 } else
439 return FALSE;
440 return TRUE;
441}
442
443int QUType_double::serializeTo( QUObject *, QUBuffer * )
444{
445 return 0;
446}
447
448int QUType_double::serializeFrom( QUObject *, QUBuffer * )
449{
450 return 0;
451}
452
453
454// {544C5175-6993-4486-B04D-CEC4D21BF4B9 }
455const QUuid TID_QUType_float( 0x544c5175, 0x6993, 0x4486, 0xb0, 0x4d, 0xce, 0xc4, 0xd2, 0x1b, 0xf4, 0xb9 );
456QUType_float static_QUType_float;
457const QUuid *QUType_float::uuid() const { return &TID_QUType_float; }
458const char *QUType_float::desc() const {return "float"; }
459
460void QUType_float::set( QUObject *o, float v )
461{
462 o->payload.f = v;
463 o->type = this;
464}
465
466bool QUType_float::canConvertFrom( QUObject *o, QUType *t )
467{
468 if ( isEqual( t, &static_QUType_int ) ||
469 isEqual( t, &static_QUType_double ) )
470 return TRUE;
471
472 return t->canConvertTo( o, this );
473}
474
475bool QUType_float::canConvertTo( QUObject * /*o*/, QUType *t )
476{
477 return isEqual( t, &static_QUType_int ) ||
478 isEqual( t, &static_QUType_double );
479}
480
481bool QUType_float::convertFrom( QUObject *o, QUType *t )
482{
483 if ( isEqual( t, &static_QUType_int ) )
484 o->payload.f = (float)o->payload.i;
485 else if ( isEqual( t, &static_QUType_double ) )
486 o->payload.f = (float)o->payload.d;
487 else
488 return t->convertTo( o, this );
489
490 o->type = this;
491 return TRUE;
492}
493
494bool QUType_float::convertTo( QUObject *o, QUType *t )
495{
496 if ( isEqual( t, &static_QUType_int ) ) {
497 o->payload.i = (int) o->payload.f;
498 o->type = &static_QUType_int;
499 } else if ( isEqual( t, &static_QUType_double ) ) {
500 o->payload.d = (double) o->payload.f;
501 o->type = &static_QUType_double;
502 } else
503 return FALSE;
504 return TRUE;
505}
506
507int QUType_float::serializeTo( QUObject *, QUBuffer * )
508{
509 return 0;
510}
511
512int QUType_float::serializeFrom( QUObject *, QUBuffer * )
513{
514 return 0;
515}
516
517// {EFCDD1D4-77A3-4b8e-8D46-DC14B8D393E9}
518const QUuid TID_QUType_charstar( 0xefcdd1d4, 0x77a3, 0x4b8e, 0x8d, 0x46, 0xdc, 0x14, 0xb8, 0xd3, 0x93, 0xe9 );
519QUType_charstar static_QUType_charstar;
520const QUuid *QUType_charstar::uuid() const { return &TID_QUType_charstar; }
521const char *QUType_charstar::desc() const { return "char*"; }
522
523void QUType_charstar::set( QUObject *o, const char* v, bool take )
524{
525 if ( take ) {
526 if ( v ) {
527 o->payload.charstar.ptr = new char[ strlen(v) + 1 ];
528 strcpy( o->payload.charstar.ptr, v );
529 } else {
530 o->payload.charstar.ptr = 0;
531 }
532 o->payload.charstar.owner = TRUE;
533 } else {
534 o->payload.charstar.ptr = (char*) v;
535 o->payload.charstar.owner = FALSE;
536 }
537 o->type = this;
538}
539
540bool QUType_charstar::canConvertFrom( QUObject *o, QUType *t )
541{
542 return t->canConvertTo( o, this );
543}
544
545bool QUType_charstar::canConvertTo( QUObject *, QUType * )
546{
547 return FALSE;
548}
549
550bool QUType_charstar::convertFrom( QUObject *o, QUType *t )
551{
552 return t->convertTo( o, this );
553}
554
555bool QUType_charstar::convertTo( QUObject *, QUType * )
556{
557 return FALSE;
558}
559
560void QUType_charstar::clear( QUObject *o )
561{
562 if ( o->payload.charstar.owner )
563 delete [] o->payload.charstar.ptr;
564 o->payload.charstar.ptr = 0;
565}
566
567int QUType_charstar::serializeTo( QUObject *, QUBuffer * )
568{
569 return 0;
570}
571
572int QUType_charstar::serializeFrom( QUObject *, QUBuffer * )
573{
574 return 0;
575}
576
577
578// Qt specific types
579
580// {44C2A547-01E7-4e56-8559-35AF9D2F42B7}
581const QUuid TID_QUType_QString( 0x44c2a547, 0x1e7, 0x4e56, 0x85, 0x59, 0x35, 0xaf, 0x9d, 0x2f, 0x42, 0xb7 );
582QUType_QString static_QUType_QString;
583const QUuid *QUType_QString::uuid() const { return &TID_QUType_QString; }
584const char *QUType_QString::desc() const { return "QString"; }
585
586void QUType_QString::set( QUObject *o, const QString& v )
587{
588 o->payload.ptr = new QString( v );
589 o->type = this;
590}
591
592bool QUType_QString::canConvertFrom( QUObject *o, QUType *t )
593{
594 if ( isEqual( t, &static_QUType_charstar ) ||
595 isEqual( t, &static_QUType_double ) ||
596 isEqual( t, &static_QUType_float ) ||
597 isEqual( t, &static_QUType_int ) )
598 return TRUE;
599
600 return t->canConvertTo( o, this );
601}
602
603bool QUType_QString::canConvertTo( QUObject * /*o*/, QUType *t )
604{
605 return isEqual( t, &static_QUType_charstar ) ||
606 isEqual( t, &static_QUType_int ) ||
607 isEqual( t, &static_QUType_double ) ||
608 isEqual( t, &static_QUType_float );
609}
610
611bool QUType_QString::convertFrom( QUObject *o, QUType *t )
612{
613 QString *str = 0;
614 if ( isEqual( t, &static_QUType_charstar ) )
615 str = new QString( o->payload.charstar.ptr );
616 else if ( isEqual( t, &static_QUType_double ) )
617 str = new QString( QString::number( o->payload.d ) );
618 else if ( isEqual( t, &static_QUType_float ) )
619 str = new QString( QString::number( o->payload.f ) );
620 else if ( isEqual( t, &static_QUType_int ) )
621 str = new QString( QString::number( o->payload.i ) );
622 else
623 return t->convertTo( o, this );
624
625 o->type->clear( o );
626 o->payload.ptr = str;
627 o->type = this;
628 return TRUE;
629}
630
631bool QUType_QString::convertTo( QUObject *o, QUType *t )
632{
633 QString *str = (QString *)o->payload.ptr;
634 if ( isEqual( t, &static_QUType_charstar ) ) {
635 o->payload.charstar.ptr = qstrdup( str->local8Bit().data() );
636 o->payload.charstar.owner = TRUE;
637 o->type = &static_QUType_charstar;
638 } else if ( isEqual( t, &static_QUType_int ) ) {
639 o->payload.l = str->toLong();
640 o->type = &static_QUType_int;
641 } else if ( isEqual( t, &static_QUType_double ) ) {
642 o->payload.d = str->toDouble();
643 o->type = &static_QUType_double;
644 } else if ( isEqual( t, &static_QUType_float ) ) {
645 o->payload.d = str->toFloat();
646 o->type = &static_QUType_float;
647 } else {
648 return FALSE;
649 }
650 delete str;
651 return TRUE;
652}
653
654int QUType_QString::serializeTo( QUObject *, QUBuffer * )
655{
656 return 0;
657}
658
659int QUType_QString::serializeFrom( QUObject *, QUBuffer * )
660{
661 return 0;
662}
663
664void QUType_QString::clear( QUObject *o )
665{
666 delete (QString*)o->payload.ptr;
667 o->payload.ptr = 0;
668}