Coconut Framework  beta
CNNumber.h
Go to the documentation of this file.
1 
8 #ifndef CNNUMBER_H
9 #define CNNUMBER_H
10 
11 #include "CNObject.h"
12 #include "CNType.h"
13 #include <stdio.h>
14 #include <stdint.h>
15 
20 } ;
21 
23 typedef enum {
32 } CNNumberType ;
33 
37 struct CNNumber {
43  union {
51  double floatValue ;
52  } ;
53 } ;
54 
62 struct CNNumber *
63 CNAllocateBooleanNumber(CNBoolean value, struct CNResource * resource) ;
64 
72 struct CNNumber *
73 CNAllocateSignedIntegerNumber(int64_t value, struct CNResource * resource) ;
74 
82 struct CNNumber *
83 CNAllocateUnsignedIntegerNumber(uint64_t value, struct CNResource * resource) ;
84 
92 struct CNNumber *
93 CNAllocateFloatNumber(double value, struct CNResource * resource) ;
94 
99 static inline void
101 {
102  CNReleaseObject(&(dst->superClass)) ;
103 }
104 
110 static inline struct CNObject *
112 {
113  return &(src->superClass) ;
114 }
115 
121 static inline CNNumberType
122 CNTypeOfNumber(const struct CNNumber * src)
123 {
124  return src->numberType ;
125 }
126 
132 static inline CNBoolean
133 CNBooleanNumber(const struct CNNumber * src)
134 {
135  return src->booleanValue ;
136 }
137 
143 static inline int64_t
144 CNSignedIntegerNumber(const struct CNNumber * src)
145 {
146  return src->signedIntegerValue ;
147 }
148 
154 static inline uint64_t
156 {
157  return src->unsignedIntegerValue ;
158 }
159 
165 static inline double
166 CNFloatNumber(const struct CNNumber * src)
167 {
168  return src->floatValue ;
169 }
170 
177 struct CNString *
178 CNNumberToString(struct CNNumber * src, struct CNResource * resource) ;
179 
185 void
186 CNPrintNumber(FILE * outfp, const struct CNNumber * src) ;
187 
188 #endif /* CNNUMBER_H */
Definition: CNNumber.h:27
struct CNNumber * CNAllocateUnsignedIntegerNumber(uint64_t value, struct CNResource *resource)
Allocate CNNumber object witl unsigned integer value.
Number data class.
Definition: CNNumber.h:37
double floatValue
Definition: CNNumber.h:51
struct CNNumber * CNAllocateSignedIntegerNumber(int64_t value, struct CNResource *resource)
Allocate CNNumber object witl signed integer value.
Root object.
Definition: CNObject.h:38
static double CNFloatNumber(const struct CNNumber *src)
Get floating point value in number object.
Definition: CNNumber.h:166
CNNumberType
Type of the context of the CNNumber.
Definition: CNNumber.h:23
static struct CNObject * CNObjectOfNumber(struct CNNumber *src)
Get super class of CNNumber.
Definition: CNNumber.h:111
void CNPrintNumber(FILE *outfp, const struct CNNumber *src)
Print number to the file.
int64_t signedIntegerValue
Definition: CNNumber.h:47
CNBoolean booleanValue
Definition: CNNumber.h:45
struct CNString * CNNumberToString(struct CNNumber *src, struct CNResource *resource)
Get string which presents the value of source number.
static CNBoolean CNBooleanNumber(const struct CNNumber *src)
Get boolean value in number object.
Definition: CNNumber.h:133
uint64_t unsignedIntegerValue
Definition: CNNumber.h:49
struct CNObject superClass
Definition: CNNumber.h:39
Fixed size string class.
Definition: CNString.h:27
Define CNObject data structure.
Methods for CNNumber class.
Definition: CNNumber.h:17
static int64_t CNSignedIntegerNumber(const struct CNNumber *src)
Get signed integer value in number object.
Definition: CNNumber.h:144
Definition: CNNumber.h:25
Methods for CNObject.
Definition: CNObject.h:29
static CNNumberType CNTypeOfNumber(const struct CNNumber *src)
Get context data of CNNumber.
Definition: CNNumber.h:122
Define primitive data types.
struct CNObjectMethods superClass
Definition: CNNumber.h:19
void CNReleaseObject(struct CNObject *dst)
Release the object.
Definition: CNNumber.h:31
static uint64_t CNUnsignedIntegerNumber(const struct CNNumber *src)
Get unsigned integer value in number object.
Definition: CNNumber.h:155
struct CNNumber * CNAllocateFloatNumber(double value, struct CNResource *resource)
Allocate CNNumber object witl floating value.
struct CNNumber * CNAllocateBooleanNumber(CNBoolean value, struct CNResource *resource)
Allocate CNNumber object witl boolean value.
Definition: CNNumber.h:29
unsigned int CNBoolean
Boolean type.
Definition: CNType.h:14
static void CNReleaseNumber(struct CNNumber *dst)
Release CNNumber object.
Definition: CNNumber.h:100
CNNumberType numberType
Definition: CNNumber.h:41