Code Monkey home page Code Monkey logo

Comments (4)

Lovesan avatar Lovesan commented on May 30, 2024 2

@johnhilts
Yep, that's the way to do it.

@PersonalityEngineer
Also, consider using included custom syntax.

(named-readtables:in-readtable bike:bike-syntax)

;; change %SubObject to $SubObject in case if that is a field not a property
(let ((ob (new 'SomeObject)))
  [[[ob %SubObject] %SubObject2] Method "data"])

@PersonalityEngineer

Also an example on using a .Net float or string array (unboxing?) would be fantastic.

bike provides a generic way to access any array with dnaref and (setf dnaref) functions, e.g.

(let ((v (new '(array :float) 123)))
  (setf (dnaref v 0) 123.0s0)
  (dnaref v 0))

However, bike also allows to use pinned objects, so that you can access their memory directly (for ex. using cffi)

(let ((vector (new '(array :int) 10)))
    (with-fixed (ptr vector)
      (dotimes (i 10)
        (setf (cffi:mem-aref ptr :int i) (1+ i))))

from bike.

johnhilts avatar johnhilts commented on May 30, 2024 1

I think you can do it with a combination of bike:property and bike:invoke.

Here's what I did:

using System;

namespace MyNamespace
{
	public class InnerClass
	{
		public string GetInfo()
		{
			return "This is from the inner class!";
		}
	}

	public class OuterClass
	{
		public OuterClass ()
		{
			this.Inner = new InnerClass();
		}

		public InnerClass Inner {get; set;}

		public string GetInfo()
		{
			return "This is from the outer class!";
		}

		public int GetNumber()
		{
			return 1234;
		}
	}
}

Then in Lisp, I did this:

;; in SLIME
BIKE-EXAMPLES> (let ((the-outer-ojbect (new 'OuterClass)))
      (invoke (property the-outer-ojbect 'Inner) 'GetInfo))
=> "This is from the inner class!"

from bike.

johnhilts avatar johnhilts commented on May 30, 2024 1

Didn't know about dnaref - very handy :)

(dnaref (invoke (invoke 'Enumerable 'Range 1 10) 'ToArray) 1)

=> 2

from bike.

Lovesan avatar Lovesan commented on May 30, 2024

Finally, here are the docs: https://github.com/Lovesan/bike/blob/master/doc/README.md

from bike.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.