Examples of TypeMismatch


Examples of com.google.javascript.jscomp.TypeValidator.TypeMismatch

    JSType firstFunction = registry.createFunctionType(number, string);
    JSType secondFunction = registry.createFunctionType(string, bool);

    assertMismatches(
        Lists.newArrayList(
            new TypeMismatch(firstFunction, secondFunction, null),
            fromNatives(STRING_TYPE, BOOLEAN_TYPE),
            fromNatives(NUMBER_TYPE, STRING_TYPE)));
  }
View Full Code Here

Examples of com.google.javascript.jscomp.TypeValidator.TypeMismatch

    JSType firstFunction = registry.createFunctionType(number, string);
    JSType secondFunction = registry.createFunctionType(number, bool);

    assertMismatches(
        Lists.newArrayList(
            new TypeMismatch(firstFunction, secondFunction, null),
            fromNatives(STRING_TYPE, BOOLEAN_TYPE)));
  }
View Full Code Here

Examples of com.google.javascript.jscomp.TypeValidator.TypeMismatch

    assertMismatches(Collections.<TypeMismatch>emptyList());
  }

  private TypeMismatch fromNatives(JSTypeNative a, JSTypeNative b) {
    JSTypeRegistry registry = compiler.getTypeRegistry();
    return new TypeMismatch(
        registry.getNativeType(a), registry.getNativeType(b), null);
  }
View Full Code Here

Examples of org.omg.DynamicAny.DynAnyPackage.TypeMismatch

       org.omg.CORBA.TypeCode _type = TypeCode.originalType( tc );

       if( _type.kind() != org.omg.CORBA.TCKind.tk_union )
       {
           throw new TypeMismatch();
       }

       typeCode = _type;

       pos = 0;
View Full Code Here

