@@ -354,3 +354,113 @@ public func math_set_precision(_ precision: Int32) {
354354public func math_get_precision( ) -> Int32 {
355355 return Int32 ( MathSettings . shared. precisionInt)
356356}
357+
358+ // MARK: - Pronunciation
359+
360+ @_cdecl ( " math_spelled_out " )
361+ public func math_spelled_out( _ math: UnsafeMutableRawPointer ? , _ buffer: UnsafeMutablePointer < CChar > ? , _ bufferSize: Int ) -> Int32 {
362+ guard let box = toMathBox ( math) , let buffer = buffer, bufferSize > 0 else {
363+ return - 4 // MATH_ERROR_NULL_POINTER
364+ }
365+
366+ let str = box. value. spelledOut
367+ guard let cString = str. cString ( using: . utf8) , cString. count <= bufferSize else {
368+ return - 3 // MATH_ERROR_OUT_OF_RANGE
369+ }
370+
371+ cString. withUnsafeBufferPointer { ptr in
372+ buffer. update ( from: ptr. baseAddress!, count: min ( ptr. count, bufferSize) )
373+ }
374+
375+ return 0 // MATH_SUCCESS
376+ }
377+
378+ @_cdecl ( " math_spelled_aviation " )
379+ public func math_spelled_aviation( _ math: UnsafeMutableRawPointer ? , _ buffer: UnsafeMutablePointer < CChar > ? , _ bufferSize: Int ) -> Int32 {
380+ guard let box = toMathBox ( math) , let buffer = buffer, bufferSize > 0 else {
381+ return - 4 // MATH_ERROR_NULL_POINTER
382+ }
383+
384+ let str = box. value. spelledAviation
385+ guard let cString = str. cString ( using: . utf8) , cString. count <= bufferSize else {
386+ return - 3 // MATH_ERROR_OUT_OF_RANGE
387+ }
388+
389+ cString. withUnsafeBufferPointer { ptr in
390+ buffer. update ( from: ptr. baseAddress!, count: min ( ptr. count, bufferSize) )
391+ }
392+
393+ return 0 // MATH_SUCCESS
394+ }
395+
396+ // MARK: - Constants
397+
398+ @_cdecl ( " math_const_e " )
399+ public func math_const_e( ) -> UnsafeMutableRawPointer ? {
400+ return fromMath ( MathConstants . e)
401+ }
402+
403+ @_cdecl ( " math_const_pi " )
404+ public func math_const_pi( ) -> UnsafeMutableRawPointer ? {
405+ return fromMath ( MathConstants . pi)
406+ }
407+
408+ @_cdecl ( " math_const_tau " )
409+ public func math_const_tau( ) -> UnsafeMutableRawPointer ? {
410+ return fromMath ( ExtendedMathConstants . tau)
411+ }
412+
413+ @_cdecl ( " math_const_phi " )
414+ public func math_const_phi( ) -> UnsafeMutableRawPointer ? {
415+ return fromMath ( ExtendedMathConstants . φ)
416+ }
417+
418+ @_cdecl ( " math_const_sqrt2 " )
419+ public func math_const_sqrt2( ) -> UnsafeMutableRawPointer ? {
420+ return fromMath ( MathConstants . sqrt2)
421+ }
422+
423+ @_cdecl ( " math_const_sqrt3 " )
424+ public func math_const_sqrt3( ) -> UnsafeMutableRawPointer ? {
425+ return fromMath ( MathConstants . sqrt3)
426+ }
427+
428+ @_cdecl ( " math_const_speed_of_light " )
429+ public func math_const_speed_of_light( ) -> UnsafeMutableRawPointer ? {
430+ return fromMath ( PhysicsConstants . c)
431+ }
432+
433+ @_cdecl ( " math_const_planck " )
434+ public func math_const_planck( ) -> UnsafeMutableRawPointer ? {
435+ return fromMath ( PhysicsConstants . h)
436+ }
437+
438+ @_cdecl ( " math_const_gravitational " )
439+ public func math_const_gravitational( ) -> UnsafeMutableRawPointer ? {
440+ return fromMath ( PhysicsConstants . G)
441+ }
442+
443+ @_cdecl ( " math_const_boltzmann " )
444+ public func math_const_boltzmann( ) -> UnsafeMutableRawPointer ? {
445+ return fromMath ( PhysicsConstants . boltzmannConstant)
446+ }
447+
448+ @_cdecl ( " math_const_avogadro " )
449+ public func math_const_avogadro( ) -> UnsafeMutableRawPointer ? {
450+ return fromMath ( PhysicsConstants . avogadroConstant)
451+ }
452+
453+ @_cdecl ( " math_const_electron_mass " )
454+ public func math_const_electron_mass( ) -> UnsafeMutableRawPointer ? {
455+ return fromMath ( PhysicsConstants . electronMass)
456+ }
457+
458+ @_cdecl ( " math_const_proton_mass " )
459+ public func math_const_proton_mass( ) -> UnsafeMutableRawPointer ? {
460+ return fromMath ( PhysicsConstants . protonMass)
461+ }
462+
463+ @_cdecl ( " math_const_elementary_charge " )
464+ public func math_const_elementary_charge( ) -> UnsafeMutableRawPointer ? {
465+ return fromMath ( PhysicsConstants . elementaryCharge)
466+ }
0 commit comments