Convenience access to primitive type fields
4620
void setIntField(int accessor, int value) {
    try {
      jmfPart.setInt(accessor, value);
    } catch (JMFException e) {
      FFDCFilter.processException(e, "setIntField", "109", this);
      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(this, tc, "setIntField failed: " + e);
    }
  }
611480
private void appendCollectionTypeField(JField field, PDescriptor descriptor) {
        switch (descriptor.getType()) {
            case BYTE:
            case BINARY:
                writer.formatln(".addByteArrayField(\"%s\")", field.name());
                break;
            case BOOL:
                writer.formatln(".addBooleanArrayField(\"%s\")", field.name());
                break;
            case DOUBLE:
                writer.formatln(".addDoubleArrayField(\"%s\")", field.name());
                break;
            case I16:
                writer.formatln(".addShortArrayField(\"%s\")", field.name());
                break;
            case I32:
            case ENUM:
                writer.formatln(".addIntArrayField(\"%s\")", field.name());
                break;
            case I64:
                writer.formatln(".addLongArrayField(\"%s\")", field.name());
                break;
            case STRING:
                writer.formatln(".addUTFArrayField(\"%s\")", field.name());
                break;
            case MESSAGE:
                writer.formatln(".addPortableArrayField(\"%s\", %s(%s))",
                                field.name(),
                                camelCase("get", descriptor.getName() + "Definition"),
                                PORTABLE_VERSION);
                break;
            default:
                throw new GeneratorException(
                        "Not implemented appendCollectionTypeField for list with type: " + descriptor.getType() + " in " +
                        this.getClass()
                            .getSimpleName());
        }
    }
1241852
async def dump_field(obj, elem, elem_type, params=None):
    
    if isinstance(elem, (int, bool)) or issubclass(elem_type, x.UVarintType) or issubclass(elem_type, x.IntType):
        return set_elem(obj, elem)

    elif issubclass(elem_type, x.BlobType) or isinstance(obj, bytes) or isinstance(obj, bytearray):
        return set_elem(obj, await dump_blob(elem))

    elif issubclass(elem_type, x.UnicodeType) or isinstance(elem, str):
        return set_elem(obj, elem)

    elif issubclass(elem_type, x.VariantType):
        return set_elem(obj, await dump_variant(None, elem, elem_type, params))

    elif issubclass(elem_type, x.ContainerType):  # container ~ simple list
        return set_elem(obj, await dump_container(None, elem, elem_type, params))

    elif issubclass(elem_type, x.MessageType):
        return set_elem(obj, await dump_message(None, elem))

    else:
        raise TypeError
65874
def get_primitive_name(schema):
    
    try:
        return {
            const.COMPILED_TYPE.LITERAL: six.text_type,
            const.COMPILED_TYPE.TYPE: get_type_name,
            const.COMPILED_TYPE.ENUM: get_type_name,
            const.COMPILED_TYPE.CALLABLE: get_callable_name,
            const.COMPILED_TYPE.ITERABLE: lambda x: _(u'{type}[{content}]').format(type=get_type_name(list), content=_(u'...') if x else _(u'-')),
            const.COMPILED_TYPE.MAPPING:  lambda x: _(u'{type}[{content}]').format(type=get_type_name(dict), content=_(u'...') if x else _(u'-')),
        }[primitive_type(schema)](schema)
    except KeyError:
        return six.text_type(repr(schema))
831377
def _basic_field_data(field, obj):
    """"""
    value = field.value_from_object(obj)
    return {Field.TYPE: FieldType.VAL, Field.VALUE: value}
28335
private String getStringValue(Object instance, Field field) throws IllegalAccessException {
    Class<?> fieldType = field.getType();

    // Only support primitive type, boxed type, String and Enum
    Preconditions.checkArgument(
      fieldType.isPrimitive() || Primitives.isWrapperType(fieldType) ||
        String.class.equals(fieldType) || fieldType.isEnum(),
      "Unsupported property type %s of field %s in class %s.",
      fieldType.getName(), field.getName(), field.getDeclaringClass().getName()
    );

    if (!field.isAccessible()) {
      field.setAccessible(true);
    }
    Object value = field.get(instance);
    if (value == null) {
      return null;
    }

    // Key name is "className.fieldName".
    return fieldType.isEnum() ? ((Enum<?>) value).name() : value.toString();
  }
895308
protected FieldMetadata processArrayTypeFrom( FieldDeclaration fieldDeclaration ) {
        ArrayType arrayType = (ArrayType)fieldDeclaration.getType();
        FieldMetadata arrayTypeFieldMetadata = null;
        // the element type is never an array type
        Type type = arrayType.getElementType();
        if (type.isPrimitiveType()) {
            PrimitiveType primitiveType = (PrimitiveType)type;
            arrayTypeFieldMetadata = FieldMetadata.arrayType(primitiveType.getPrimitiveTypeCode().toString());
            processModifiersAndVariablesOfFieldDeclaration(fieldDeclaration, arrayTypeFieldMetadata);
            arrayTypeFieldMetadata.setName(getFieldName(fieldDeclaration));
            return arrayTypeFieldMetadata;

        }
        // can't be an array type
        if (type.isSimpleType()) {
            SimpleType simpleType = (SimpleType)type;
            arrayTypeFieldMetadata = FieldMetadata.arrayType(JavaMetadataUtil.getName(simpleType.getName()));
            processModifiersAndVariablesOfFieldDeclaration(fieldDeclaration, arrayTypeFieldMetadata);
            arrayTypeFieldMetadata.setName(getFieldName(fieldDeclaration));
            return arrayTypeFieldMetadata;
        }

        return null;
    }
