jp_wikiwiki_aiou_ddCallWithTempLib
一時的なライブラリをつかって何かの処理をしたい場合に使える関数。
使用例:
指定したテクノロジー「cfetA7」がアタッチされた一時ライブラリーが生成されてユーザー関数(lambda)はそれを受け取って使う。
(jp_wikiwiki_aiou_ddCallWithTempLibName "cfetA7"
(lambda (tempLibName)
(let ((cv (dbOpelCellViewByType tempLibName "tempCell" "layout" "maskLayout" "a")))
(when (dbIsId cv)
(dbCreateRect cv (list "M1" "drawing") (list (range 58.8 108.7) (range 93.22 87.7)))
(dbCreateInstByMasterName cv "LLX22K40" "INV8" "layout" nil (range 12.5 440.8) "R90")
:
))))
関数定義:
jp_wikiwiki_aiou_ddCallWithTempLib は ユーザーが指定したテクノロジー techLibName がアタッチされた一時的なライブラリを生成し、ユーザーが指定した関数 userProc を一時ライブラリの名前 tempLibName を引数として呼び出す。uerProc の実行が終わると jp_wikiwiki_aiou_ddCallWithTempLib は一時ライブラリを消去する。
; ==============================================================================
; jp_wikiwiki_aiou_ddCallWithTempLib
; @Version(20260117b)
; ==============================================================================
;
(define (jp_wikiwiki_aiou_ddCallWithTempLib techLibName userProc)
(assert (ddIdId (dbGetObj techLibName))
"jp_wikiwiki_aiou_ddCallWithTempLib: the techLib specified by argument #1 does not exist.")
;
(assert (isCallable userProc)
"jp_wikiwiki_aiou_ddCallWithTempLib: argument #2 must be callable.")
;
(let
(
(origForcedPath (ddGetForcedLib))
(tempCdslibFilePath (makeTempFileName (strcat (getTempDir) "/")))
)
(let ((p (outfile tempCdslibFilePath)))
(assert (porp p)
"jp_wikiwiki_aiou_ddCallWithTempLib: Could not make a temporary cds.lib file: %L" tempCdslibFilePath)
(unwindProtect
(when (stringp origForcedPath)
(cond
((blankstrp origForcedPath)
(display "INCLUDE " p) (display (truename "cds.lib") p) (newline p))
((isFile origForcedPath)
(display "INCLUDE " p) (display (truename origForcedPath) p) (newline p))))
(close p)))
;
(assert (isFile tempCdslibFilePath)
"jp_wikiwiki_aiou_ddCallWithTempLib: Could not make a temporary cds.lib file: %L" tempCdslibFilePath)
(sh (strcat "\\chmod go-rwx " tempCdslibFilePath)) ;; 情報漏洩対策
;
(let ((tempLibName nil))
(unwindProtect
(begin
(ddSetForcedLib tempCdslibFilePath)
(ddUpdateLibList)
(funcall userProc
(setq tempLibName
(letseq
(
(libNameFormat (strcat "_" (getLogin) "_%d"))
(libNameIndex 0)
(libName (lsprintf libNameFormat libNameIndex))
)
(when (ddIsId (ddGetObj libName))
(while
(ddIsId (ddGetObj (setq libName
(lsprintf libNameFormat (preincrement libNameIndex)))))
nil))
(letseq
(
(libPath (makeTempFileName (strcat (getTempDir) "/")))
(lib (ddCreateLib libName libPath))
)
(assert (ddIsId lib)
"jp_wikiwiki_aiou_ddCallWithTempLib: Could not make a temporary library")
(sh (strcat "\\chmod go-rwx " libPath)) ;; 情報漏洩対策
(techBindTechFile lib techLibName)
(ddReleaseObj lib)
libName)))))
;
(begin
(when (stringp tempLibName)
(let ((tempLib (ddGetObj tempLibName)))
(if (ddIsId tempLib)
(let ((tempLibPath (ddGetObjWritePath tempLib)))
(ddReleaseObj tempLib)
(ddSetForcedLib (or origForcedPath "/dev/null"))
(ddUpdateLibList)
(sh (strcat "\\chmod -R u+rwx " tempLibPath))
(sh (strcat "\\rm -rf " tempLibPath " &")))
(begin
(ddSetForcedLib (or origForcedPath "/dev/null"))
(ddUpdateLibList)))))
(when (isFile tempCdslibFilePath)
(deleteFile tempCdslibFilePath)))))))
;
; ==============================================================================
; [EOF]