Skip to content

Commit bc7b2fb

Browse files
committed
export color and point, add serializer for uint64 and float
1 parent cd816d4 commit bc7b2fb

File tree

4 files changed

+44
-30
lines changed

4 files changed

+44
-30
lines changed

package/Codegen/TSTypes.cs

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,15 @@ public virtual string TransformText()
9898
import { NativeXamlControl } from './NativeXamlControl';
9999
import { findNodeHandle, UIManager } from 'react-native';
100100
101-
import type { Point } from './Props';
101+
import type { Point, Color } from './Props';
102+
103+
export type { Point, Color };
102104
103105
const xamlCommands = UIManager.getViewManagerConfig('XamlControl').Commands;
104106
105107
");
106108

107-
#line 35 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
109+
#line 37 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
108110

109111
foreach (var type in Types.Where(t => Util.HasCtor(t))) {
110112
var ns = Util.GetTSNamespace(type);
@@ -114,126 +116,126 @@ public virtual string TransformText()
114116
#line hidden
115117
this.Write("export namespace ");
116118

117-
#line 39 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
119+
#line 41 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
118120
this.Write(this.ToStringHelper.ToStringWithCulture(ns));
119121

120122
#line default
121123
#line hidden
122124
this.Write(" {\r\n");
123125

124-
#line 40 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
126+
#line 42 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
125127
}
126128

127129
#line default
128130
#line hidden
129131
this.Write("export type ");
130132

131-
#line 41 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
133+
#line 43 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
132134
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(type)));
133135

134136
#line default
135137
#line hidden
136138
this.Write("Props = Omit<");
137139

138-
#line 41 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
140+
#line 43 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
139141
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetNativePropsName(type)));
140142

141143
#line default
142144
#line hidden
143145
this.Write(", \'type\'>;\r\n\r\nexport class ");
144146

145-
#line 43 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
147+
#line 45 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
146148
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(type)));
147149

148150
#line default
149151
#line hidden
150152
this.Write(" extends React.Component<");
151153

152-
#line 43 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
154+
#line 45 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
153155
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(type)));
154156

155157
#line default
156158
#line hidden
157159
this.Write("Props> {\r\n render() {\r\n return <NativeXamlControl {...this.props} type=\'");
158160

159-
#line 45 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
161+
#line 47 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
160162
this.Write(this.ToStringHelper.ToStringWithCulture(type.GetFullName()));
161163

162164
#line default
163165
#line hidden
164166
this.Write("\' />;\r\n }\r\n");
165167

166-
#line 47 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
168+
#line 49 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
167169
foreach (var command in Util.GetCommands(type.GetFullName())) {
168170

169171
#line default
170172
#line hidden
171173
this.Write(" static ");
172174

173-
#line 48 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
175+
#line 50 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
174176
this.Write(this.ToStringHelper.ToStringWithCulture(command.Name));
175177

176178
#line default
177179
#line hidden
178180
this.Write("(ref: React.MutableRefObject<");
179181

180-
#line 48 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
182+
#line 50 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
181183
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(type)));
182184

183185
#line default
184186
#line hidden
185187
this.Write(">, args: ");
186188

187-
#line 48 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
189+
#line 50 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
188190
this.Write(this.ToStringHelper.ToStringWithCulture(command.TSArgTypes != null ? command.TSArgTypes : "any[]"));
189191

190192
#line default
191193
#line hidden
192194
this.Write(") {\r\n const tag = findNodeHandle(ref.current);\r\n UIManager.dispatchViewMana" +
193195
"gerCommand(tag, xamlCommands.");
194196

195-
#line 50 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
197+
#line 52 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
196198
this.Write(this.ToStringHelper.ToStringWithCulture(command.Name));
197199

198200
#line default
199201
#line hidden
200202
this.Write(", ");
201203

202-
#line 50 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
204+
#line 52 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
203205
this.Write(this.ToStringHelper.ToStringWithCulture(command.TSArgTypes != null ? "[args]" : "args"));
204206

205207
#line default
206208
#line hidden
207209
this.Write(");\r\n }\r\n");
208210

209-
#line 52 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
211+
#line 54 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
210212
}
211213

212214
#line default
213215
#line hidden
214216
this.Write("};\r\n");
215217

