~ubuntu-branches/ubuntu/maverick/freecad/maverick

« back to all changes in this revision

Viewing changes to src/CXX/cxxsupport.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV
  • Date: 2010-01-11 08:48:33 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100111084833-4g9vgdqbkw8u34zb
Tags: 0.9.2646.5-1
* New upstream version (closes: #561696).
* Added swig to Build-Depends (closes: #563523, #563772).
* Removed python-opencv from Build-Depends and Recommends (closes: #560768).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//-----------------------------------------------------------------------------
2
 
//
3
 
// Copyright (c) 1998 - 2007, The Regents of the University of California
4
 
// Produced at the Lawrence Livermore National Laboratory
5
 
// All rights reserved.
6
 
//
7
 
// This file is part of PyCXX. For details,see http://cxx.sourceforge.net/. The
8
 
// full copyright notice is contained in the file COPYRIGHT located at the root
9
 
// of the PyCXX distribution.
10
 
//
11
 
// Redistribution  and  use  in  source  and  binary  forms,  with  or  without
12
 
// modification, are permitted provided that the following conditions are met:
13
 
//
14
 
//  - Redistributions of  source code must  retain the above  copyright notice,
15
 
//    this list of conditions and the disclaimer below.
16
 
//  - Redistributions in binary form must reproduce the above copyright notice,
17
 
//    this  list of  conditions  and  the  disclaimer (as noted below)  in  the
18
 
//    documentation and/or materials provided with the distribution.
19
 
//  - Neither the name of the UC/LLNL nor  the names of its contributors may be
20
 
//    used to  endorse or  promote products derived from  this software without
21
 
//    specific prior written permission.
22
 
//
23
 
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT  HOLDERS AND CONTRIBUTORS "AS IS"
24
 
// AND ANY EXPRESS OR  IMPLIED WARRANTIES, INCLUDING,  BUT NOT  LIMITED TO, THE
25
 
// IMPLIED WARRANTIES OF MERCHANTABILITY AND  FITNESS FOR A PARTICULAR  PURPOSE
26
 
// ARE  DISCLAIMED.  IN  NO  EVENT  SHALL  THE  REGENTS  OF  THE  UNIVERSITY OF
27
 
// CALIFORNIA, THE U.S.  DEPARTMENT  OF  ENERGY OR CONTRIBUTORS BE  LIABLE  FOR
28
 
// ANY  DIRECT,  INDIRECT,  INCIDENTAL,  SPECIAL,  EXEMPLARY,  OR CONSEQUENTIAL
29
 
// DAMAGES (INCLUDING, BUT NOT  LIMITED TO, PROCUREMENT OF  SUBSTITUTE GOODS OR
30
 
// SERVICES; LOSS OF  USE, DATA, OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER
31
 
// CAUSED  AND  ON  ANY  THEORY  OF  LIABILITY,  WHETHER  IN  CONTRACT,  STRICT
32
 
// LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)  ARISING IN ANY  WAY
33
 
// OUT OF THE  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
34
 
// DAMAGE.
35
 
//
36
 
//-----------------------------------------------------------------------------
37
 
 
38
 
#include "CXX/Objects.hxx"
39
 
namespace Py {
40
 
 
41
 
Py_UNICODE unicode_null_string[1] = { 0 };
42
 
 
43
 
Type Object::type () const
44
 
45
 
    return Type (PyObject_Type (p), true);
46
 
}
47
 
 
48
 
String Object::str () const
49
 
{
50
 
    return String (PyObject_Str (p), true);
51
 
}
52
 
 
53
 
String Object::repr () const
54
 
55
 
    return String (PyObject_Repr (p), true);
56
 
}
57
 
 
58
 
std::string Object::as_string() const
59
 
{
60
 
    return static_cast<std::string>(str());
61
 
}
62
 
 
63
 
List Object::dir () const
64
 
        {
65
 
        return List (PyObject_Dir (p), true);
66
 
        }
67
 
 
68
 
bool Object::isType (const Type& t) const
69
 
70
 
    return type ().ptr() == t.ptr();
71
 
}
72
 
 
73
 
Char::operator String() const
74
 
{
75
 
    return String(ptr());
76
 
}
77
 
 
78
 
// TMM: non-member operaters for iterators - see above
79
 
// I've also made a bug fix in respect to the cxx code
80
 
// (dereffed the left.seq and right.seq comparison)
81
 
bool operator==(const Sequence::iterator& left, const Sequence::iterator& right)
82
 
{
83
 
    return left.eql( right );
84
 
}
85
 
 
86
 
bool operator!=(const Sequence::iterator& left, const Sequence::iterator& right)
87
 
{
88
 
    return left.neq( right );
89
 
}
90
 
 
91
 
bool operator< (const Sequence::iterator& left, const Sequence::iterator& right)
92
 
{
93
 
    return left.lss( right );
94
 
}
95
 
 
96
 
bool operator> (const Sequence::iterator& left, const Sequence::iterator& right)
97
 
{
98
 
    return left.gtr( right );
99
 
}
100
 
 
101
 
bool operator<=(const Sequence::iterator& left, const Sequence::iterator& right)
102
 
{
103
 
    return left.leq( right );
104
 
}
105
 
 
106
 
bool operator>=(const Sequence::iterator& left, const Sequence::iterator& right)
107
 
{
108
 
    return left.geq( right );
109
 
}
110
 
 
111
 
// now for const_iterator
112
 
bool operator==(const Sequence::const_iterator& left, const Sequence::const_iterator& right)
113
 
{
114
 
    return left.eql( right );
115
 
}
116
 
 
117
 
bool operator!=(const Sequence::const_iterator& left, const Sequence::const_iterator& right)
118
 
{
119
 
    return left.neq( right );
120
 
}
121
 
 
122
 
bool operator< (const Sequence::const_iterator& left, const Sequence::const_iterator& right)
123
 
{
124
 
    return left.lss( right );
125
 
}
126
 
 
127
 
bool operator> (const Sequence::const_iterator& left, const Sequence::const_iterator& right)
128
 
{
129
 
    return left.gtr( right );
130
 
}
131
 
 
132
 
bool operator<=(const Sequence::const_iterator& left, const Sequence::const_iterator& right)
133
 
{
134
 
    return left.leq( right );
135
 
}
136
 
 
137
 
bool operator>=(const Sequence::const_iterator& left, const Sequence::const_iterator& right)
138
 
{
139
 
    return left.geq( right );
140
 
}
141
 
 
142
 
// For mappings:
143
 
bool operator==(const Mapping::iterator& left, const Mapping::iterator& right)
144
 
{
145
 
    return left.eql( right );
146
 
}
147
 
 
148
 
bool operator!=(const Mapping::iterator& left, const Mapping::iterator& right)
149
 
{
150
 
    return left.neq( right );
151
 
}
152
 
 
153
 
// now for const_iterator
154
 
bool operator==(const Mapping::const_iterator& left, const Mapping::const_iterator& right)
155
 
{
156
 
    return left.eql( right );
157
 
}
158
 
 
159
 
bool operator!=(const Mapping::const_iterator& left, const Mapping::const_iterator& right)
160
 
{
161
 
    return left.neq( right );
162
 
}
163
 
 
164
 
// TMM: 31May'01 - Added the #ifndef so I can exclude iostreams.
165
 
#ifndef CXX_NO_IOSTREAMS
166
 
// output
167
 
 
168
 
std::ostream& operator<< (std::ostream& os, const Object& ob)
169
 
{
170
 
    return (os << static_cast<std::string>(ob.str()));
171
 
}  
172
 
#endif
173
 
 
174
 
} // Py