]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/C/VfrCompile/Pccts/h/ATokPtrImpl.h
a1efc3b3b98fbcc359a1dd329e802f4138a43f4c
[mirror_edk2.git] / BaseTools / Source / C / VfrCompile / Pccts / h / ATokPtrImpl.h
1 /*
2 * ATokPtrImpl.h (formerly ATokPtr.cpp)
3 *
4 * This is #included in ATokBuffer.cpp for historical reasons.
5 * It has been renamed because of problems with the .cpp extension
6 * when used with IDE.
7 *
8 *
9 * ANTLRToken MUST be defined before entry to this file.
10 *
11 * SOFTWARE RIGHTS
12 *
13 * We reserve no LEGAL rights to the Purdue Compiler Construction Tool
14 * Set (PCCTS) -- PCCTS is in the public domain. An individual or
15 * company may do whatever they wish with source code distributed with
16 * PCCTS or the code generated by PCCTS, including the incorporation of
17 * PCCTS, or its output, into commerical software.
18 *
19 * We encourage users to develop software with PCCTS. However, we do ask
20 * that credit is given to us for developing PCCTS. By "credit",
21 * we mean that if you incorporate our source code into one of your
22 * programs (commercial product, research project, or otherwise) that you
23 * acknowledge this fact somewhere in the documentation, research report,
24 * etc... If you like PCCTS and have developed a nice tool with the
25 * output, please mention that you developed it using PCCTS. In
26 * addition, we ask that this header remain intact in our source code.
27 * As long as these guidelines are kept, we expect to continue enhancing
28 * this system and expect to make other tools available as they are
29 * completed.
30 *
31 * ANTLR 1.33
32 * Written by Russell Quong June 30, 1995
33 * Adapted by Terence Parr to ANTLR stuff
34 * Parr Research Corporation
35 * with Purdue University and AHPCRC, University of Minnesota
36 * 1989-2000
37 */
38
39 #include "pcctscfg.h"
40
41 PCCTS_NAMESPACE_STD
42
43 #include "ATokPtr.h"
44
45 void ANTLRTokenPtr::ref() const
46 {
47 if (ptr_ != NULL) {
48 ptr_->ref();
49 }
50 }
51
52 void ANTLRTokenPtr::deref()
53 {
54 if (ptr_ != NULL)
55 {
56 ptr_->deref();
57 if ( ptr_->nref()==0 )
58 {
59 delete ptr_;
60 ptr_ = NULL;
61 }
62 }
63 }
64
65 ANTLRTokenPtr::~ANTLRTokenPtr()
66 {
67 deref();
68 }
69
70 //
71 // 8-Apr-97 MR1 Make operator -> a const member function
72 // as weall as some other member functions
73 //
74 ANTLRTokenPtr& ANTLRTokenPtr::operator = (const ANTLRTokenPtr & lhs) // MR1
75 {
76 lhs.ref(); // protect against "xp = xp"; ie same underlying object
77 deref();
78 ptr_ = lhs.ptr_;
79 return *this;
80 }
81
82 ANTLRTokenPtr& ANTLRTokenPtr::operator = (ANTLRAbstractToken *addr)
83 {
84 if (addr != NULL) {
85 addr->ref();
86 }
87 deref();
88 ptr_ = addr;
89 return *this;
90 }