public Var(PPVar var) { ppvar = var; isManaged = true; if (NeedsRefcounting(ppvar)) { PPBVar.AddRef(ppvar); } }
public Var(Var other) { ppvar = other.ppvar; isManaged = true; if (NeedsRefcounting(ppvar)) { PPBVar.AddRef(ppvar); } }
public Var(object var) { if (var is int) { ppvar.type = PPVarType.Int32; ppvar.value.as_int = (int)var; isManaged = true; } if (var is uint) { ppvar.type = PPVarType.Int32; ppvar.value.as_int = Convert.ToInt32(var); isManaged = true; } else if (var is string) { ppvar = VarFromUtf8Helper((string)var); isManaged = true; } else if (var is bool) { ppvar.type = PPVarType.Bool; ppvar.value.as_bool = (bool)var ? PPBool.True : PPBool.False; isManaged = true; } else if (var is double) { ppvar.type = PPVarType.Double; ppvar.value.as_double = (double)var; isManaged = true; } // Note: You may see precision differences else if (var is float) { ppvar.type = PPVarType.Double; ppvar.value.as_double = Convert.ToDouble((float)var); isManaged = true; } else if (var is Var) { ppvar = ((Var)var).ppvar; isManaged = true; if (NeedsRefcounting(ppvar)) { PPBVar.AddRef(ppvar); } } else { ppvar.type = PPVarType.Undefined; isManaged = true; } }