@@ -159,30 +159,26 @@ absl::StatusOr<Value> MaxList(ValueManager& value_manager,
159159
160160template <typename T, typename U>
161161absl::Status RegisterCrossNumericMin (FunctionRegistry& registry) {
162- CEL_RETURN_IF_ERROR (registry.Register (
163- BinaryFunctionAdapter<Value, T, U>::CreateDescriptor (
164- kMathMin , /* receiver_style=*/ false ),
165- BinaryFunctionAdapter<Value, T, U>::WrapFunction (Min<T, U>)));
162+ CEL_RETURN_IF_ERROR (
163+ (BinaryFunctionAdapter<Value, T, U>::RegisterGlobalOverload (
164+ kMathMin , Min<T, U>, registry)));
166165
167- CEL_RETURN_IF_ERROR (registry.Register (
168- BinaryFunctionAdapter<Value, U, T>::CreateDescriptor (
169- kMathMin , /* receiver_style=*/ false ),
170- BinaryFunctionAdapter<Value, U, T>::WrapFunction (Min<U, T>)));
166+ CEL_RETURN_IF_ERROR (
167+ (BinaryFunctionAdapter<Value, U, T>::RegisterGlobalOverload (
168+ kMathMin , Min<U, T>, registry)));
171169
172170 return absl::OkStatus ();
173171}
174172
175173template <typename T, typename U>
176174absl::Status RegisterCrossNumericMax (FunctionRegistry& registry) {
177- CEL_RETURN_IF_ERROR (registry.Register (
178- BinaryFunctionAdapter<Value, T, U>::CreateDescriptor (
179- kMathMax , /* receiver_style=*/ false ),
180- BinaryFunctionAdapter<Value, T, U>::WrapFunction (Max<T, U>)));
175+ CEL_RETURN_IF_ERROR (
176+ (BinaryFunctionAdapter<Value, T, U>::RegisterGlobalOverload (
177+ kMathMax , Max<T, U>, registry)));
181178
182- CEL_RETURN_IF_ERROR (registry.Register (
183- BinaryFunctionAdapter<Value, U, T>::CreateDescriptor (
184- kMathMax , /* receiver_style=*/ false ),
185- BinaryFunctionAdapter<Value, U, T>::WrapFunction (Max<U, T>)));
179+ CEL_RETURN_IF_ERROR (
180+ (BinaryFunctionAdapter<Value, U, T>::RegisterGlobalOverload (
181+ kMathMax , Max<U, T>, registry)));
186182
187183 return absl::OkStatus ();
188184}
@@ -303,189 +299,140 @@ Value BitShiftRightUint(ValueManager&, uint64_t lhs, int64_t rhs) {
303299
304300absl::Status RegisterMathExtensionFunctions (FunctionRegistry& registry,
305301 const RuntimeOptions& options) {
306- CEL_RETURN_IF_ERROR (registry.Register (
307- UnaryFunctionAdapter<Value, int64_t >::CreateDescriptor (
308- kMathMin , /* receiver_style=*/ false ),
309- UnaryFunctionAdapter<Value, int64_t >::WrapFunction (Identity<int64_t >)));
310- CEL_RETURN_IF_ERROR (registry.Register (
311- UnaryFunctionAdapter<Value, double >::CreateDescriptor (
312- kMathMin , /* receiver_style=*/ false ),
313- UnaryFunctionAdapter<Value, double >::WrapFunction (Identity<double >)));
314- CEL_RETURN_IF_ERROR (registry.Register (
315- UnaryFunctionAdapter<Value, uint64_t >::CreateDescriptor (
316- kMathMin , /* receiver_style=*/ false ),
317- UnaryFunctionAdapter<Value, uint64_t >::WrapFunction (Identity<uint64_t >)));
318- CEL_RETURN_IF_ERROR (registry.Register (
319- BinaryFunctionAdapter<Value, int64_t , int64_t >::CreateDescriptor (
320- kMathMin , /* receiver_style=*/ false ),
321- BinaryFunctionAdapter<Value, int64_t , int64_t >::WrapFunction (
322- Min<int64_t , int64_t >)));
323- CEL_RETURN_IF_ERROR (registry.Register (
324- BinaryFunctionAdapter<Value, double , double >::CreateDescriptor (
325- kMathMin , /* receiver_style=*/ false ),
326- BinaryFunctionAdapter<Value, double , double >::WrapFunction (
327- Min<double , double >)));
328- CEL_RETURN_IF_ERROR (registry.Register (
329- BinaryFunctionAdapter<Value, uint64_t , uint64_t >::CreateDescriptor (
330- kMathMin , /* receiver_style=*/ false ),
331- BinaryFunctionAdapter<Value, uint64_t , uint64_t >::WrapFunction (
332- Min<uint64_t , uint64_t >)));
302+ CEL_RETURN_IF_ERROR (
303+ (UnaryFunctionAdapter<Value, int64_t >::RegisterGlobalOverload (
304+ kMathMin , Identity<int64_t >, registry)));
305+ CEL_RETURN_IF_ERROR (
306+ (UnaryFunctionAdapter<Value, double >::RegisterGlobalOverload (
307+ kMathMin , Identity<double >, registry)));
308+ CEL_RETURN_IF_ERROR (
309+ (UnaryFunctionAdapter<Value, uint64_t >::RegisterGlobalOverload (
310+ kMathMin , Identity<uint64_t >, registry)));
311+ CEL_RETURN_IF_ERROR (
312+ (BinaryFunctionAdapter<Value, int64_t , int64_t >::RegisterGlobalOverload (
313+ kMathMin , Min<int64_t , int64_t >, registry)));
314+ CEL_RETURN_IF_ERROR (
315+ (BinaryFunctionAdapter<Value, double , double >::RegisterGlobalOverload (
316+ kMathMin , Min<double , double >, registry)));
317+ CEL_RETURN_IF_ERROR (
318+ (BinaryFunctionAdapter<Value, uint64_t , uint64_t >::RegisterGlobalOverload (
319+ kMathMin , Min<uint64_t , uint64_t >, registry)));
333320 CEL_RETURN_IF_ERROR ((RegisterCrossNumericMin<int64_t , uint64_t >(registry)));
334321 CEL_RETURN_IF_ERROR ((RegisterCrossNumericMin<int64_t , double >(registry)));
335322 CEL_RETURN_IF_ERROR ((RegisterCrossNumericMin<double , uint64_t >(registry)));
336- CEL_RETURN_IF_ERROR (registry.Register (
337- UnaryFunctionAdapter<absl::StatusOr<Value>, ListValue>::CreateDescriptor (
338- kMathMin , false ),
339- UnaryFunctionAdapter<absl::StatusOr<Value>, ListValue>::WrapFunction (
340- MinList)));
341-
342- CEL_RETURN_IF_ERROR (registry.Register (
343- UnaryFunctionAdapter<Value, int64_t >::CreateDescriptor (
344- kMathMax , /* receiver_style=*/ false ),
345- UnaryFunctionAdapter<Value, int64_t >::WrapFunction (Identity<int64_t >)));
346- CEL_RETURN_IF_ERROR (registry.Register (
347- UnaryFunctionAdapter<Value, double >::CreateDescriptor (
348- kMathMax , /* receiver_style=*/ false ),
349- UnaryFunctionAdapter<Value, double >::WrapFunction (Identity<double >)));
350- CEL_RETURN_IF_ERROR (registry.Register (
351- UnaryFunctionAdapter<Value, uint64_t >::CreateDescriptor (
352- kMathMax , /* receiver_style=*/ false ),
353- UnaryFunctionAdapter<Value, uint64_t >::WrapFunction (Identity<uint64_t >)));
354- CEL_RETURN_IF_ERROR (registry.Register (
355- BinaryFunctionAdapter<Value, int64_t , int64_t >::CreateDescriptor (
356- kMathMax , /* receiver_style=*/ false ),
357- BinaryFunctionAdapter<Value, int64_t , int64_t >::WrapFunction (
358- Max<int64_t , int64_t >)));
359- CEL_RETURN_IF_ERROR (registry.Register (
360- BinaryFunctionAdapter<Value, double , double >::CreateDescriptor (
361- kMathMax , /* receiver_style=*/ false ),
362- BinaryFunctionAdapter<Value, double , double >::WrapFunction (
363- Max<double , double >)));
364- CEL_RETURN_IF_ERROR (registry.Register (
365- BinaryFunctionAdapter<Value, uint64_t , uint64_t >::CreateDescriptor (
366- kMathMax , /* receiver_style=*/ false ),
367- BinaryFunctionAdapter<Value, uint64_t , uint64_t >::WrapFunction (
368- Max<uint64_t , uint64_t >)));
323+ CEL_RETURN_IF_ERROR ((
324+ UnaryFunctionAdapter<absl::StatusOr<Value>,
325+ ListValue>::RegisterGlobalOverload (kMathMin , MinList,
326+ registry)));
327+
328+ CEL_RETURN_IF_ERROR (
329+ (UnaryFunctionAdapter<Value, int64_t >::RegisterGlobalOverload (
330+ kMathMax , Identity<int64_t >, registry)));
331+ CEL_RETURN_IF_ERROR (
332+ (UnaryFunctionAdapter<Value, double >::RegisterGlobalOverload (
333+ kMathMax , Identity<double >, registry)));
334+ CEL_RETURN_IF_ERROR (
335+ (UnaryFunctionAdapter<Value, uint64_t >::RegisterGlobalOverload (
336+ kMathMax , Identity<uint64_t >, registry)));
337+ CEL_RETURN_IF_ERROR (
338+ (BinaryFunctionAdapter<Value, int64_t , int64_t >::RegisterGlobalOverload (
339+ kMathMax , Max<int64_t , int64_t >, registry)));
340+ CEL_RETURN_IF_ERROR (
341+ (BinaryFunctionAdapter<Value, double , double >::RegisterGlobalOverload (
342+ kMathMax , Max<double , double >, registry)));
343+ CEL_RETURN_IF_ERROR (
344+ (BinaryFunctionAdapter<Value, uint64_t , uint64_t >::RegisterGlobalOverload (
345+ kMathMax , Max<uint64_t , uint64_t >, registry)));
369346 CEL_RETURN_IF_ERROR ((RegisterCrossNumericMax<int64_t , uint64_t >(registry)));
370347 CEL_RETURN_IF_ERROR ((RegisterCrossNumericMax<int64_t , double >(registry)));
371348 CEL_RETURN_IF_ERROR ((RegisterCrossNumericMax<double , uint64_t >(registry)));
372- CEL_RETURN_IF_ERROR (registry.Register (
373- UnaryFunctionAdapter<absl::StatusOr<Value>, ListValue>::CreateDescriptor (
374- kMathMax , false ),
375- UnaryFunctionAdapter<absl::StatusOr<Value>, ListValue>::WrapFunction (
376- MaxList)));
377-
378- CEL_RETURN_IF_ERROR (registry.Register (
379- UnaryFunctionAdapter<double , double >::CreateDescriptor (
380- " math.ceil" , /* receiver_style=*/ false ),
381- UnaryFunctionAdapter<double , double >::WrapFunction (CeilDouble)));
382- CEL_RETURN_IF_ERROR (registry.Register (
383- UnaryFunctionAdapter<double , double >::CreateDescriptor (
384- " math.floor" , /* receiver_style=*/ false ),
385- UnaryFunctionAdapter<double , double >::WrapFunction (FloorDouble)));
386- CEL_RETURN_IF_ERROR (registry.Register (
387- UnaryFunctionAdapter<double , double >::CreateDescriptor (
388- " math.round" , /* receiver_style=*/ false ),
389- UnaryFunctionAdapter<double , double >::WrapFunction (RoundDouble)));
390- CEL_RETURN_IF_ERROR (registry.Register (
391- UnaryFunctionAdapter<double , double >::CreateDescriptor (
392- " math.trunc" , /* receiver_style=*/ false ),
393- UnaryFunctionAdapter<double , double >::WrapFunction (TruncDouble)));
394- CEL_RETURN_IF_ERROR (registry.Register (
395- UnaryFunctionAdapter<bool , double >::CreateDescriptor (
396- " math.isInf" , /* receiver_style=*/ false ),
397- UnaryFunctionAdapter<bool , double >::WrapFunction (IsInfDouble)));
398- CEL_RETURN_IF_ERROR (registry.Register (
399- UnaryFunctionAdapter<bool , double >::CreateDescriptor (
400- " math.isNaN" , /* receiver_style=*/ false ),
401- UnaryFunctionAdapter<bool , double >::WrapFunction (IsNaNDouble)));
402- CEL_RETURN_IF_ERROR (registry.Register (
403- UnaryFunctionAdapter<bool , double >::CreateDescriptor (
404- " math.isFinite" , /* receiver_style=*/ false ),
405- UnaryFunctionAdapter<bool , double >::WrapFunction (IsFiniteDouble)));
406- CEL_RETURN_IF_ERROR (registry.Register (
407- UnaryFunctionAdapter<double , double >::CreateDescriptor (
408- " math.abs" , /* receiver_style=*/ false ),
409- UnaryFunctionAdapter<double , double >::WrapFunction (AbsDouble)));
410- CEL_RETURN_IF_ERROR (registry.Register (
411- UnaryFunctionAdapter<Value, int64_t >::CreateDescriptor (
412- " math.abs" , /* receiver_style=*/ false ),
413- UnaryFunctionAdapter<Value, int64_t >::WrapFunction (AbsInt)));
414- CEL_RETURN_IF_ERROR (registry.Register (
415- UnaryFunctionAdapter<uint64_t , uint64_t >::CreateDescriptor (
416- " math.abs" , /* receiver_style=*/ false ),
417- UnaryFunctionAdapter<uint64_t , uint64_t >::WrapFunction (AbsUint)));
418- CEL_RETURN_IF_ERROR (registry.Register (
419- UnaryFunctionAdapter<double , double >::CreateDescriptor (
420- " math.sign" , /* receiver_style=*/ false ),
421- UnaryFunctionAdapter<double , double >::WrapFunction (SignDouble)));
422- CEL_RETURN_IF_ERROR (registry.Register (
423- UnaryFunctionAdapter<int64_t , int64_t >::CreateDescriptor (
424- " math.sign" , /* receiver_style=*/ false ),
425- UnaryFunctionAdapter<int64_t , int64_t >::WrapFunction (SignInt)));
426- CEL_RETURN_IF_ERROR (registry.Register (
427- UnaryFunctionAdapter<uint64_t , uint64_t >::CreateDescriptor (
428- " math.sign" , /* receiver_style=*/ false ),
429- UnaryFunctionAdapter<uint64_t , uint64_t >::WrapFunction (SignUint)));
430-
431- CEL_RETURN_IF_ERROR (registry.Register (
432- BinaryFunctionAdapter<int64_t , int64_t , int64_t >::CreateDescriptor (
433- " math.bitAnd" , /* receiver_style=*/ false ),
434- BinaryFunctionAdapter<int64_t , int64_t , int64_t >::WrapFunction (
435- BitAndInt)));
436- CEL_RETURN_IF_ERROR (registry.Register (
437- BinaryFunctionAdapter<uint64_t , uint64_t , uint64_t >::CreateDescriptor (
438- " math.bitAnd" , /* receiver_style=*/ false ),
439- BinaryFunctionAdapter<uint64_t , uint64_t , uint64_t >::WrapFunction (
440- BitAndUint)));
441- CEL_RETURN_IF_ERROR (registry.Register (
442- BinaryFunctionAdapter<int64_t , int64_t , int64_t >::CreateDescriptor (
443- " math.bitOr" , /* receiver_style=*/ false ),
444- BinaryFunctionAdapter<int64_t , int64_t , int64_t >::WrapFunction (
445- BitOrInt)));
446- CEL_RETURN_IF_ERROR (registry.Register (
447- BinaryFunctionAdapter<uint64_t , uint64_t , uint64_t >::CreateDescriptor (
448- " math.bitOr" , /* receiver_style=*/ false ),
449- BinaryFunctionAdapter<uint64_t , uint64_t , uint64_t >::WrapFunction (
450- BitOrUint)));
451- CEL_RETURN_IF_ERROR (registry.Register (
452- BinaryFunctionAdapter<int64_t , int64_t , int64_t >::CreateDescriptor (
453- " math.bitXor" , /* receiver_style=*/ false ),
454- BinaryFunctionAdapter<int64_t , int64_t , int64_t >::WrapFunction (
455- BitXorInt)));
456- CEL_RETURN_IF_ERROR (registry.Register (
457- BinaryFunctionAdapter<uint64_t , uint64_t , uint64_t >::CreateDescriptor (
458- " math.bitXor" , /* receiver_style=*/ false ),
459- BinaryFunctionAdapter<uint64_t , uint64_t , uint64_t >::WrapFunction (
460- BitXorUint)));
461- CEL_RETURN_IF_ERROR (registry.Register (
462- UnaryFunctionAdapter<int64_t , int64_t >::CreateDescriptor (
463- " math.bitNot" , /* receiver_style=*/ false ),
464- UnaryFunctionAdapter<int64_t , int64_t >::WrapFunction (BitNotInt)));
465- CEL_RETURN_IF_ERROR (registry.Register (
466- UnaryFunctionAdapter<uint64_t , uint64_t >::CreateDescriptor (
467- " math.bitNot" , /* receiver_style=*/ false ),
468- UnaryFunctionAdapter<uint64_t , uint64_t >::WrapFunction (BitNotUint)));
469- CEL_RETURN_IF_ERROR (registry.Register (
470- BinaryFunctionAdapter<Value, int64_t , int64_t >::CreateDescriptor (
471- " math.bitShiftLeft" , /* receiver_style=*/ false ),
472- BinaryFunctionAdapter<Value, int64_t , int64_t >::WrapFunction (
473- BitShiftLeftInt)));
474- CEL_RETURN_IF_ERROR (registry.Register (
475- BinaryFunctionAdapter<Value, uint64_t , int64_t >::CreateDescriptor (
476- " math.bitShiftLeft" , /* receiver_style=*/ false ),
477- BinaryFunctionAdapter<Value, uint64_t , int64_t >::WrapFunction (
478- BitShiftLeftUint)));
479- CEL_RETURN_IF_ERROR (registry.Register (
480- BinaryFunctionAdapter<Value, int64_t , int64_t >::CreateDescriptor (
481- " math.bitShiftRight" , /* receiver_style=*/ false ),
482- BinaryFunctionAdapter<Value, int64_t , int64_t >::WrapFunction (
483- BitShiftRightInt)));
484- CEL_RETURN_IF_ERROR (registry.Register (
485- BinaryFunctionAdapter<Value, uint64_t , int64_t >::CreateDescriptor (
486- " math.bitShiftRight" , /* receiver_style=*/ false ),
487- BinaryFunctionAdapter<Value, uint64_t , int64_t >::WrapFunction (
488- BitShiftRightUint)));
349+ CEL_RETURN_IF_ERROR ((
350+ UnaryFunctionAdapter<absl::StatusOr<Value>,
351+ ListValue>::RegisterGlobalOverload (kMathMax , MaxList,
352+ registry)));
353+
354+ CEL_RETURN_IF_ERROR (
355+ (UnaryFunctionAdapter<double , double >::RegisterGlobalOverload (
356+ " math.ceil" , CeilDouble, registry)));
357+ CEL_RETURN_IF_ERROR (
358+ (UnaryFunctionAdapter<double , double >::RegisterGlobalOverload (
359+ " math.floor" , FloorDouble, registry)));
360+ CEL_RETURN_IF_ERROR (
361+ (UnaryFunctionAdapter<double , double >::RegisterGlobalOverload (
362+ " math.round" , RoundDouble, registry)));
363+ CEL_RETURN_IF_ERROR (
364+ (UnaryFunctionAdapter<double , double >::RegisterGlobalOverload (
365+ " math.trunc" , TruncDouble, registry)));
366+ CEL_RETURN_IF_ERROR (
367+ (UnaryFunctionAdapter<bool , double >::RegisterGlobalOverload (
368+ " math.isInf" , IsInfDouble, registry)));
369+ CEL_RETURN_IF_ERROR (
370+ (UnaryFunctionAdapter<bool , double >::RegisterGlobalOverload (
371+ " math.isNaN" , IsNaNDouble, registry)));
372+ CEL_RETURN_IF_ERROR (
373+ (UnaryFunctionAdapter<bool , double >::RegisterGlobalOverload (
374+ " math.isFinite" , IsFiniteDouble, registry)));
375+ CEL_RETURN_IF_ERROR (
376+ (UnaryFunctionAdapter<double , double >::RegisterGlobalOverload (
377+ " math.abs" , AbsDouble, registry)));
378+ CEL_RETURN_IF_ERROR (
379+ (UnaryFunctionAdapter<Value, int64_t >::RegisterGlobalOverload (
380+ " math.abs" , AbsInt, registry)));
381+ CEL_RETURN_IF_ERROR (
382+ (UnaryFunctionAdapter<uint64_t , uint64_t >::RegisterGlobalOverload (
383+ " math.abs" , AbsUint, registry)));
384+ CEL_RETURN_IF_ERROR (
385+ (UnaryFunctionAdapter<double , double >::RegisterGlobalOverload (
386+ " math.sign" , SignDouble, registry)));
387+ CEL_RETURN_IF_ERROR (
388+ (UnaryFunctionAdapter<int64_t , int64_t >::RegisterGlobalOverload (
389+ " math.sign" , SignInt, registry)));
390+ CEL_RETURN_IF_ERROR (
391+ (UnaryFunctionAdapter<uint64_t , uint64_t >::RegisterGlobalOverload (
392+ " math.sign" , SignUint, registry)));
393+
394+ CEL_RETURN_IF_ERROR (
395+ (BinaryFunctionAdapter<int64_t , int64_t , int64_t >::RegisterGlobalOverload (
396+ " math.bitAnd" , BitAndInt, registry)));
397+ CEL_RETURN_IF_ERROR (
398+ (BinaryFunctionAdapter<uint64_t , uint64_t ,
399+ uint64_t >::RegisterGlobalOverload (" math.bitAnd" ,
400+ BitAndUint,
401+ registry)));
402+ CEL_RETURN_IF_ERROR (
403+ (BinaryFunctionAdapter<int64_t , int64_t , int64_t >::RegisterGlobalOverload (
404+ " math.bitOr" , BitOrInt, registry)));
405+ CEL_RETURN_IF_ERROR (
406+ (BinaryFunctionAdapter<uint64_t , uint64_t ,
407+ uint64_t >::RegisterGlobalOverload (" math.bitOr" ,
408+ BitOrUint,
409+ registry)));
410+ CEL_RETURN_IF_ERROR (
411+ (BinaryFunctionAdapter<int64_t , int64_t , int64_t >::RegisterGlobalOverload (
412+ " math.bitXor" , BitXorInt, registry)));
413+ CEL_RETURN_IF_ERROR (
414+ (BinaryFunctionAdapter<uint64_t , uint64_t ,
415+ uint64_t >::RegisterGlobalOverload (" math.bitXor" ,
416+ BitXorUint,
417+ registry)));
418+ CEL_RETURN_IF_ERROR (
419+ (UnaryFunctionAdapter<int64_t , int64_t >::RegisterGlobalOverload (
420+ " math.bitNot" , BitNotInt, registry)));
421+ CEL_RETURN_IF_ERROR (
422+ (UnaryFunctionAdapter<uint64_t , uint64_t >::RegisterGlobalOverload (
423+ " math.bitNot" , BitNotUint, registry)));
424+ CEL_RETURN_IF_ERROR (
425+ (BinaryFunctionAdapter<Value, int64_t , int64_t >::RegisterGlobalOverload (
426+ " math.bitShiftLeft" , BitShiftLeftInt, registry)));
427+ CEL_RETURN_IF_ERROR (
428+ (BinaryFunctionAdapter<Value, uint64_t , int64_t >::RegisterGlobalOverload (
429+ " math.bitShiftLeft" , BitShiftLeftUint, registry)));
430+ CEL_RETURN_IF_ERROR (
431+ (BinaryFunctionAdapter<Value, int64_t , int64_t >::RegisterGlobalOverload (
432+ " math.bitShiftRight" , BitShiftRightInt, registry)));
433+ CEL_RETURN_IF_ERROR (
434+ (BinaryFunctionAdapter<Value, uint64_t , int64_t >::RegisterGlobalOverload (
435+ " math.bitShiftRight" , BitShiftRightUint, registry)));
489436
490437 return absl::OkStatus ();
491438}
0 commit comments