Skip to content

Commit

Permalink
Merge pull request #331 from luketpeterson/python_space_impl
Browse files Browse the repository at this point in the history
Consolidating MeTTa type definitions in one place for Atom Types and Grounded Atom Types
  • Loading branch information
luketpeterson authored Jun 16, 2023
2 parents b5acba1 + 5a76552 commit 8ee0262
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 0 additions & 2 deletions c/src/atom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ pub struct bindings_set_t {
pub type bindings_callback_t = lambda_t<*const bindings_t>;
pub type bindings_mut_callback_t = lambda_t<*mut bindings_t>;

#[no_mangle] pub extern "C" fn ATOM_TYPE_GROUNDED_SPACE() -> *mut atom_t { atom_into_ptr(rust_type_atom::<DynSpace>()) }

#[repr(C)]
pub struct gnd_api_t {
// TODO: replace args by C array and ret by callback
Expand Down
3 changes: 3 additions & 0 deletions c/src/metta.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use hyperon::space::DynSpace;
use hyperon::Atom;
use hyperon::metta::text::*;
use hyperon::metta::interpreter;
use hyperon::metta::interpreter::InterpretedAtom;
use hyperon::common::plan::StepResult;
use hyperon::metta::runner::Metta;
use hyperon::rust_type_atom;

use crate::util::*;
use crate::atom::*;
Expand Down Expand Up @@ -89,6 +91,7 @@ pub unsafe extern "C" fn sexpr_parser_parse(parser: *mut sexpr_parser_t,
#[no_mangle] pub extern "C" fn ATOM_TYPE_VARIABLE() -> *mut atom_t { atom_into_ptr(hyperon::metta::ATOM_TYPE_VARIABLE) }
#[no_mangle] pub extern "C" fn ATOM_TYPE_EXPRESSION() -> *mut atom_t { atom_into_ptr(hyperon::metta::ATOM_TYPE_EXPRESSION) }
#[no_mangle] pub extern "C" fn ATOM_TYPE_GROUNDED() -> *mut atom_t { atom_into_ptr(hyperon::metta::ATOM_TYPE_GROUNDED) }
#[no_mangle] pub extern "C" fn ATOM_TYPE_GROUNDED_SPACE() -> *mut atom_t { atom_into_ptr(rust_type_atom::<DynSpace>()) }

#[no_mangle]
pub unsafe extern "C" fn check_type(space: *const space_t, atom: *const atom_t, typ: *const atom_t) -> bool {
Expand Down
6 changes: 2 additions & 4 deletions python/hyperon/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ class AtomType:
VARIABLE = Atom._from_catom(hp.CAtomType.VARIABLE)
EXPRESSION = Atom._from_catom(hp.CAtomType.EXPRESSION)
GROUNDED = Atom._from_catom(hp.CAtomType.GROUNDED)

class GroundedAtomType:
SPACE = Atom._from_catom(hp.CAtomType.GROUNDED_SPACE)
GROUNDED_SPACE = Atom._from_catom(hp.CAtomType.GROUNDED_SPACE)

class GroundedAtom(Atom):

Expand All @@ -100,7 +98,7 @@ def __init__(self, catom):

def get_object(self):
from .base import Space
if self.get_grounded_type() == GroundedAtomType.SPACE:
if self.get_grounded_type() == AtomType.GROUNDED_SPACE:
return Space._from_cspace(hp.atom_get_space(self.catom))
else:
return hp.atom_get_object(self.catom)
Expand Down

0 comments on commit 8ee0262

Please sign in to comment.