#1653 JS: list.make problem

jessevdam Sun 25 Sep 2011

In JS the list.make does not function properly

In the fan code we have

**
** Constructor with of type and initial capacity.
**
new make(Type of, Int capacity)

**
** Constructor for Obj?[] with initial capacity.
**
new makeObj(Int capacity)

In the java code we have

//the one from fan
public static List make(Type of, long capacity)
{
  return new List(of, (int)capacity);
}

public static List makeObj(long capacity)
{
  return new List(Sys.ObjType.toNullable(), (int)capacity);
}

//probably used somewhere internally in java impl
public static List make(Type of, Object[] values)
{
  if (values == null) return null;
  return new List(of, values);
}

In the the js code we have a make function which takes values, but I think it should take an integer for the initial capacity.

fan.sys.List.make = function(of, values) // -> values references an Integer not a List!!
{
  if (of == null) throw fan.sys.NullErr();
  if (values === undefined) values = [];

  var self = new fan.sys.List();
  self.m_of = of;
  self.m_size = values.length;
  self.m_values = values;
  self.m_readonly = false;
  self.m_immutable = false;
  return self;
}

andy Mon 26 Sep 2011

List.capacity isn't really supported under JavaScript (always returns size) - but pushed a fix that allows make and makeObj to work.

jessevdam Mon 26 Sep 2011

thanks

Login or Signup to reply.