public static void figureOutConnect ( PrintStream w , Object ... comps ) { // add all the components via Proxy. List < ComponentAccess > l = new ArrayList < ComponentAccess > ( ) ; for ( Object c : comps ) { l . add ( new ComponentAccess ( c ) ) ; } // find all out slots for ( ComponentAccess cp_out : l ) { w . println ( "// connect " + objName ( cp_out ) ) ; // over all input slots. for ( Access fout : cp_out . outputs ( ) ) { String s = " out2in(" + objName ( cp_out ) + ", \"" + fout . getField ( ) . getName ( ) + "\"" ; for ( ComponentAccess cp_in : l ) { // skip if it is the same component. if ( cp_in == cp_out ) { continue ; } // out points to in for ( Access fin : cp_in . inputs ( ) ) { // name equivalence enought for now. if ( fout . getField ( ) . getName ( ) . equals ( fin . getField ( ) . getName ( ) ) ) { s = s + ", " + objName ( cp_in ) ; } } } w . println ( s + ");" ) ; } w . println ( ) ; } }
Figure out connectivity and generate Java statements .