pub(crate) fn build(self, env: &mut Environment, gc: &mut Memory) -> Result<BuiltType<T>, Error>
   where
      T: Any + Sized,
   {
      // Build the dtables.
      let mut type_dtable = self.type_dtable.build_dtable(
         DispatchTable::new_for_type(Rc::clone(&self.type_name)),
         env,
         gc,
      )?;
      let instance_dtable = self.instance_dtable.build_dtable(
         DispatchTable::new_for_instance(Rc::clone(&self.type_name)),
         env,
         gc,
      )?;
      let instance_dtable = Gc::new(instance_dtable);

      // The type dtable also contains constructors, so build those while we're at it.
      // We implement a helper here that fulfills the ObjectConstructor trait.

      struct Instancer<T>
      where
         T: Sized,
      {
         instance_dtable: Gc<DispatchTable>,
         _data: PhantomData<T>,
      }

      impl<T> ObjectConstructor<T> for Instancer<T> {
         fn construct(&self, instance: T) -> crate::Object<T> {
            Object::new(Gc::as_raw(&self.instance_dtable), instance)
         }
      }

      let instancer: Rc<dyn ObjectConstructor<T>> = Rc::new(Instancer {
         instance_dtable: Gc::clone(&instance_dtable),
         _data: PhantomData,
      });
      for (signature, constructor) in self.constructors {
         let f = constructor(Rc::clone(&instancer));
         DispatchTableDescriptor::add_function_to_dtable(
            env,
            gc,
            &mut type_dtable,
            signature,
            FunctionKind::Foreign(f),
         )?;
      }

      // Build the instance dtable.
      type_dtable.instance = Some(Gc::as_raw(&instance_dtable));

      let type_dtable = Gc::new(type_dtable);
      Ok(BuiltType {
         type_dtable,
         instance_dtable,
         type_name: self.type_name,
         _data: PhantomData,
      })
   }
/// Builds the struct builder into its type dtable and instance dtable, respectively.
Builds the struct builder into its type dtable and instance dtable, respectively.
Builds the struct builder into its type dtable and instance dtable respectively .
pub(crate) fn build(self, env: &mut Environment, gc: &mut Memory) -> Result<BuiltType<T>, Error>
   where
      T: Any + Sized,
   {
      // Build the dtables.
      let mut type_dtable = self.type_dtable.build_dtable(
         DispatchTable::new_for_type(Rc::clone(&self.type_name)),
         env,
         gc,
      )?;
      let instance_dtable = self.instance_dtable.build_dtable(
         DispatchTable::new_for_instance(Rc::clone(&self.type_name)),
         env,
         gc,
      )?;
      let instance_dtable = Gc::new(instance_dtable);
      // The type dtable also contains constructors, so build those while we're at it.
      // We implement a helper here that fulfills the ObjectConstructor trait.
      struct Instancer<T>
      where
         T: Sized,
      {
         instance_dtable: Gc<DispatchTable>,
         _data: PhantomData<T>,
      }
      impl<T> ObjectConstructor<T> for Instancer<T> {
         fn construct(&self, instance: T) -> crate::Object<T> {
            Object::new(Gc::as_raw(&self.instance_dtable), instance)
         }
      }
      let instancer: Rc<dyn ObjectConstructor<T>> = Rc::new(Instancer {
         instance_dtable: Gc::clone(&instance_dtable),
         _data: PhantomData,
      });
      for (signature, constructor) in self.constructors {
         let f = constructor(Rc::clone(&instancer));
         DispatchTableDescriptor::add_function_to_dtable(
            env,
            gc,
            &mut type_dtable,
            signature,
            FunctionKind::Foreign(f),
         )?;
      }
      // Build the instance dtable.
      type_dtable.instance = Some(Gc::as_raw(&instance_dtable));
      let type_dtable = Gc::new(type_dtable);
      Ok(BuiltType {
         type_dtable,
         instance_dtable,
         type_name: self.type_name,
         _data: PhantomData,
      })
   }
pub ( crate ) fn build ( self , env : & mut Environment , gc : & mut Memory ) -> Result < BuiltType < T > , Error > where T : Any + Sized , { // Build the dtables. let mut type_dtable = self . type_dtable . build_dtable ( DispatchTable :: new_for_type ( Rc :: clone ( & self . type_name ) ) , env , gc , ) ? ; let instance_dtable = self . instance_dtable . build_dtable ( DispatchTable :: new_for_instance ( Rc :: clone ( & self . type_name ) ) , env , gc , ) ? ; let instance_dtable = Gc :: new ( instance_dtable ) ; // The type dtable also contains constructors, so build those while we're at it. // We implement a helper here that fulfills the ObjectConstructor trait. struct Instancer < T > where T : Sized , { instance_dtable : Gc < DispatchTable > , _data : PhantomData < T > , } impl < T > ObjectConstructor < T > for Instancer < T > { fn construct ( & self , instance : T ) -> crate :: Object < T > { Object :: new ( Gc :: as_raw ( & self . instance_dtable ) , instance ) } } let instancer : Rc < dyn ObjectConstructor < T > > = Rc :: new ( Instancer { instance_dtable : Gc :: clone ( & instance_dtable ) , _data : PhantomData , } ) ; for ( signature , constructor ) in self . constructors { let f = constructor ( Rc :: clone ( & instancer ) ) ; DispatchTableDescriptor :: add_function_to_dtable ( env , gc , & mut type_dtable , signature , FunctionKind :: Foreign ( f ) , ) ? ; } // Build the instance dtable. type_dtable . instance = Some ( Gc :: as_raw ( & instance_dtable ) ) ; let type_dtable = Gc :: new ( type_dtable ) ; Ok ( BuiltType { type_dtable , instance_dtable , type_name : self . type_name , _data : PhantomData , } ) }
Builds the struct builder into its type dtable and instance dtable, respectively.
Builds the struct builder into its type dtable and instance dtable respectively .
self
env
&mut Environment
gc
&mut Memory