Skip to content

Instantly share code, notes, and snippets.

@paulbaumgart
Created September 24, 2010 20:24
Show Gist options
  • Select an option

  • Save paulbaumgart/595973 to your computer and use it in GitHub Desktop.

Select an option

Save paulbaumgart/595973 to your computer and use it in GitHub Desktop.
CPVarArgHandling_Index = nil;
va_start = function (args, startIndex) // startIndex instead of parameter name
// isn't great, but is unavoidable since
// they took out argument names in JS 1.3.
// Only way to fix this would be to add it
// to the Obj-J preprocessor.
{
if (startIndex)
{
if (typeof startIndex !== "number")
throw new Error("Invalid var-args start index: " + startIndex);
CPVarArgHandling_Index = startIndex + 2;
}
else
CPVarArgHandling_Index = 2;
};
va_arg = function (args)
{
var value = args[CPVarArgHandling_Index++];
return value ? value : nil;
};
va_end = function(args)
{
CPVarArgHandling_Index = nil;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment