Wish BImplicit construction and implicit type conversion using XML

santook

Member
It is hoped that the following versions can support the XML file of the class library to add a description to realize the implicit initialization and implicit type conversion of the class, as shown below.
B4X:
Sub Process_Globals
    Public Serial1 As Serial
    Public tmp As SensorTempture(17)
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    Log("Tempture:",tmp)
    Log("Compensation value:",tmp+1.27)
    if tmp then
         Log("Temperature overrun!)
    end if
End Sub

The corresponding XML description looks like this
XML:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
    <doclet-version-NOT-library-version>1.00</doclet-version-NOT-library-version>
  <class>
    <name>B4R::rSensorTempture</name>
    <shortname>SensorTempture</shortname>

    <!--Use XML to describe the implemented constructor-->
    <Constructor>
      <name DesignerName="Begin">Begin</name>
      <comment>Initialize sensor
PinNum - ADC pin used by sensor
      </comment>
      <parameter>
        <name>PinNum</name>
        <type>Byte</type>
      </parameter>
      <returntype>void</returntype>
    </Constructor>

    <!--Implicit type conversion using XML description-->
    <TypeConversion>
      <name DesignerName="GetValue">GetValue</name>
      <comment>Returns the value of the read sensor
      </comment>
      <returntype>float</returntype>
    </TypeConversion>

    <TypeConversion>
      <name DesignerName="IsAlarm">IsAlarm</name>
      <comment>Returns whether the sensor gives an alarm
      </comment>
      <returntype>Boolean</returntype>
    </TypeConversion>

    <!-- Operator overloading through XML description-->
    <Operator>
      <name DesignerName="Add">+</name>
      <comment>Compensation calculation on actual temperature
e - The compensation value
      </comment>
      <parameter>
        <name>e</name>
        <type>Float</type>
      </parameter>
      <returntype>Float</returntype>
    </Operator>
  </class>
    <version>1.0</version>
</root>
 
Top