Examples of GeneratorContext


Examples of rocket.generator.rebind.GeneratorContext

  protected void overrideObjectReaderReadFieldsMethod(final NewConcreteType reader, final Type type) {
    Checker.notNull("parameter:reader", reader);
    Checker.notNull("parameter:type", type);

    final GeneratorContext context = this.getGeneratorContext();

    final NewMethod newMethod = reader.newMethod();
    newMethod.setAbstract(false);
    newMethod.setFinal(true);
    newMethod.setName(SerializationConstants.CLIENT_OBJECT_READER_IMPL_READ_FIELDS_METHOD);
    newMethod.setReturnType(context.getVoid());
    newMethod.setStatic(false);
    newMethod.setVisibility(Visibility.PUBLIC);

    // rename parameters to the same names used in templates...
    final NewMethodParameter object = newMethod.newParameter();
    object.setName(SerializationConstants.CLIENT_OBJECT_READER_IMPL_READ_INSTANCE_PARAMETER);
    object.setFinal(true);
    object.setType(type);

    final NewMethodParameter objectInputStream = newMethod.newParameter();
    objectInputStream.setName(SerializationConstants.CLIENT_OBJECT_READER_IMPL_READ_FIELDS_OBJECT_INPUT_STREAM_PARAMETER);
    objectInputStream.setFinal(true);
    objectInputStream.setType(this.getObjectInputStream());

    final ReadFieldsTemplatedFile body = new ReadFieldsTemplatedFile();
    newMethod.setBody(body);
    body.setType(type);

    // add all fields to the template
    final Iterator<Field> fields = this.filterSerializableFields(type.getFields()).iterator();
    int fieldCount = 0;
    context.branch();

    while (fields.hasNext()) {
      final Field field = fields.next();
      final Method setter = this.createFieldSetter(reader, field);
      body.addFieldSetter(setter);

      fieldCount++;
    }

    context.unbranch();
    context.debug("Overridden " + newMethod);
  }
View Full Code Here

Examples of rocket.generator.rebind.GeneratorContext

   */
  protected Method createFieldSetter(final NewConcreteType reader, final Field field) {
    Checker.notNull("parameter:reader", reader);
    Checker.notNull("parameter:field", field);

    final GeneratorContext context = this.getGeneratorContext();

    final SetFieldTemplatedFile body = new SetFieldTemplatedFile();
    body.setField(field);

    final NewMethod method = reader.newMethod();
    method.setAbstract(false);
    method.setBody(body);
    method.setFinal(true);
    method.setName(GeneratorHelper.buildSetterName(field.getName()));
    method.setNative(true);
    method.setReturnType(context.getVoid());
    method.setStatic(false);
    method.setVisibility(Visibility.PRIVATE);

    final NewMethodParameter instance = method.newParameter();
    instance.setFinal(true);
    instance.setName(SerializationConstants.CLIENT_OBJECT_READER_IMPL_FIELD_SETTER_INSTANCE_PARAMETER);
    instance.setType(field.getEnclosingType());

    final NewMethodParameter value = method.newParameter();
    value.setFinal(true);
    value.setName(SerializationConstants.CLIENT_OBJECT_READER_IMPL_FIELD_SETTER_VALUE_PARAMETER);

    final Type fieldType = field.getType();
    value.setType(fieldType);

    if (fieldType.equals(context.getLong())) {
      method.addMetaData("com.google.gwt.core.client.UnsafeNativeLong", "");
    }

    context.debug(field.getName());

    return method;
  }
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.