Examples of org.omg.DynamicAny.DynAnyPackage.TypeMismatch

      throws InvalidValue, TypeMismatch
   {
      checkDestroyed ();
      if( ! type().equivalent( value.type() ))
      {
         throw new TypeMismatch();
      }

      try
      {
         typeCode = TypeCode.originalType( value.type() );
View Full Code Here

Examples of org.omg.DynamicAny.DynAnyPackage.TypeMismatch

      throws TypeMismatch
   {
      checkDestroyed ();
      if( ! dynAny.type().equivalent( discriminator.type() ))
      {
         throw new TypeMismatch();
      }
      discriminator = dynAny.to_any();
      pos = 1;

      /* check if the new discriminator is consistent with the
View Full Code Here

Examples of org.omg.DynamicAny.DynAnyPackage.TypeMismatch

      try
      {
         int def_idx = type().default_index();
         if( def_idx == -1 )
         {
            throw new TypeMismatch();
         }
         pos = 0;

         // do nothing if the discriminator is already set to a default value
         if (memberIndex != def_idx)
View Full Code Here

Examples of org.omg.DynamicAny.DynAnyPackage.TypeMismatch

      try
      {
         /* if there is a default index, we do have active members */
         if( type().default_index() != -1 )
         {
            throw new TypeMismatch();
         }
         pos = 0;

         // do nothing if discriminator is already set to no active member
         if (!has_no_active_member ())
View Full Code Here

Examples of org.omg.DynamicAny.DynAnyPackage.TypeMismatch

                     discriminator = check_val;
                     return;
                  }
               }
               // no unused value found
               throw new TypeMismatch();
            }
         case TCKind._tk_char:
            {
               // assume there is a printable char not used as a label!
               boolean found;
               org.omg.CORBA.Any check_val = null;

               // 33 to 126 defines a reasonable set of printable chars
               for (int i = 0; i < 127; i++)
               {
                  check_val = orb.create_any ();
                  check_val.insert_char ((char) i);

                  found = false; // is the value used as a label?
                  for( int j = 0; j < type().member_count() && !found; j++ )
                  {
                     if( check_val.equal( type().member_label(j)) )
                     {
                        found = true;
                     }
                  }

                  if( !found )
                  {
                     // the value is not found among the union's label
                     discriminator = check_val;
                     return;
                  }
               }
               // no unused value found, should not happen
               throw new TypeMismatch();
            }
         case TCKind._tk_short:
            {
               // assume there is an unsigned short not used as a label!
               boolean found;
               org.omg.CORBA.Any check_val = null;

               short max_short = 32767;
               for (short i = 0; i < max_short; i++)
               {
                  check_val = orb.create_any ();
                  check_val.insert_short (i);

                  found = false; // is the value used as a label?
                  for( int j = 0; j < type().member_count() && !found; j++ )
                  {
                     if( check_val.equal( type().member_label(j)) )
                     {
                        found = true;
                     }
                  }

                  if( !found )
                  {
                     // the value is not found among the union's label
                     discriminator = check_val;
                     return;
                  }
               }
               // no unused value found, should not happen
               throw new TypeMismatch();
            }
         case TCKind._tk_long:
            {
               // assume there is an unsigned int not used as a label!
               boolean found;
               org.omg.CORBA.Any check_val = null;

               int max_int = 2147483647;
               for (int i = 0; i < max_int; i++)
               {
                  check_val = orb.create_any ();
                  check_val.insert_long (i);

                  found = false; // is the value used as a label?
                  for( int j = 0; j < type().member_count() && !found; j++ )
                  {
                     if( check_val.equal( type().member_label(j)) )
                     {
                        found = true;
                     }
                  }

                  if( !found )
                  {
                     // the value is not found among the union's label
                     discriminator = check_val;
                     return;
                  }
               }
               // no unused value found, should not happen
               throw new TypeMismatch();
            }
         case TCKind._tk_longlong:
            {
               // assume there is an unsigned long not used as a label!
               boolean found;
               org.omg.CORBA.Any check_val = null;

               long max_long = 2147483647; // this should be sufficient!
               for (long i = 0; i < max_long; i++)
               {
                  check_val = orb.create_any ();
                  check_val.insert_longlong (i);

                  found = false; // is the value used as a label?
                  for( int j = 0; j < type().member_count() && !found; j++ )
                  {
                     if( check_val.equal( type().member_label(j)) )
                     {
                        found = true;
                     }
                  }

                  if( !found )
                  {
                     // the value is not found among the union's label
                     discriminator = check_val;
                     return;
                  }
               }
               // no unused value found, should not happen
               throw new TypeMismatch();
            }
         case TCKind._tk_enum:
            {
               org.omg.DynamicAny.DynEnum dynEnum = null;
               try
               {
                  dynEnum = (org.omg.DynamicAny.DynEnum) dynFactory.create_dyn_any_from_type_code (discriminator.type());
               }
               catch( InconsistentTypeCode e )
               {
                   throw unexpectedException(e);
               }

               boolean found;
               for( int i = 0; i < discriminator.type().member_count(); i++ )
               {
                  try
                  {
                     dynEnum.set_as_string( discriminator.type().member_name(i) );
                  }
                  catch( InvalidValue e )
                  {
                      throw unexpectedException(e);
                  }

                  found = false; // is the value used as a label?
                  for( int j = 0; j < type().member_count() && !found; j++ )
                  {
                     if( dynEnum.to_any ().equal( type().member_label(j) ) )
                     {
                        found = true;
                     }
                  }

                  if( !found )
                  {
                     // the enum value is not found among the union's label
                     discriminator = dynEnum.to_any();
                     return;
                  }
               }
               // no unused value found
               throw new TypeMismatch();
            }
         default:
            throw new TypeMismatch();
         }
      }
      catch (org.omg.CORBA.TypeCodePackage.BadKind e)
      {
          throw unexpectedException(e);
View Full Code Here

Examples of org.omg.DynamicAny.DynAnyPackage.TypeMismatch

       org.omg.CORBA.TypeCode _type = TypeCode.originalType( type );

       if( _type.kind().value() != org.omg.CORBA.TCKind._tk_enum )
       {
           throw new TypeMismatch();
       }

       typeCode = _type;
       pos = -1;
       enumValue = 0;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.