parsav  Diff

Differences From Artifact [15de92d877]:

To Artifact [a177326f1c]:


    52     52   		{'ct', intptr};
    53     53   	}
    54     54   	t.ptr_basetype = ty
    55     55   	local recurse = false
    56     56   	--if ty:isstruct() then
    57     57   		--if ty.methods.free then recurse = true end
    58     58   	--end
    59         -	t.metamethods.__not = macro(function(self)
    60         -		return `self.ptr
    61         -	end)
    62     59   	if dyn then
    63     60   		t.methods = {
    64     61   			free = terra(self: &t): bool
    65     62   				[recurse and quote
    66     63   					self.ptr:free()
    67     64   				end or {}]
    68     65   				if self.ct > 0 then
................................................................................
   104    101   		end
   105    102   	end
   106    103   	terra t:advance(n: intptr)
   107    104   		self.ptr = self.ptr + n
   108    105   		self.ct = self.ct - n
   109    106   		return self.ptr
   110    107   	end
          108  +	terra t.methods.null(): t return t { ptr = nil, ct = 0 } end -- maybe should be a macro?
          109  +	terra t:ref() return self.ptr ~= nil end
          110  +	t.metamethods.__not = macro(function(self) return `not self:ref() end)
          111  +	t.metamethods.__apply = macro(function(self,idx) return `self.ptr[idx] end)
   111    112   	if not ty:isstruct() then
   112    113   		terra t:cmp_raw(other: &ty)
   113    114   			for i=0, self.ct do
   114    115   				if self.ptr[i] ~= other[i] then return false end
   115    116   			end
   116    117   			return true
   117    118   		end