Package org.apache.etch.compiler.ast

Examples of org.apache.etch.compiler.ast.TypeRef


  public String getValidator( Named<?> named )
  {
    if (named instanceof Parameter)
    {
      Parameter param = (Parameter) named;
      TypeRef type = param.type();

      if (type.isBuiltin())
        return "Validator_" + type.type() + ".Get( " + type.dim()
          + " )";

      Named<?> n = type.getNamed( type.intf() );

      if (n.isBuiltin())
      {
        Builtin b = (Builtin) n;
        String cn = b.className();
        if (cn.endsWith( "?" ))
          cn = cn.substring( 0, cn.length()-1 );
       
        return String.format( "Validator_custom.Get( typeof(%s), %d, %s )",
          cn, type.dim(), b.allowSubclass() );
      }

      // Allow subclassing for etch defined structs and externs.

      if (n.isStruct() || n.isExcept())
        return String.format( "Validator_custom.Get( typeof(%s), %d, true )",
          n.efqname( this ), type.dim() );

      // Don't allow subclassing for externs or etch defined enums.

      if (!(n.isExtern() || n.isEnumx()))
        Assertion.check( n.isExtern() || n.isEnumx(),
          "n.isExtern() || n.isEnumx(): "+n );

      return "Validator_custom.Get( typeof ( "
        + n.efqname( this + " ), " + type.dim()
        + ", false )";
    }

    if (named instanceof Thrown)
    {
View Full Code Here


  public String getValidator( Named<?> named )
  {
    if (named instanceof Parameter)
    {
      Parameter param = (Parameter) named;
      TypeRef type = param.type();

      if (type.isBuiltin())
        return "Validator_"+type.type()+".get( "+type.dim()+" )";

      return "Validator_custom.getCustom( "+type.getNamed( type.intf() ).efqname( this )+".class, "+type.dim()+" )";
    }

    if (named instanceof Thrown)
    {
      Thrown thrown = (Thrown) named;
View Full Code Here

  public String getValidator( Named<?> named )
  {
    if (named instanceof Parameter)
    {
      Parameter param = (Parameter) named;
      TypeRef type = param.type();

      if (type.isBuiltin())
        return "Validator_" + type.type() + ".Get( " + type.dim()
          + " )";

      Named<?> n = type.getNamed( gIntf );

      if (n.isBuiltin())
      {
        Builtin b = (Builtin) n;
        String cn = b.className();
        if (cn.endsWith( "?" ))
          cn = cn.substring( 0, cn.length()-1 );
        return String.format( "Validator_custom.Get( typeof(%s), %d, %s )",
          cn, type.dim(), b.allowSubclass() );
      }

      // Allow subclassing for etch defined structs and externs.

      if (n.isStruct() || n.isExcept())
        return String.format( "Validator_custom.Get( typeof(%s), %d, true )",
          n.efqname( this ), type.dim() );

      // Don't allow subclassing for externs or etch defined enums.

      if (!(n.isExtern() || n.isEnumx()))
        Assertion.check( n.isExtern() || n.isEnumx(),
          "n.isExtern() || n.isEnumx(): "+n );



      return "Validator_custom.Get( typeof ( "
        + n.efqname( this + " ), " + type.dim()
        + ", false )";
    }

    if (named instanceof Thrown)
    {
View Full Code Here

  }

  public String getValidator(Service service, Named<?> named) {
    if (named instanceof Parameter) {
      Parameter param = (Parameter) named;
      TypeRef type = param.type();

      if (type.isBuiltin())
        return String.format("(etch_object*)etchvtor_%s_get( %d )", getValidatorStringForParam(param),
            type.dim());

      Named<?> n = type.getNamed(type.intf());

      if (n.isBuiltin()) {
        Builtin b = (Builtin) n;
        String cn = b.className();

        int i = cn.indexOf('<');
        if (i >= 0)
          cn = cn.substring(0, i);
       
        String classid = getClassIDBuiltin(b);
        String messagetype = getMessageTypeBuiltin(b);
        return String.format(
            "(etch_object*)etchvtor_custom_get(%s, CLASSID_%s, builtins._mt_%s,%d)",
              getEtchTypeForBuiltin(b),classid, messagetype, getDimensionForBuiltin(b));
      }


      if (n.isStruct() || n.isExcept() || n.isEnumx())
        return String.format(
            "(etch_object*)etchvtor_custom_get(ETCHTYPEB_USER, get_dynamic_classid_unique(&CLASSID_%s), %s_valufact_get_static()->_mt_%s, %d)",
                 n.efqname(this).toUpperCase(), getDefiningServiceNameOf(type), n.efqname(this), type.dim());

      if (n.isExtern())
      {
        Assertion.check(false,"extern type not supported for " + n );
      }
View Full Code Here

    addBuiltin( service, newName( "Set" ), "etch_set", true );
    addBuiltin(service, newName("Datetime"), "etch_date", false);
  }

  public String getValidatorStringForParam(Parameter param) {
    TypeRef type = param.type();
    return getValidatorStringForParam(type);
  }
View Full Code Here

  public String getValidator( Named<?> named )
  {
    if (named instanceof Parameter)
    {
      Parameter param = (Parameter) named;
      TypeRef type = param.type();

      if (type.isBuiltin())
        return String.format( "Validator_%s.get( %d )",
          type.type(), type.dim() );

      Named<?> n = type.getNamed( type.intf() );

      if (n.isBuiltin())
      {
        Builtin b = (Builtin) n;
        String cn = b.className();
       
        int i = cn.indexOf( '<' );
        if (i >= 0)
          cn = cn.substring( 0, i );
       
        return String.format( "Validator_custom.get( %s.class, %d, %s )",
          cn, type.dim(), b.allowSubclass() );
      }

      // Allow subclassing for etch defined structs and externs.

      if (n.isStruct() || n.isExcept())
        return String.format( "Validator_custom.get( %s.class, %d, true )",
          n.efqname( this ), type.dim() );

      // Don't allow subclassing for externs or etch defined enums.

      if (!(n.isExtern() || n.isEnumx()))
        Assertion.check( n.isExtern() || n.isEnumx(),
          "n.isExtern() || n.isEnumx(): "+n );

      return String.format( "Validator_custom.get( %s.class, %d, false )",
        n.efqname( this ), type.dim() );
    }

    if (named instanceof Thrown)
    {
      Thrown thrown = (Thrown) named;
View Full Code Here

  public String getValidator( Named<?> named )
  {
    if (named instanceof Parameter)
    {
      Parameter param = (Parameter) named;
      TypeRef type = param.type();

      if (type.isBuiltin())
        return String.format( "Validator_%s.get( %d )",
          type.type(), type.dim() );

      Named<?> n = type.getNamed( type.intf() );

      if (n.isBuiltin())
      {
        Builtin b = (Builtin) n;
        String cn = b.className();
       
        int i = cn.indexOf( '<' );
        if (i >= 0)
          cn = cn.substring( 0, i );
       
        return String.format( "Validator_custom.get( %s.class, %d, %s )",
          cn, type.dim(), b.allowSubclass() );
      }

      // Allow subclassing for etch defined structs and externs.

      if (n.isStruct() || n.isExcept())
        return String.format( "Validator_custom.get( %s.class, %d, true )",
          n.efqname( this ), type.dim() );

      // Don't allow subclassing for externs or etch defined enums.

      if (!(n.isExtern() || n.isEnumx()))
        Assertion.check( n.isExtern() || n.isEnumx(),
          "n.isExtern() || n.isEnumx(): "+n );

      return String.format( "Validator_custom.get( %s.class, %d, false )",
        n.efqname( this ), type.dim() );
    }

    if (named instanceof Thrown)
    {
      Thrown thrown = (Thrown) named;
View Full Code Here

  @Override
  public String getValidator(Named<?> named) {
    if (named instanceof Parameter) {
      Parameter param = (Parameter) named;
      TypeRef type = param.type();

      if (type.isBuiltin())
        return String.format("EtchValidator%s::Get(runtime, %d, tmpValue)",
            this.getValidatorStringForParam(param), type.dim());

      Named<?> n = type.getNamed(type.intf());

      if (n.isBuiltin()) {
        Builtin b = (Builtin) n;

        String cn = b.className();
        if (n.efqname(this).equals("EtchHashTable")) {
          cn += "<EtchObjectPtr, EtchObjectPtr>";
        }
        if (n.efqname(this).equals("EtchHashSet")) {
          cn += "<EtchObjectPtr>";
        }
        if (n.efqname(this).equals("EtchList")) {
          cn += "<EtchObjectPtr>";
        }

        /*
         * int i = cn.indexOf( '<' ); if (i >= 0) cn = cn.substring( 0, i );
         */
        return String.format(
            "EtchValidatorCustom::Get(runtime, %d, %s::TYPE(), %s, tmpValue);",
            type.dim(), cn, b.allowSubclass());
      }

      // Allow subclassing for etch defined structs and externs.

      if (n.isStruct() || n.isExcept()) {
        if (n.isStruct()) {
          Struct s = (Struct) n;
          return String.format(
              "EtchValidatorCustom::Get(runtime, %d, %s::TYPE(), true, tmpValue);",
              type.dim(), s
              .service().name() + "::" + n.efqname(this));
        }
        Except e = (Except) n;
        return String.format(
            "EtchValidatorCustom::Get(runtime, %d, %s::TYPE(), true, tmpValue);", type.dim(), e
            .service().name() + "::" + n.efqname(this));
      }
      // Don't allow subclassing for externs or etch defined enums.
      if (!(n.isExtern() || n.isEnumx()))
        Assertion.check(n.isExtern() || n.isEnumx(),
            "n.isExtern() || n.isEnumx(): " + n);
      Enumx e = (Enumx) n;
      return String.format(
          "EtchValidatorCustom::Get(runtime, %d, %s::TYPE(), false, tmpValue);",
          type.dim(), n.efqname(this));
    }

    if (named instanceof Thrown) {
      Thrown thrown = (Thrown) named;
      Except e = (Except) thrown.getNamed();
View Full Code Here

    this.addBuiltin(service, this.newName("Set"), "EtchHashSet", true);
    this.addBuiltin(service, this.newName("Datetime"), "EtchDate", false);
  }

  public String getValidatorStringForParam(Parameter param) {
    TypeRef type = param.type();
    return this.getValidatorStringForParam(type);
  }
View Full Code Here

//     tester_valufact_get_static()->_mt_tester_simpleStruct,
//        1))
   
    if (named instanceof Parameter) {
      Parameter param = (Parameter) named;
      TypeRef type = param.type();

      if (type.isBuiltin())
        return String.format("(etch_object*)etchvtor_%s_get( %d )", getValidatorStringForParam(param),
            type.dim());

      Named<?> n = type.getNamed(type.intf());

      if (n.isBuiltin()) {
        Builtin b = (Builtin) n;
        String cn = b.className();

        int i = cn.indexOf('<');
        if (i >= 0)
          cn = cn.substring(0, i);
       
        String classid = getClassIDBuiltin(b);
        String messagetype = getMessageTypeBuiltin(b);
        return String.format(
            "(etch_object*)etchvtor_custom_get(%s, CLASSID_%s, builtins._mt_%s,%d)",
              getEtchTypeForBuiltin(b),classid, messagetype, getDimensionForBuiltin(b));
      }


      if (n.isStruct() || n.isExcept() || n.isEnumx())
        return String.format(
            "(etch_object*)etchvtor_custom_get(ETCHTYPEB_USER, get_dynamic_classid_unique(&CLASSID_%s), %s_valufact_get_static()->_mt_%s, %d)",
                 n.efqname(this).toUpperCase(), service.name().toString().toLowerCase(), n.efqname(this), type.dim());

      if (n.isExtern())
      {
        Assertion.check(false,"extern type not supported for " + n );
      }
View Full Code Here

TOP

Related Classes of org.apache.etch.compiler.ast.TypeRef

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.