generic circuits have access to the circuit specific settings, closes #626

This commit is contained in:
hneemann 2021-02-05 15:29:27 +01:00
parent f7a37fc1e8
commit 822a6f02a4
2 changed files with 5 additions and 3 deletions

View File

@ -36,6 +36,7 @@ public class ResolveGenerics {
* Key uses to store the args for the generic circuits
*/
public static final String GEN_ARGS_KEY = "genArgs";
private static final String SETTINGS_KEY = "settings";
private final HashMap<String, Statement> map;
private final HashMap<Args, CircuitHolder> circuitMap;
private final Circuit circuit;
@ -163,6 +164,7 @@ public class ResolveGenerics {
Context context = new Context();
if (circuit.getOrigin() != null)
context.declareVar(Context.BASE_FILE_KEY, circuit.getOrigin());
context.declareVar(SETTINGS_KEY, new SubstituteLibrary.AllowSetAttributes(circuit.getAttributes()));
context.declareFunc("addWire", new AddWire(newWires));
context.declareFunc("addComponent", new AddComponent(newComponents, args));
return context;
@ -308,7 +310,7 @@ public class ResolveGenerics {
return;
}
if (!key.equals(Context.BASE_FILE_KEY)) {
if (!key.equals(Context.BASE_FILE_KEY) && !key.equals(SETTINGS_KEY)) {
contentSet.add(key);
sb.append(key).append(":=");
if (val instanceof String) {

View File

@ -102,8 +102,8 @@ public class LayoutShape implements Shape {
}
}
height = left.max(right.max(custom.getAttributes().get(Keys.HEIGHT)));
width = top.max(bottom.max(custom.getAttributes().get(Keys.WIDTH)));
height = left.max(right.max(circuit.getAttributes().get(Keys.HEIGHT)));
width = top.max(bottom.max(circuit.getAttributes().get(Keys.WIDTH)));
HashMap<String, PinPos> map = new HashMap<>();
top.createPosition(map, new Vector(0, 0), width);