500034
def primitive_type(schema):
    
    schema_type = type(schema)

    # Literal
    if schema_type in const.literal_types:
        return const.COMPILED_TYPE.LITERAL
    # Enum
    elif Enum is not None and isinstance(schema, (EnumMeta, Enum)):
        return const.COMPILED_TYPE.ENUM
    # Type
    elif issubclass(schema_type, six.class_types):
        return const.COMPILED_TYPE.TYPE
    # Mapping
    elif isinstance(schema, collections.Mapping):
        return const.COMPILED_TYPE.MAPPING
    # Iterable
    elif isinstance(schema, collections.Iterable):
        return const.COMPILED_TYPE.ITERABLE
    # Callable
    elif callable(schema):
        return const.COMPILED_TYPE.CALLABLE
    # Not detected
    else:
        return None
1029306
def view_properties_as_tree field=@form.get_current_field
    alert "Nil field" unless field
    return unless field
    text = []
    tree = {}
    #iv = field.instance_variables.map do |v| v.to_s; end
    field.instance_variables.each do |v|
      val = field.instance_variable_get(v)
      klass = val.class
      if val.is_a? Array 
        #tree[v.to_s] = val
        text << { v.to_s => val }
        val = val.size
      elsif val.is_a? Hash
        #tree[v.to_s] = val
        text << { v.to_s => val }
        if val.size <= 5
          val = val.keys
        else
          val = val.keys.size.to_s + " [" + val.keys.first(5).join(", ") + " ...]"
        end
      end
      case val
      when String, Integer, TrueClass, FalseClass, NilClass, Array, Hash, Symbol
        ;
      else
        val = "Not shown"
      end
      text << "%-20s  %10s  %s" % [v, klass, val]
    end
    tree["Instance Variables"] = text
    pm = field.public_methods(false).map do |v| v.to_s; end
    tree["Public Methods"] = pm
    pm = field.public_methods(true) - field.public_methods(false)
    pm = pm.map do |v| v.to_s; end
    tree["Inherited Methods"] = pm

    #$log.debug "  view_properties #{s.size} , #{s} "
    treedialog tree, :title => "Properties"
  end
545219
private static int sizeofPrimitiveType(final Class type) {
        if (type == int.class) {
            return INT_FIELD_SIZE;
        } else if (type == long.class) {
            return LONG_FIELD_SIZE;
        } else if (type == short.class) {
            return SHORT_FIELD_SIZE;
        } else if (type == byte.class) {
            return BYTE_FIELD_SIZE;
        } else if (type == boolean.class) {
            return BOOLEAN_FIELD_SIZE;
        } else if (type == char.class) {
            return CHAR_FIELD_SIZE;
        } else if (type == double.class) {
            return DOUBLE_FIELD_SIZE;
        } else if (type == float.class) {
            return FLOAT_FIELD_SIZE;
        } else {
            throw new IllegalArgumentException("not primitive: " + type);
        }
    }
1081322
private Object getField(Object object, Field f) {
        f.setAccessible(true);
        try {
            return f.get(object);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
375457
private Iterable<? extends JSType> getTypeAlternatives(JSType type) {
    if (type.isUnionType()) {
      return type.getUnionMembers();
    } else {
      ObjectType objType = type.toMaybeObjectType();
      FunctionType constructor = objType != null ? objType.getConstructor() : null;
      if (constructor != null && constructor.isInterface()) {
        List<JSType> list = new ArrayList<>();
        for (FunctionType impl : constructor.getDirectSubTypes()) {
          list.add(impl.getInstanceType());
        }
        return list.isEmpty() ? null : list;
      } else {
        return null;
      }
    }
  }
1295426
def p_object_ty(self, p):
        
        field_types = {} if len(p) == 5 else p[5]
        p[0] = Object(p[3], **field_types)
642799
def get_field_type(info):
    """"""

    type_ = info.get_type()

    cls = get_field_class(type_)

    field = cls(info, type_, None)
    field.setup()
    return field.py_type
866994
def get_field_type(f):
    """"""
    types = (t[5:] for t in dir(f) if t[:4] == 'TYPE' and
             getattr(f, t) == f.type)
    return next(types)
911592
private static String getTypeName(FieldElement field) {
        DataType type = field.type();
        return type.toString();
    }
1033076
private int getIntForType(JSType type) {
    // Templatized types don't exist at runtime, so collapse to raw type
    if (type != null && type.isGenericObjectType()) {
      type = type.toMaybeObjectType().getRawType();
    }
    if (intForType.containsKey(type)) {
      return intForType.get(type).intValue();
    }
    int newInt = intForType.size() + 1;
    intForType.put(type, newInt);
    return newInt;
  }