property macros

View: New views
5 Messages — Rating Filter:   Alert me  

property macros

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi,

i would like to do something like that:

macro property:
   return [|
      version as single:
         get: return _FLOAT(Marshal.ReadInt32(structure.version))
   |]

but properties don't seem to be supported for macros. why? will this be possible in the future?

i am trying to do a .net wrapper for a c-library and it would be extremely helpful if i could use macros for properties. i guess it would result in ten times less required code...

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: property macros

by Jeffery Olson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


try yield instead of return

On Mon, Oct 5, 2009 at 1:08 PM, horace <horace3d@...> wrote:

> hi,
>
> i would like to do something like that:
>
> macro property:
>    return [|
>       version as single:
>          get: return _FLOAT(Marshal.ReadInt32(structure.version))
>    |]
>
> but properties don't seem to be supported for macros. why? will this be
> possible in the future?
>
> i am trying to do a .net wrapper for a c-library and it would be extremely
> helpful if i could use macros for properties. i guess it would result in ten
> times less required code...
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: property macros

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Mon, Oct 5, 2009 at 10:11 PM, Jeffery Olson <olson.jeffery@...> wrote:

try yield instead of return


with yield the macro compiles without errors but the property i try to generate with it doesn't work. it seems like the property doesn't get created at all.

what is the difference of yield and return if i only want to return something once?

 

On Mon, Oct 5, 2009 at 1:08 PM, horace <horace3d@...> wrote:
> hi,
>
> i would like to do something like that:
>
> macro property:
>    return [|
>       version as single:
>          get: return _FLOAT(Marshal.ReadInt32(structure.version))
>    |]
>
> but properties don't seem to be supported for macros. why? will this be
> possible in the future?
>
> i am trying to do a .net wrapper for a c-library and it would be extremely
> helpful if i could use macros for properties. i guess it would result in ten
> times less required code...
>
> >
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: property macros

by Usul-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I have tried something similar and I see no issue...

macro property:
    yield [|
        public version as single:
            get: return 42
    |]

class TestClass:
    property

print "Runtime Version: " + typeof(List).Assembly.ImageRuntimeVersion
print "Boo version:" + BooVersion
print "TestClass version: " + TestClass().version

>>>

Runtime Version: v2.0.50727
Boo version:0.9.2.3383
TestClass version: 42


nb: added public because I'm in strict mode...


If ever you still have this issue, please provide a self contained example (that doesn't depend on external things like _FLOAT and structure.version)





2009/10/6 horace <horace3d@...>


On Mon, Oct 5, 2009 at 10:11 PM, Jeffery Olson <olson.jeffery@...> wrote:

try yield instead of return


with yield the macro compiles without errors but the property i try to generate with it doesn't work. it seems like the property doesn't get created at all.

what is the difference of yield and return if i only want to return something once?

 

On Mon, Oct 5, 2009 at 1:08 PM, horace <horace3d@...> wrote:
> hi,
>
> i would like to do something like that:
>
> macro property:
>    return [|
>       version as single:
>          get: return _FLOAT(Marshal.ReadInt32(structure.version))
>    |]
>
> but properties don't seem to be supported for macros. why? will this be
> possible in the future?
>
> i am trying to do a .net wrapper for a c-library and it would be extremely
> helpful if i could use macros for properties. i guess it would result in ten
> times less required code...
>
> >
>




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@...
To unsubscribe from this group, send email to boolang%2Bunsubscribe@...
For more options, visit this group at http://groups.google.com/group/boolang?hl=en
-~----------~----~----~----~------~----~------~--~---


--

You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@....
For more options, visit this group at http://groups.google.com/group/boolang?hl=.

Re: property macros

by horace3d@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Nov 11, 2009 at 5:22 PM, Usul Mouadib <mouadib@...> wrote:

>
> I have tried something similar and I see no issue...
>
> macro property:
>     yield [|
>         public version as single:
>             get: return 42
>     |]
>
> class TestClass:
>     property
>
> print "Runtime Version: " + typeof(List).Assembly.ImageRuntimeVersion
> print "Boo version:" + BooVersion
> print "TestClass version: " + TestClass().version
>
>>>>
>
> Runtime Version: v2.0.50727
> Boo version:0.9.2.3383
> TestClass version: 42
>
>
> nb: added public because I'm in strict mode...
>
>
> If ever you still have this issue, please provide a self contained example
> (that doesn't depend on external things like _FLOAT and structure.version)

my _FLOAT function (which is defined elsewhere - not in the macro file
but in the project where the macro will get used) converts from a
fixed point format to floating point.


def _FLOAT(v as int) as single:
        return cast(single, v) / (1 << 10)


thanks! i will try this again once i continue working on my wrapper project...



>
>
>
>
>
> 2009/10/6 horace <horace3d@...>
>>
>>
>> On Mon, Oct 5, 2009 at 10:11 PM, Jeffery Olson <olson.jeffery@...>
>> wrote:
>>>
>>> try yield instead of return
>>
>>
>> with yield the macro compiles without errors but the property i try to
>> generate with it doesn't work. it seems like the property doesn't get
>> created at all.
>>
>> what is the difference of yield and return if i only want to return
>> something once?
>>
>>
>>>
>>> On Mon, Oct 5, 2009 at 1:08 PM, horace <horace3d@...> wrote:
>>> > hi,
>>> >
>>> > i would like to do something like that:
>>> >
>>> > macro property:
>>> >    return [|
>>> >       version as single:
>>> >          get: return _FLOAT(Marshal.ReadInt32(structure.version))
>>> >    |]
>>> >
>>> > but properties don't seem to be supported for macros. why? will this be
>>> > possible in the future?
>>> >
>>> > i am trying to do a .net wrapper for a c-library and it would be
>>> > extremely
>>> > helpful if i could use macros for properties. i guess it would result
>>> > in ten
>>> > times less required code...
>>> >
>>> > >
>>> >
>>>
>>>
>>
>>
>> --~--~---------~--~----~------------~-------~--~----~
>> You received this message because you are subscribed to the Google Groups
>> "Boo Programming Language" group.
>> To post to this group, send email to boolang@...
>> To unsubscribe from this group, send email to
>> boolang+unsubscribe@...
>> For more options, visit this group at
>> http://groups.google.com/group/boolang?hl=en
>> -~----------~----~----~----~------~----~------~--~---
>>
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Boo Programming Language" group.
> To post to this group, send email to boolang@....
> For more options, visit this group at
> http://groups.google.com/group/boolang?hl=.
>

--

You received this message because you are subscribed to the Google Groups "Boo Programming Language" group.
To post to this group, send email to boolang@....
For more options, visit this group at http://groups.google.com/group/boolang?hl=.