216-
#line 54 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
218+
#line 56 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
217219
if (ns != "") {
218220

219221
#line default
220222
#line hidden
221223
this.Write("}\r\n");
222224

223-
#line 56 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
225+
#line 58 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
224226
}
225227

226228
#line default
227229
#line hidden
228230

229-
#line 57 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
231+
#line 59 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
230232
}
231233

232234
#line default
233235
#line hidden
234236
this.Write("\r\n");
235237

236-
#line 59 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
238+
#line 61 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
237239
foreach (var ea in Util.eventArgsTypes) {
238240
var ns = Util.GetTSNamespace(ea);
239241
if (ns != "") {
@@ -242,14 +244,14 @@ public virtual string TransformText()
242244
#line hidden
243245
this.Write("export namespace ");
244246

245-
#line 62 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
247+
#line 64 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
246248
this.Write(this.ToStringHelper.ToStringWithCulture(ns));
247249

248250
#line default
249251
#line hidden
250252
this.Write(" {\r\n");
251253

252-
#line 63 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
254+
#line 65 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
253255

254256
}
255257

@@ -258,41 +260,41 @@ public virtual string TransformText()
258260
#line hidden
259261
this.Write("export type ");
260262

261-
#line 66 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
263+
#line 68 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
262264
this.Write(this.ToStringHelper.ToStringWithCulture(ea.GetName()));
263265

264266
#line default
265267
#line hidden
266268
this.Write(" = ");
267269

268-
#line 66 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
270+
#line 68 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
269271
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetEventArgsTSType(ea, "Native")));
270272

271273
#line default
272274
#line hidden
273275
this.Write("; // ");
274276

275-
#line 66 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
277+
#line 68 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
276278
this.Write(this.ToStringHelper.ToStringWithCulture(ea.GetFullName()));
277279

278280
#line default
279281
#line hidden
280282
this.Write(" \r\n");
281283

282-
#line 67 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
284+
#line 69 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
283285
if (ns != "") {
284286

285287
#line default
286288
#line hidden
287289
this.Write("}\r\n");
288290

289-
#line 69 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
291+
#line 71 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
290292
}
291293

292294
#line default
293295
#line hidden
294296

295-
#line 70 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
297+
#line 72 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSTypes.tt"
296298
}
297299

298300
#line default

package/Codegen/TSTypes.tt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ import React from 'react';
2828
import { NativeXamlControl } from './NativeXamlControl';
2929
import { findNodeHandle, UIManager } from 'react-native';
3030

31-
import type { Point } from './Props';
31+
import type { Point, Color } from './Props';
32+
33+
export type { Point, Color };
3234

3335
const xamlCommands = UIManager.getViewManagerConfig('XamlControl').Commands;
3436

package/src/Types.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ import React from 'react';
333333
import { NativeXamlControl } from './NativeXamlControl';
334334
import { findNodeHandle, UIManager } from 'react-native';
335335

336-
import type { Point } from './Props';
336+
import type { Point, Color } from './Props';
337+
338+
export type { Point, Color };
337339

338340
const xamlCommands = UIManager.getViewManagerConfig('XamlControl').Commands;
339341

package/windows/ReactNativeXaml/XamlObject.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,14 @@ facebook::jsi::Value XamlObject::IInspectableToValue(jsi::Runtime& rt, const win
193193
assert((v < std::numeric_limits<int32_t>::max()) && (v > std::numeric_limits<int32_t>::min()));
194194
return jsi::Value(refInt64.GetInt32());
195195
}
196+
else if (auto refUInt64 = o.try_as<winrt::Windows::Foundation::IReference<uint64_t>>()) {
197+
auto v = refUInt64.GetUInt64();
198+
assert((v < std::numeric_limits<int32_t>::max()) && (v > std::numeric_limits<int32_t>::min()));
199+
return jsi::Value(refInt64.GetInt32());
200+
}
201+
else if (auto refFloat= o.try_as<winrt::Windows::Foundation::IReference<float>>()) {
202+
return jsi::Value(static_cast<double>(refFloat.GetSingle()));
203+
}
196204
else if (auto refDouble = o.try_as<winrt::Windows::Foundation::IReference<double>>()) {
197205
return jsi::Value(refDouble.GetDouble());
198206
}

0 commit comments

Comments
 (0)