File: parent_module-tests.scad

package info (click to toggle)
openscad 2021.01-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 36,096 kB
  • sloc: cpp: 53,199; sh: 4,384; ansic: 4,382; python: 1,813; yacc: 853; javascript: 762; lex: 417; lisp: 163; xml: 127; makefile: 118
file content (26 lines) | stat: -rw-r--r-- 511 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*
	$parent_modules should return the number of module in the module 
    instantiation stack. The stack is independent on where the modules 
    are defined. It's where they're instantiated that counts.

    parent_module(N) returns the Nth module name in the stack
*/
module print(name) {
  echo("name: ", name);
  for (i=[1:$parent_modules-1]) echo(parent_module(i));
}

module yyy() {
  print("yyy");
}

module test() {
  module xxx() {
    print("xxx");
    yyy();
  }
  print("test");
  xxx();
}

test();