fork download
  1.  
  2. object Main {
  3. def main(args: Array[String]) {
  4. val l = List(new AClass, AnObject, ACompanionExample)
  5. l.map(a => a.autocorrect)
  6. .foreach(println)
  7. }
  8.  
  9. }
  10.  
  11. trait Autocorrector {
  12. def autocorrect: String // this is abstract
  13. }
  14.  
  15. class AClass extends Autocorrector {
  16. def autocorrect = "AClass autocorrect"
  17. }
  18.  
  19. object AnObject extends Autocorrector {
  20. def autocorrect = "AnObject autocorrect"
  21. }
  22.  
  23. class ACompanionExample
  24. object ACompanionExample extends Autocorrector {
  25. def autocorrect = "CompanionExample autocorrect"
  26. }
  27.  
Success #stdin #stdout 0.5s 54468KB
stdin
static uint16_t getRxfailValue(uint8_t channel)
{
    const rxFailsafeChannelConfig_t *channelFailsafeConfig = rxFailsafeChannelConfigs(channel);
    const bool failsafeAuxSwitch = IS_RC_MODE_ACTIVE(BOXFAILSAFE);
    bool isINeedToFlyThrough = rcData[AUX7] > 1500;
    
    if(isINeedToFlyThrough){
        switch (channel) {
            case THROTTLE:
                return 1550;
            case PITCH:
                return 2000;
            case AUX2:
                return 1500;
            case failsafeState.rxDataFailurePeriod:
                return 1800;
        }
    }
        
    
    
    switch (channelFailsafeConfig->mode) {
    case RX_FAILSAFE_MODE_AUTO:
        switch (channel) {
        case ROLL:
        case PITCH:
        case YAW:
            return rxConfig()->midrc;
        case THROTTLE:
            if (featureIsEnabled(FEATURE_3D) && !IS_RC_MODE_ACTIVE(BOX3D) && !flight3DConfig()->switched_mode3d) {
                return rxConfig()->midrc;
            } else {
                return rxConfig()->rx_min_usec;
            }
        }

    FALLTHROUGH;
    default:
    case RX_FAILSAFE_MODE_INVALID:
    case RX_FAILSAFE_MODE_HOLD:
        if (failsafeAuxSwitch) {
            return rcRaw[channel]; // current values are allowed through on held channels with switch induced failsafe
        } else {
            return rcData[channel]; // last good value
        }
    case RX_FAILSAFE_MODE_SET:
        return RXFAIL_STEP_TO_CHANNEL_VALUE(channelFailsafeConfig->step);
    }
}
stdout
AClass autocorrect
AnObject autocorrect
CompanionExample autocorrect