Merge pull request #630 from KLayout/ruby-include

Ruby include
This commit is contained in:
Matthias Köfferlein
2020-09-14 18:33:57 +02:00
committed by GitHub
37 changed files with 1138 additions and 32 deletions
+9
View File
@@ -0,0 +1,9 @@
# some prep steps
ly = RBA::Layout::new
ly.create_cell("TOP")
l1 = ly.layer(1, 0)
ly.top_cell.shapes(l1).insert(RBA::Box::new(0, 0, 1000, 2000))
l2 = ly.layer(2, 0)
ly.top_cell.shapes(l2).insert(RBA::Box::new(500, 500, 1500, 2500))
+6
View File
@@ -0,0 +1,6 @@
import os
def f():
return("f: " + os.path.basename(pya.Macro.real_path(__file__, lineno())) + ":" + str(pya.Macro.real_line(__file__, lineno())))
+5
View File
@@ -0,0 +1,5 @@
def f
return "f: " + File.basename(__FILE__) + ":" + __LINE__.to_s
end
+5
View File
@@ -0,0 +1,5 @@
def f
raise("An error")
end
+22
View File
@@ -0,0 +1,22 @@
# some prep steps
ly = RBA::Layout::new
ly.create_cell("TOP")
l1 = ly.layer(1, 0)
ly.top_cell.shapes(l1).insert(RBA::Box::new(0, 0, 1000, 2000))
l2 = ly.layer(2, 0)
ly.top_cell.shapes(l2).insert(RBA::Box::new(500, 500, 1500, 2500))
# actual "DRC"
source(ly.top_cell)
l1_drc = input(1, 0)
l2_drc = input(2, 0)
(l1_drc & l2_drc).output(100, 0)
l100 = ly.layer(100, 0)
puts "Result: " + RBA::Region::new(ly.top_cell.begin_shapes_rec(l100)).to_s + " in " + File.basename(__FILE__) + ":" + __LINE__.to_s
+2
View File
@@ -0,0 +1,2 @@
print("Hello, world!")
+2
View File
@@ -0,0 +1,2 @@
puts "Hello, world!"
+14
View File
@@ -0,0 +1,14 @@
# %include "a_inc.drc"
# actual "DRC"
source(ly.top_cell)
l1_drc = input(1, 0)
l2_drc = input(2, 0)
(l1_drc & l2_drc).output(100, 0)
l100 = ly.layer(100, 0)
puts "Result: " + RBA::Region::new(ly.top_cell.begin_shapes_rec(l100)).to_s + " in " + File.basename(__FILE__) + ":" + __LINE__.to_s
+15
View File
@@ -0,0 +1,15 @@
import os
import inspect
def lineno():
return inspect.currentframe().f_back.f_lineno
print("Stop 1: " + os.path.basename(pya.Macro.real_path(__file__, lineno())) + ":" + str(pya.Macro.real_line(__file__, lineno())))
# %include a_inc.py
print(f())
print("Stop 2: " + os.path.basename(pya.Macro.real_path(__file__, lineno())) + ":" + str(pya.Macro.real_line(__file__, lineno())))
+9
View File
@@ -0,0 +1,9 @@
puts "Stop 1: " + File.basename(__FILE__) + ":" + __LINE__.to_s
# %include a_inc.rb
puts f
puts "Stop 2: " + File.basename(__FILE__) + ":" + __LINE__.to_s
+12
View File
@@ -0,0 +1,12 @@
# %include b_inc.rb
begin
puts f
rescue => ex
ln = ex.backtrace[0].split(":")
# NOTE: as the backtrace is a native Ruby feature, include file translation
# does not happen. We need to do this explicitly here:
puts ex.to_s + " in " + RBA::Macro::real_path(ln[0], ln[1].to_i) + ":" + RBA::Macro::real_line(ln[0], ln[1].to_i).to_s
end
+1
View File
@@ -0,0 +1 @@
included.1
+2
View File
@@ -0,0 +1,2 @@
included.2a
included.2b
+3
View File
@@ -0,0 +1,3 @@
include.3a
# %include inc2.txt
include.3b
+2
View File
@@ -0,0 +1,2 @@
A line
Another line
+3
View File
@@ -0,0 +1,3 @@
A line
# %include inc1.txt
Another line
+3
View File
@@ -0,0 +1,3 @@
A line
# %include inc3.txt
Another line
+3
View File
@@ -0,0 +1,3 @@
A line
# %include inc$(1+2).txt
Another line