use of lucee.runtime.type.UDFGSProperty in project Lucee by lucee.
the class ComponentImpl method metaUDFs.
private static void metaUDFs(PageContext pc, ComponentImpl comp, Struct sct, int access) throws PageException {
// UDFs
/*ArrayImpl arr1=new ArrayImpl();
{
Page page = comp._getPageSource().loadPage(pc, false);
// Page page = ((PageSourceImpl)comp._getPageSource()).getPage();
if(page!=null && page.udfs!=null) {
for(int i=0;i<page.udfs.length;i++){
if(page.udfs[i].getAccess()>access) continue;
print.e(">>"+((UDFPropertiesBase)page.udfs[i]).getFunctionName());
arr1.append(ComponentUtil.getMetaData(pc,(UDFPropertiesBase) page.udfs[i]));
}
}
}*/
ArrayImpl arr = new ArrayImpl();
if (comp.absFin != null) {
// we not to add abstract separately because they are not real Methods, more a rule
if (comp.absFin.hasAbstractUDFs())
getUDFs(pc, comp.absFin.getAbstractUDFs().values().iterator(), comp, access, arr);
}
if (comp._udfs != null)
getUDFs(pc, comp._udfs.values().iterator(), comp, access, arr);
// property functions
Iterator<Entry<Key, UDF>> it = comp._udfs.entrySet().iterator();
Entry<Key, UDF> entry;
UDF udf;
while (it.hasNext()) {
entry = it.next();
udf = entry.getValue();
if (udf.getAccess() > access || !(udf instanceof UDFGSProperty))
continue;
if (comp.base != null) {
if (udf == comp.base.getMember(access, entry.getKey(), true, true))
continue;
}
arr.append(udf.getMetaData(pc));
}
if (arr.size() != 0) {
Collections.sort(arr, new ComparatorImpl());
sct.set(KeyConstants._functions, arr);
}
}
use of lucee.runtime.type.UDFGSProperty in project Lucee by lucee.
the class UDFUtil method toDumpData.
public static DumpData toDumpData(PageContext pageContext, int maxlevel, DumpProperties dp, UDF udf, short type) {
if (!dp.getShowUDFs()) {
if (TYPE_UDF == type)
return new SimpleDumpData("<UDF>");
if (TYPE_BIF == type)
return new SimpleDumpData("<BIF>");
if (TYPE_CLOSURE == type)
return new SimpleDumpData("<Closure>");
if (TYPE_LAMBDA == type)
return new SimpleDumpData("<Lambda>");
}
// arguments
FunctionArgument[] args = udf.getFunctionArguments();
DumpTable atts;
if (TYPE_UDF == type)
atts = new DumpTable("udf", "#ca5095", "#e9accc", "#000000");
else if (TYPE_CLOSURE == type)
atts = new DumpTable("udf", "#9cb770", "#c7e1ba", "#000000");
else if (TYPE_BIF == type)
atts = new DumpTable("udf", "#e1c039", "#f1e2a3", "#000000");
else
atts = new DumpTable("udf", "#f3d5bd", "#f6e4cc", "#000000");
atts.appendRow(new DumpRow(63, new DumpData[] { new SimpleDumpData("label"), new SimpleDumpData("name"), new SimpleDumpData("required"), new SimpleDumpData("type"), new SimpleDumpData("default"), new SimpleDumpData("hint") }));
for (int i = 0; i < args.length; i++) {
FunctionArgument arg = args[i];
DumpData def;
try {
Object oa = udf.getDefaultValue(pageContext, i, null);
if (oa == null)
oa = "null";
def = new SimpleDumpData(Caster.toString(oa));
} catch (PageException e) {
def = new SimpleDumpData("");
}
atts.appendRow(new DumpRow(0, new DumpData[] { new SimpleDumpData(arg.getDisplayName()), new SimpleDumpData(arg.getName().getString()), new SimpleDumpData(arg.isRequired()), new SimpleDumpData(arg.getTypeAsString()), def, new SimpleDumpData(arg.getHint()) }));
// atts.setRow(0,arg.getHint());
}
DumpTable func;
String label = udf.getDisplayName();
if (TYPE_CLOSURE == type) {
func = new DumpTable("#9cb770", "#c7e1ba", "#000000");
func.setTitle(StringUtil.isEmpty(label) ? "Closure" : "Closure " + label);
} else if (TYPE_UDF == type) {
func = new DumpTable("#ca5095", "#e9accc", "#000000");
String f = "Function ";
try {
f = StringUtil.ucFirst(ComponentUtil.toStringAccess(udf.getAccess()).toLowerCase()) + " " + f;
} catch (ApplicationException e) {
}
f += udf.getFunctionName();
if (udf instanceof UDFGSProperty)
f += " (generated)";
func.setTitle(f);
} else if (TYPE_BIF == type) {
String f = "Build in Function " + (!StringUtil.isEmpty(label) ? label : udf.getFunctionName());
func = new DumpTable("#e1c039", "#f1e2a3", "#000000");
func.setTitle(f);
} else {
func = new DumpTable("#f3d5bd", "#f6e4cc", "#000000");
func.setTitle(StringUtil.isEmpty(label) ? "Lambda" : "Lambda " + label);
}
// Source
String src = udf.getSource();
if (!StringUtil.isEmpty(src))
func.setComment("source:" + src);
String hint = udf.getHint();
String desc = udf.getDescription();
if (!StringUtil.isEmpty(desc))
addComment(func, desc);
if (!StringUtil.isEmpty(hint))
addComment(func, hint);
if (Component.MODIFIER_NONE != udf.getModifier())
func.appendRow(1, new SimpleDumpData("modifier"), new SimpleDumpData(ComponentUtil.toModifier(udf.getModifier(), "")));
func.appendRow(1, new SimpleDumpData("arguments"), atts);
func.appendRow(1, new SimpleDumpData("return type"), new SimpleDumpData(udf.getReturnTypeAsString()));
return func;
}
use of lucee.runtime.type.UDFGSProperty in project Lucee by lucee.
the class ComponentImpl method getUDFs.
private static void getUDFs(PageContext pc, Iterator<UDF> it, ComponentImpl comp, int access, ArrayImpl arr) throws PageException {
UDF udf;
while (it.hasNext()) {
udf = it.next();
if (udf instanceof UDFGSProperty)
continue;
if (udf.getAccess() > access)
continue;
if (!udf.getPageSource().equals(comp._getPageSource()))
continue;
arr.append(ComponentUtil.getMetaData(pc, (UDFPropertiesBase) ((UDFImpl) udf).properties));
}
}
Aggregations