From 2f1435ad1b228fd61e6e4f621abba3df2dda0425 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Sj=C3=B6lund?= Date: Tue, 10 Jan 2012 12:57:42 +0000 Subject: [PATCH] - Moved isPackage to the scripting enviornment - GenerateDoc now splits the index page between libraries and builtin environment git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10874 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- Compiler/FrontEnd/ModelicaBuiltin.mo | 11 ++++++++ Compiler/Script/CevalScript.mo | 8 +++++- Compiler/Script/Interactive.mo | 21 ++++----------- Examples/GenerateDoc.mos | 40 ++++++++++++++++++++-------- 4 files changed, 52 insertions(+), 28 deletions(-) diff --git a/Compiler/FrontEnd/ModelicaBuiltin.mo b/Compiler/FrontEnd/ModelicaBuiltin.mo index 719261354f5..cc58460c8fd 100644 --- a/Compiler/FrontEnd/ModelicaBuiltin.mo +++ b/Compiler/FrontEnd/ModelicaBuiltin.mo @@ -2190,6 +2190,17 @@ annotation( preferredView="text"); end basename; +function isPackage + input TypeName cl; + output Boolean b; +external "builtin"; +annotation( + Documentation(info=" + Returns true if the given classname is a package. +"), + preferredView="text"); +end isPackage; + annotation(preferredView="text"); end Scripting; diff --git a/Compiler/Script/CevalScript.mo b/Compiler/Script/CevalScript.mo index 726cb1f7408..813b38448f5 100644 --- a/Compiler/Script/CevalScript.mo +++ b/Compiler/Script/CevalScript.mo @@ -1680,6 +1680,12 @@ algorithm ((str1,str2)) = Interactive.getNamedAnnotation(classpath, p, "Documentation", SOME(("","")),Interactive.getDocumentationAnnotationString); then (cache,ValuesUtil.makeArray({Values.STRING(str1),Values.STRING(str2)}),st); + + case (cache,env,"isPackage",{Values.CODE(Absyn.C_TYPENAME(classpath))},st as Interactive.SYMBOLTABLE(ast=p),msg) + equation + b = Interactive.isPackage(classpath, p); + then + (cache,Values.BOOL(b),st); case (cache,env,"getAstAsCorbaString",{Values.STRING("")},st as Interactive.SYMBOLTABLE(ast=p),msg) equation @@ -3955,7 +3961,7 @@ algorithm // Absyn.CLASS(partialPrefix = false) = c; // do not filter partial classes cr = Absyn.pathToCref(className); // filter out packages - false = Interactive.isPackage(cr, p); + false = Interactive.isPackage(className, p); // filter out functions // false = Interactive.isFunction(cr, p); // filter out types diff --git a/Compiler/Script/Interactive.mo b/Compiler/Script/Interactive.mo index 17b992a116b..15a655923de 100644 --- a/Compiler/Script/Interactive.mo +++ b/Compiler/Script/Interactive.mo @@ -1986,15 +1986,6 @@ algorithm then (resstr,st); - case (istmts, st as SYMBOLTABLE(ast = p)) - equation - matchApiFunction(istmts, "isPackage"); - {Absyn.CREF(componentRef = cr)} = getApiFunctionArgs(istmts); - b1 = isPackage(cr, p); - resstr = boolString(b1); - then - (resstr,st); - case (istmts, st as SYMBOLTABLE(ast = p)) equation matchApiFunction(istmts, "isClass"); @@ -2089,7 +2080,7 @@ algorithm matchApiFunction(istmts, "existPackage"); {Absyn.CREF(componentRef = cr)} = getApiFunctionArgs(istmts); b1 = existClass(cr, p); - b2 = isPackage(cr, p); + b2 = isPackage(Absyn.crefToPath(cr), p); b = boolAnd(b1, b2); resstr = boolString(b); then @@ -8583,23 +8574,21 @@ public function isPackage This function takes a component reference and a program. It returns true if the refrenced class has the restriction \"package\", otherwise it returns false." - input Absyn.ComponentRef inComponentRef; + input Absyn.Path path; input Absyn.Program inProgram; output Boolean outBoolean; algorithm outBoolean:= - matchcontinue (inComponentRef,inProgram) + matchcontinue (path,inProgram) local - Absyn.Path path; Absyn.ComponentRef cr; Absyn.Program p; - case (cr,p) + case (path,p) equation - path = Absyn.crefToPath(cr); Absyn.CLASS(_,_,_,_,Absyn.R_PACKAGE(),_,_) = getPathedClassInProgram(path, p); then true; - case (cr,p) then false; + else false; end matchcontinue; end isPackage; diff --git a/Examples/GenerateDoc.mos b/Examples/GenerateDoc.mos index f2c8a32af5c..00d103c99d9 100644 --- a/Examples/GenerateDoc.mos +++ b/Examples/GenerateDoc.mos @@ -184,22 +184,40 @@ replaceCommands := ""; filetmp := "index.html"; writeFile(filetmp, "Modelica Documentation

Modelica Documentation

\n"); writeFile(filetmp, "

This is a listing of builtin Modelica functions, libraries shipped with OpenModelica and the documentation for OpenModelica-specific scripting.

\n", append = true); -writeFile(filetmp, "

Contents

\n", append = true); +writeFile(filetmp, "

Libraries

\n", append = true); writeFile(filetmp, "", append = true); for cl in classNames loop file := getSourceFile(cl); base := basename(file); - contentStrToks := typeNameStrings(cl); - modelVersion := getVersion(cl); - if base == "package.mo" then - replaceCommands := replaceCommands + " $link2 =~ s&[Mm][Oo][Dd][Ee][Ll][Ii][Cc][Aa]://" + contentStrToks[end] + "/&" + dirname(file) + "/&g;\n"; - dirpaths := strtok(dirname(file),"/"); - dirs := dirs + " \"" + dirpaths[end] + "\" "; + if base <> "ModelicaBuiltin.mo" then + base := basename(file); + contentStrToks := typeNameStrings(cl); + modelVersion := getVersion(cl); + if base == "package.mo" then + replaceCommands := replaceCommands + " $link2 =~ s&[Mm][Oo][Dd][Ee][Ll][Ii][Cc][Aa]://" + contentStrToks[end] + "/&" + dirname(file) + "/&g;\n"; + dirpaths := strtok(dirname(file),"/"); + dirs := dirs + " \"" + dirpaths[end] + "\" "; + end if; + comment := getClassComment(cl); + contentStr := typeNameString(cl); + fileName := filename(contentStr); + writeFile(filetmp, "", append = true); + end if; +end for; +writeFile(filetmp, "
NameDescriptionVersion
" + contentStrToks[end] + "" + comment + "" + modelVersion + "
\n", append = true); +writeFile(filetmp, "

Builtin Environment

\n", append = true); +writeFile(filetmp, "", append = true); +for cl in classNames loop + file := getSourceFile(cl); + base := basename(file); + if base == "ModelicaBuiltin.mo" then + contentStr := typeNameString(cl); + contentStrToks := typeNameStrings(cl); + modelVersion := getVersion(cl); + comment := getClassComment(cl); + fileName := filename(contentStr); + writeFile(filetmp, "", append = true); end if; - contentStr := typeNameString(cl); - comment := getClassComment(cl); - fileName := filename(contentStr); - writeFile(filetmp, "", append = true); end for; writeFile(filetmp, "
NameDescriptionVersion
" + contentStrToks[end] + "" + comment + "" + modelVersion + "
" + contentStrToks[end] + "" + comment + "" + modelVersion + "
\n", append = true); writeFile(filetmp, version + " (Offline version)", append = true);