ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Java to RPGLE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Java to RPGLE

    Anybody interested in converting Java source to RPGLE source ? I don't mean so that the RPG interfaces with the JVM, I mean native RPGLE objects.

    It just sounded like fun, so I did it, and now I've done it I don't know what to do with it!

    Just wondered if anyone had any interest/need for such a thing?

  • #2
    Re: Java to RPGLE

    I'd be interested simply in seeing it work, even if nothing else (which might not happen). It'd take some experimenting to see what uses it had.
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment


    • #3
      Re: Java to RPGLE

      OK - usual caveats (work in progress, just for fun, etc) - here is an example of some java source:
      PHP Code:
      public class Example extends Object
      {
          private 
      int quantity ;
          private 
      zoned(7:2value ;

          public 
      void chgQuantity(int x)   
          {
            
      quantity;
          }


      the resulting service program source is quit large, but the relevant bit here is the method/procedure code for 'chgQuantity':
      PHP Code:
      P ExampleChgQuantity...                                            
      P                 B                   EXPORT                       
      D                 PI                                               
      D  
      @                              *   VALUE                        
      D  x                            10I 0 VALUE                        
       
      *                                                                 
      @this           S               *                                
      D this            DS                  LIKEDS(Example_BASED(@this)
       *                                                                 
       /
      free                                                             
                                                                         
          
      // Pick up object                                              
             
      @thisExampleInstanceCheck(@) ;                            
                                                                         
             
      this.quantity;                                          
                                                                         
       /
      end-free                                                         
       
      *                                                                 
       * 
      End of procedure                                                
      P                 E 
      The data structure Example_ is defined in the service program as:

      PHP Code:
      D Example_...                                                     
      D                 DS                  QUALIFIED BASED(@NULLALIGN
      D  
      @                                  LIKEDS(Object_)             
      D  quantity                     10I 0                             
      D  value                         7S 2                             
      D                                5A 
      The Object_ data structure is defined in the service program that looks after the Object class. In essence, the RPGLE service programs behave in a similar way to Java class files.

      The Object_ structure looks like this:
      PHP Code:
      D Object_...                                                      
      D                 DS                  QUALIFIED BASED(@NULLALIGN
      D  Signature                    16A                               
      D  
      Class                          *                               
      D  RefCount                     10I 0                             
      D                               12A 
      Signature is used to make sure that the thing in question really is what it says it is.
      Class is a pointer to the class object of the object (!). Class objects are singletons.
      RefCount is used to count the number of references to this object so that some (unsophisticated) memory management can be performed.

      Does that whet your appetite?

      Comment

      Working...
      X