/* --------------------------------------------------------- *
* __________ D E L T A S C R I P T *
* (_________() *
* / === / - A fast, dynamic scripting language *
* | == | - Version 4.13.11.0 *
* / === / - Developed by Adam R. Nelson *
* | = = | - 2011-2013 *
* / === / - Distributed under GNU LGPL v3 *
* (________() - http://github.com/ar-nelson/deltascript *
* *
* --------------------------------------------------------- */
package com.sector91.delta.script.objects;
import com.sector91.delta.script.annotations.DSType;
import com.sector91.delta.script.objects.reflect.DS_JavaClass;
/**
* <p>A convenience class for creating anonymous {@link DS_Callable} objects.
* It leaves only the {@link #call(DS_Scope, DS_Object...)} method undefined.
* The number of arguments it takes must be defined in the constructor.</p>
*
* @author Adam R. Nelson
* @version 4.13.11.0
* @since 3.12.2.0
*/
@DSType("AnonymousCallable")
public abstract class DS_AnonymousCallable extends DS_AbstractObject
implements DS_Callable
{
public static final String TYPE_NAME = "AnonymousCallable";
private final int args;
public DS_AnonymousCallable(int argCount)
{args = argCount;}
public int getArgCount()
{return args;}
public String[] getArgNames()
{
String[] argNames = new String[args];
for (int i=0; i<args; i++)
argNames[i] = "arg"+i;
return argNames;
}
public boolean equals(DS_Object other)
{return this == other;}
public String getTypeName()
{return TYPE_NAME;}
public Object unbox()
{return this;}
@Override protected DS_JavaClass getDeltaScriptClass()
{return DS_JavaClass.fromClass(DS_AnonymousCallable.class);}
}