Bug 1025 - GlueGen: Add accessor for compound fields of type array, pointer and string (code generation)
Summary: GlueGen: Add accessor for compound fields of type array, pointer and string (...
Status: RESOLVED FIXED
Alias: None
Product: Gluegen
Classification: JogAmp
Component: core (show other bugs)
Version: 2
Hardware: All all
: --- enhancement
Assignee: Sven Gothel
URL:
Depends on: 1022
Blocks: 1021
  Show dependency treegraph
 
Reported: 2014-06-25 09:52 CEST by Sven Gothel
Modified: 2014-06-25 11:39 CEST (History)
2 users (show)

See Also:
Type: ---
SCM Refs:
gluegen 9ee44e1a289ecbac024662dd5a2ffc42e8add023 gluegen 679d484d4d8c3528aacc5b98dca644086948fcc5 gluegen 8f571b2c0008df1b6554fa8fa754440c0f024052 jocl 49d7ae5356c279d519fc6744129c92a166e4f504 jogl a515faf5e7d679b7ad87a05fa8fc81ab148bcd41
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sven Gothel 2014-06-25 09:52:17 CEST
Enhance compound access as delivered by Bug 1022,
to also generate accessors (getter and setter) for
array, pointer and string types.

Allow configuration of array length either via
their internal size (c-header) or config 'ReturnedArrayLength'.

'ReturnedArrayLength' allows specifying a java expression.

Canonical field names of compounds are _now_ specified as
follows for configuration entries:
  COMPOUND.FIELD
e.g.
  StructA.fieldB

Also allow configuration of pointer fields to be treated as 
referenced arrays via 'ReturnedArrayLength'.

Further, allow specifying 'pointer fields' as String values
via 'ReturnsString' configuration.
Comment 1 Sven Gothel 2014-06-25 10:25:07 CEST
gluegen commit 9ee44e1a289ecbac024662dd5a2ffc42e8add023:

Implementation details:
 - handle above described accessor features
 - enhance JavaDoc for generated accessors
 - generate native JNI compound and string accessor on demand
 - encapsule accessor code generation in their own methods
 - enhance exception messages
 - enhance type verbosity in debug mode
 - verbose debug output via GlueGen.debug()

Tests:
 - Features covered by test1.[ch]
   and Test1p1JavaEmitter and Test1p2ProcAddressEmitter

- Validated compilation and unit tests for modules:
 - joal
 - jogl (minor config changes req.)
   commit a515faf5e7d679b7ad87a05fa8fc81ab148bcd41
 - jocl (minor config changes req.)
   commit 49d7ae5356c279d519fc6744129c92a166e4f504
Comment 2 Sven Gothel 2014-06-25 10:33:16 CEST
679d484d4d8c3528aacc5b98dca644086948fcc5
  GlueGen: Fix test case (gcc compiler regression due to redefined types / removed them)
Comment 3 Sven Gothel 2014-06-25 10:49:27 CEST
Issues w/ opaque 'long' field access of structs
where native size != java size (e.g. 32bit):

  /** Getter for native field: CType['TK_Context' (typedef), size [fixed false, lnx64 8], [pointer*1]], with array length of <code>1</code> */
  public long getCtx() {
    return accessor.getLongAt(ctx_offset[mdIdx]);
  }


.. reopened.
Comment 4 Sven Gothel 2014-06-25 11:39:43 CEST
commit 8f571b2c0008df1b6554fa8fa754440c0f024052

  Fix regression of single non-native sized compound fields,
  see comment 3.
    
  Single non-native sized compound fields, if an opaque array/pointer,
  must utilized the native size StructAccessor get/set method.