mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Let objects inherit caps from superclasses
The main point of this change is to allow "global" capabilities defined on the base object type. The example here is the clone capability on all objects, which governs the ability to clone a handle. Related changes in this commit: - Renamed `kobject` to `object` as far as the syscall interface is concerned. `kobject` is the cname, but j6_cap_kobject_clone feels clunky. - The above change made me realize that the "object <type>" syntax for specifying object references was also clunky, so now it's "ref <type>" - Having to add `.object` on everywhere to access objects in interface.exposes or object.super was cumbersome, so those properties now return object types directly, instead of ObjectRef. - syscall_verify.cpp.cog now generates code to check capabilities on handles if they're specified in the definition, even when not passing an object to the implementation function.
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -18,7 +18,7 @@ class Interface:
|
||||
self.desc = desc
|
||||
|
||||
self.functions = [c for c in children if isinstance(c, Function)]
|
||||
self.exposes = [e.type for e in children if isinstance(e, Expose)]
|
||||
self.__exposes = [e.type for e in children if isinstance(e, Expose)]
|
||||
|
||||
def __str__(self):
|
||||
parts = [f"interface {self.name}: {self.uid}"]
|
||||
@@ -35,8 +35,12 @@ class Interface:
|
||||
mm = [(i, None, self.functions[i]) for i in range(len(self.functions))]
|
||||
|
||||
base = len(mm)
|
||||
for o in [e.object for e in self.exposes]:
|
||||
for o in self.exposes:
|
||||
mm.extend([(base + i, o, o.methods[i]) for i in range(len(o.methods))])
|
||||
base += len(o.methods)
|
||||
|
||||
return mm
|
||||
|
||||
@property
|
||||
def exposes(self):
|
||||
return [ref.object for ref in self.__exposes]
|
||||
|
||||
@@ -7,11 +7,12 @@ class Object:
|
||||
self.uid = uid
|
||||
self.options = opts
|
||||
self.desc = desc
|
||||
self.super = typename
|
||||
self.methods = children
|
||||
self.cname = cname or name
|
||||
self.caps = caps
|
||||
|
||||
self.__super = typename
|
||||
|
||||
from . import ObjectRef
|
||||
self.__ref = ObjectRef(name)
|
||||
|
||||
@@ -25,3 +26,8 @@ class Object:
|
||||
return "\n".join(parts)
|
||||
|
||||
reftype = property(lambda self: self.__ref)
|
||||
|
||||
@property
|
||||
def super(self):
|
||||
if self.__super is not None:
|
||||
return self.__super.object
|
||||
|
||||
Reference in New Issue
Block a user