TextClass.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2021 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 
39 #ifndef Included_RexxText
40 #define Included_RexxText
41 
42 #include "ObjectClass.hpp"
43 
44 
45 /******************************************************************************/
46 /* REXX Kernel */
47 /* */
48 /* Primitive RexxText Class Definition */
49 /* */
50 /******************************************************************************/
51 
52 // Needs a specific metaclass because RexxText has some static fields that need to be marked for garbage collection.
53 class RexxTextClass : public RexxClass {
54  public:
55  inline RexxTextClass(RESTORETYPE restoreType) { ; };
56  void *operator new(size_t size, void *ptr) {return ptr;};
57  void *operator new (size_t);
58  void *operator new(size_t size, size_t size1, const char *className, RexxBehaviour *classBehave, RexxBehaviour *instance) { return new (size, className, classBehave, instance) RexxClass; }
59  inline void operator delete(void *, void *ptr) { }
60  inline void operator delete (void *) { }
61  inline void operator delete(void *, size_t, const char *, RexxBehaviour *, RexxBehaviour *) { }
62 
63  inline RexxTextClass() { ; };
64 
65  void live(size_t);
66  void liveGeneral(int reason);
67 };
68 
69 
70 // A RexxText is a RexxString by delegation, not by inheritance (don't inherit from RexxString)
71 class RexxText : public RexxObject
72 {
73 public:
74  inline void *operator new(size_t, void *ptr) { return ptr; }
75  inline void operator delete(void *, void *) { ; }
76  void *operator new(size_t);
77  inline void operator delete(void *) { ; }
78 
79  void live(size_t);
80  void liveGeneral(int reason);
81  void flatten(RexxEnvelope*);
82 
83  inline RexxText() { ; };
84  inline RexxText(RESTORETYPE restoreType) { ; };
85 
86  RexxObject *newRexx(RexxObject **, size_t, size_t);
87 
88  RexxString *primitiveMakeString(); // needed to convert "b"~text to string when calling left("b"~text, 1)
90 
91  RexxString *makeString(); // needed to convert "b"~text to string when calling "abc"~pos("b"~text)
92  RexxText *makeText();
93 
95 
96  static void createInstance();
97  static RexxTextClass *classInstance; // RexxCore.h #define TheRexxTextClass RexxText::classInstance
98 
99  static RexxText *nullText;
100 
101  static RexxText *newText(RexxString *s);
102  static RexxText *newText(const char *s, size_t l);
103 };
104 
106 {
107  return RexxText::newText(s);
108 }
109 
110 inline RexxText *new_text(const char *s, size_t l)
111 {
112  return RexxText::newText(s, l);
113 }
114 
115 inline RexxText *new_text(const char *s)
116 {
117  return new_text(s, strlen(s));
118 }
119 
120 
121 /******************************************************************************/
122 /* REXX Kernel */
123 /* */
124 /* Primitive Unicode Class Definition */
125 /* */
126 /******************************************************************************/
127 
128 class Unicode : public RexxObject
129 {
130 public:
131  inline void *operator new(size_t, void *ptr) { return ptr; }
132  inline void operator delete(void *, void *) { ; }
133  void *operator new(size_t);
134  inline void operator delete(void *) { ; }
135 
136  void live(size_t);
137  void liveGeneral(int reason);
138  void flatten(RexxEnvelope*);
139 
140  inline Unicode() { ; };
141  inline Unicode(RESTORETYPE restoreType) { ; };
142 
143  RexxObject *newRexx(RexxObject **, size_t, size_t);
144  RexxObject *copyRexx();
145  static void createInstance();
146  static RexxClass *classInstance; // RexxCore.h #define TheUnicodeClass Unicode::classInstance
147 
149 
166  RexxObject *utf8proc_transform(RexxString *str, RexxObject **named_arglist, size_t named_argcount);
167 
169 };
170 
171 #endif
RESTORETYPE
Definition: ObjectClass.hpp:82
RexxText * new_text(RexxString *s)
Definition: TextClass.hpp:105
RexxTextClass(RESTORETYPE restoreType)
Definition: TextClass.hpp:55
void liveGeneral(int reason)
Definition: TextClass.cpp:217
void live(size_t)
Definition: TextClass.cpp:209
void live(size_t)
Definition: TextClass.cpp:144
RexxText * makeText()
Definition: TextClass.cpp:180
void liveGeneral(int reason)
Definition: TextClass.cpp:149
static RexxText * newText(RexxString *s)
Definition: TextClass.cpp:61
RexxText * textValue()
Definition: TextClass.cpp:195
static RexxTextClass * classInstance
Definition: TextClass.hpp:97
void flatten(RexxEnvelope *)
Definition: TextClass.cpp:154
RexxString * makeString()
Definition: TextClass.cpp:174
RexxText * primitiveMakeText()
Definition: TextClass.cpp:168
RexxText(RESTORETYPE restoreType)
Definition: TextClass.hpp:84
static void createInstance()
Definition: TextClass.cpp:56
RexxString * primitiveMakeString()
Definition: TextClass.cpp:161
static RexxText * nullText
Definition: TextClass.hpp:99
RexxObject * newRexx(RexxObject **, size_t, size_t)
Definition: TextClass.cpp:126
RexxObject * copyRexx()
Definition: TextClass.cpp:330
RexxObject * utf8proc_transform(RexxString *str, RexxObject **named_arglist, size_t named_argcount)
Definition: TextClass.cpp:681
RexxInteger * utf8proc_graphemeBreak(RexxArray *)
Definition: TextClass.cpp:410
static RexxClass * classInstance
Definition: TextClass.hpp:146
RexxInteger * utf8proc_codepointCharWidth(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:573
RexxInteger * utf8proc_codepointCategory(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:422
RexxInteger * utf8proc_codepointBidiClass(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:473
RexxInteger * utf8proc_codepointToTitleSimple(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:639
static void createInstance()
Definition: TextClass.cpp:318
RexxString * utf8proc_version()
Definition: TextClass.cpp:393
RexxInteger * utf8proc_codepointControlBoundary(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:565
void live(size_t)
Definition: TextClass.cpp:342
RexxInteger * utf8proc_codepointToUpperSimple(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:632
RexxInteger * utf8proc_codepointIsLower(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:646
RexxString * unialgo_version()
Definition: TextClass.cpp:800
RexxInteger * utf8proc_codepointToLowerSimple(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:625
RexxInteger * utf8proc_codepointDecompositionType(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:517
RexxInteger * systemIsLittleEndian()
Definition: TextClass.cpp:359
void liveGeneral(int reason)
Definition: TextClass.cpp:347
RexxInteger * utf8proc_codepointBoundClass(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:585
void flatten(RexxEnvelope *)
Definition: TextClass.cpp:352
Unicode(RESTORETYPE restoreType)
Definition: TextClass.hpp:141
RexxInteger * utf8proc_codepointIsUpper(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:654
RexxInteger * utf8proc_codepointIgnorable(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:557
RexxInteger * utf8proc_codepointBidiMirrored(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:509
RexxObject * newRexx(RexxObject **, size_t, size_t)
Definition: TextClass.cpp:323
RexxInteger * utf8proc_codepointCombiningClass(RexxObject *rexxCodepoint)
Definition: TextClass.cpp:465