~ubuntu-branches/debian/experimental/nuitka/experimental

« back to all changes in this revision

Viewing changes to nuitka/build/include/nuitka/variables_parameters.hpp

  • Committer: Package Import Robot
  • Author(s): Kay Hayen
  • Date: 2014-10-05 19:28:20 UTC
  • mfrom: (1.1.30)
  • Revision ID: package-import@ubuntu.com-20141005192820-s06oca9rty517iy8
Tags: 0.5.5+ds-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//     Copyright 2014, Kay Hayen, mailto:kay.hayen@gmail.com
2
 
//
3
 
//     Part of "Nuitka", an optimizing Python compiler that is compatible and
4
 
//     integrates with CPython, but also works on its own.
5
 
//
6
 
//     Licensed under the Apache License, Version 2.0 (the "License");
7
 
//     you may not use this file except in compliance with the License.
8
 
//     You may obtain a copy of the License at
9
 
//
10
 
//        http://www.apache.org/licenses/LICENSE-2.0
11
 
//
12
 
//     Unless required by applicable law or agreed to in writing, software
13
 
//     distributed under the License is distributed on an "AS IS" BASIS,
14
 
//     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 
//     See the License for the specific language governing permissions and
16
 
//     limitations under the License.
17
 
//
18
 
#ifndef __NUITKA_VARIABLES_PARAMETERS_H__
19
 
#define __NUITKA_VARIABLES_PARAMETERS_H__
20
 
 
21
 
class PyObjectLocalParameterVariableWithDel
22
 
{
23
 
public:
24
 
    explicit PyObjectLocalParameterVariableWithDel( PyObject *object )
25
 
    {
26
 
        assertObject( object );
27
 
 
28
 
        this->object = object;
29
 
    }
30
 
 
31
 
    explicit PyObjectLocalParameterVariableWithDel()
32
 
    {
33
 
        this->object = NULL;
34
 
    }
35
 
 
36
 
    void setVariableValue( PyObject *object )
37
 
    {
38
 
        assertObject( object );
39
 
        assert( this->object == NULL);
40
 
        this->object = object;
41
 
    }
42
 
 
43
 
    ~PyObjectLocalParameterVariableWithDel()
44
 
    {
45
 
        Py_XDECREF( this->object );
46
 
    }
47
 
 
48
 
    inline bool isInitialized() const
49
 
    {
50
 
        return this->object != NULL;
51
 
    }
52
 
 
53
 
private:
54
 
 
55
 
    PyObjectLocalParameterVariableWithDel( const PyObjectLocalParameterVariableWithDel &other ) { assert( false ); }
56
 
 
57
 
public:
58
 
    PyObject *object;
59
 
};
60
 
 
61
 
class PyObjectLocalParameterVariableNoDel
62
 
{
63
 
public:
64
 
 
65
 
    explicit PyObjectLocalParameterVariableNoDel( PyObject *object )
66
 
    {
67
 
        assertObject( object );
68
 
 
69
 
        this->object = object;
70
 
    }
71
 
 
72
 
    explicit PyObjectLocalParameterVariableNoDel()
73
 
    {
74
 
        this->object = NULL;
75
 
    }
76
 
 
77
 
    void setVariableValue( PyObject *object )
78
 
    {
79
 
        assertObject( object );
80
 
        assert( this->object == NULL);
81
 
        this->object = object;
82
 
    }
83
 
 
84
 
    ~PyObjectLocalParameterVariableNoDel()
85
 
    {
86
 
        assertObject( this->object );
87
 
 
88
 
        Py_DECREF( this->object );
89
 
    }
90
 
 
91
 
    inline bool isInitialized() const
92
 
    {
93
 
        return true;
94
 
    }
95
 
 
96
 
private:
97
 
 
98
 
    PyObjectLocalParameterVariableNoDel( const PyObjectLocalParameterVariableNoDel &other ) { assert( false ); }
99
 
 
100
 
public:
101
 
    PyObject *object;
102
 
};
103
 
 
104
 
#endif