python

Dependencies:   TSI mbed

Fork of pymite by Norimasa Okamoto

Revision:
2:a2bea117e22e
Parent:
1:28afb064a41c
Child:
3:559c4bd38111
diff -r 28afb064a41c -r a2bea117e22e platform/mbed/main_nat.cpp
--- a/platform/mbed/main_nat.cpp	Sun Mar 10 10:13:36 2013 +0000
+++ b/platform/mbed/main_nat.cpp	Tue Mar 12 11:40:41 2013 +0000
@@ -4,7 +4,7 @@
  * PyMite usr native function file
  *
  * automatically created by pmImgCreator.py
- * on Sun Mar 10 18:24:12 2013
+ * on Tue Mar 12 20:23:40 2013
  *
  * DO NOT EDIT THIS FILE.
  * ANY CHANGES WILL BE LOST.
@@ -17,14 +17,7 @@
 
 /* From: mbed.py */
 #include "mbed.h"
-
-/* PinName lookup table.  Converts pin number to PinName. */
-static PinName const pinNumToName[] = {
-    NC, LED1, LED2, LED3, LED4, p5, p6, p7, p8, p9,
-    p10, p11, p12, p13, p14, p15, p16, p17, p18, p19,
-    p20, p21, p22, p23, p24, p25, p26, p27, p28, p29,
-    p30
-};
+#include "NativeClassInterface.h"
 
 PmReturn_t
 nat_placeholder_func(pPmFrame_t *ppframe)
@@ -45,43 +38,8 @@
 nat_01_mbed___init__(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalOut *dout;
-        uint8_t objid;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        dout = new DigitalOut(pinNumToName[((pPmInt_t)pn)->val]);
-
-        /* Save the pointer to adc as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)dout, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        heap_gcPushTempRoot(pn, &objid);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        heap_gcPopTempRoot(objid);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.init<DigitalOut,PinName>(OBJ_TYPE_INT);
         
 }
 
@@ -89,40 +47,8 @@
 nat_02_mbed_write(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalOut *dout;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dout = (DigitalOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        dout->write(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<DigitalOut,int,&DigitalOut::write>(OBJ_TYPE_NON, OBJ_TYPE_INT);
         
 }
 
@@ -130,33 +56,8 @@
 nat_03_mbed_read(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalOut *dout;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dout = (DigitalOut *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = dout->read();
-        retval = int_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<int,DigitalOut,&DigitalOut::read>(OBJ_TYPE_INT);
         
 }
 
@@ -164,43 +65,8 @@
 nat_04_mbed___init__(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalIn *din;
-        uint8_t objid;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        din = new DigitalIn(pinNumToName[((pPmInt_t)pn)->val]);
-
-        /* Save the pointer to adc as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)din, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        heap_gcPushTempRoot(pn, &objid);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        heap_gcPopTempRoot(objid);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.init<DigitalIn,PinName>(OBJ_TYPE_INT);
         
 }
 
@@ -208,33 +74,8 @@
 nat_05_mbed_read(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalIn *din;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        din = (DigitalIn *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = din->read();
-        retval = int_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<int,DigitalIn,&DigitalIn::read>(OBJ_TYPE_INT);
         
 }
 
@@ -242,1170 +83,400 @@
 nat_06_mbed___init__(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogIn *adc;
-        uint8_t objid;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.init<DigitalInOut,PinName>(OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        adc = new AnalogIn(pinNumToName[((pPmInt_t)pn)->val]);
+PmReturn_t
+nat_07_mbed_read(pPmFrame_t *ppframe)
+{
 
-        /* Save the pointer to adc as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)adc, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        heap_gcPushTempRoot(pn, &objid);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        heap_gcPopTempRoot(objid);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<int,DigitalInOut,&DigitalInOut::read>(OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_07_mbed_read_u16(pPmFrame_t *ppframe)
+nat_08_mbed_write(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogIn *adc;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        adc = (AnalogIn *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = adc->read_u16();
-        retval = int_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<DigitalInOut,int,&DigitalInOut::write>(OBJ_TYPE_NON, OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_08_mbed_read(pPmFrame_t *ppframe)
+nat_09_mbed_input(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogIn *adc;
-        float n;
+        NativeClassInterface nci;
+        return nci.method<DigitalInOut,&DigitalInOut::input>(OBJ_TYPE_NON);
+        
+}
 
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+PmReturn_t
+nat_10_mbed_output(pPmFrame_t *ppframe)
+{
 
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        adc = (AnalogIn *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = adc->read();
-        retval = float_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<DigitalInOut,&DigitalInOut::output>(OBJ_TYPE_NON);
         
 }
 
 PmReturn_t
-nat_09_mbed___init__(pPmFrame_t *ppframe)
+nat_11_mbed___init__(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogOut *dac;
-        uint8_t objid;
-
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.init<AnalogIn,PinName>(OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the object */
-        dac = new AnalogOut(pinNumToName[((pPmInt_t)pn)->val]);
+PmReturn_t
+nat_12_mbed_read_u16(pPmFrame_t *ppframe)
+{
 
-        /* Save the pointer to adc as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)dac, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        heap_gcPushTempRoot(pn, &objid);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        heap_gcPopTempRoot(objid);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<uint16_t,AnalogIn,&AnalogIn::read_u16>(OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_10_mbed_write_u16(pPmFrame_t *ppframe)
+nat_13_mbed_read(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogOut *dac;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dac = (AnalogOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        dac->write_u16(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<float,AnalogIn,&AnalogIn::read>(OBJ_TYPE_FLT);
         
 }
 
 PmReturn_t
-nat_11_mbed_write(pPmFrame_t *ppframe)
+nat_14_mbed___init__(pPmFrame_t *ppframe)
+{
+
+        NativeClassInterface nci;
+        return nci.init<AnalogOut,PinName>(OBJ_TYPE_INT);
+        
+}
+
+PmReturn_t
+nat_15_mbed_write_u16(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogOut *dac;
-        float n;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.method<AnalogOut,uint16_t,&AnalogOut::write_u16>(OBJ_TYPE_NON, OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_FLT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dac = (AnalogOut *)((pPmInt_t)pn)->val;
+PmReturn_t
+nat_16_mbed_write(pPmFrame_t *ppframe)
+{
 
-        /* Saturate and write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        n = ((pPmFloat_t)pn)->val;
-        if (n < 0.0)
-        {
-            n = 0.0;
-        }
-        else if (n > 1.0)
-        {
-            n = 1.0;
-        }
-        dac->write(n);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<AnalogOut,float,&AnalogOut::write>(OBJ_TYPE_NON, OBJ_TYPE_FLT);
         
 }
 
 PmReturn_t
-nat_12_mbed_read(pPmFrame_t *ppframe)
+nat_17_mbed_read(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        AnalogOut *dac;
-        float n;
+        NativeClassInterface nci;
+        return nci.method<float,AnalogOut,&AnalogOut::read>(OBJ_TYPE_FLT);
+        
+}
 
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+PmReturn_t
+nat_18_mbed___init__(pPmFrame_t *ppframe)
+{
 
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dac = (AnalogOut *)((pPmInt_t)pn)->val;
-
-        /* Return output value on the stack */
-        n = dac->read();
-        retval = float_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
+        NativeClassInterface nci;
+        return nci.init<PwmOut,PinName>(OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_13_mbed___init__(pPmFrame_t *ppframe)
+nat_19_mbed_write(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-        uint8_t objid;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        pwm = new PwmOut(pinNumToName[((pPmInt_t)pn)->val]);
-
-        /* Save the pointer to pwm as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)pwm, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        heap_gcPushTempRoot(pn, &objid);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        heap_gcPopTempRoot(objid);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<PwmOut,float,&PwmOut::write>(OBJ_TYPE_NON, OBJ_TYPE_FLT);
         
 }
 
 PmReturn_t
-nat_14_mbed_write(pPmFrame_t *ppframe)
+nat_20_mbed_read(pPmFrame_t *ppframe)
 {
 
-        PmReturn_t retval = PM_RET_OK;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pPmObj_t pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pPmObj_t pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_FLT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pPmObj_t pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        PwmOut* pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        pn = NATIVE_GET_LOCAL(1);
-        float n = ((pPmFloat_t)pn)->val;
-        pwm->write(n);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<float,PwmOut,&PwmOut::read>(OBJ_TYPE_FLT);
         
 }
 
 PmReturn_t
-nat_15_mbed_read(pPmFrame_t *ppframe)
+nat_21_mbed_period(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        DigitalOut *dout;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        dout = (DigitalOut *)((pPmInt_t)pn)->val;
-
-        /* Return input value on the stack */
-        n = dout->read();
-        retval = int_new(n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<PwmOut,float,&PwmOut::period>(OBJ_TYPE_NON, OBJ_TYPE_FLT);
         
 }
 
 PmReturn_t
-nat_16_mbed_period(pPmFrame_t *ppframe)
+nat_22_mbed_period_ms(pPmFrame_t *ppframe)
 {
 
-        PmReturn_t retval = PM_RET_OK;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pPmObj_t pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pPmObj_t pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_FLT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pPmObj_t pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        PwmOut* pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->period(((pPmFloat_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<PwmOut,int,&PwmOut::period_ms>(OBJ_TYPE_NON, OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_17_mbed_period_ms(pPmFrame_t *ppframe)
+nat_23_mbed_period_us(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->period_ms(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<PwmOut,int,&PwmOut::period_us>(OBJ_TYPE_NON, OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_18_mbed_period_us(pPmFrame_t *ppframe)
+nat_24_mbed_pulsewidth(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->period_us(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<PwmOut,float,&PwmOut::pulsewidth>(OBJ_TYPE_NON, OBJ_TYPE_FLT);
         
 }
 
 PmReturn_t
-nat_19_mbed_pulsewidth(pPmFrame_t *ppframe)
+nat_25_mbed_pulsewidth_ms(pPmFrame_t *ppframe)
+{
+
+        NativeClassInterface nci;
+        return nci.method<PwmOut,int,&PwmOut::pulsewidth_ms>(OBJ_TYPE_NON, OBJ_TYPE_INT);
+        
+}
+
+PmReturn_t
+nat_26_mbed_pulsewidth_us(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.method<PwmOut,int,&PwmOut::pulsewidth_us>(OBJ_TYPE_NON, OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_FLT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
+PmReturn_t
+nat_27_mbed___init__(pPmFrame_t *ppframe)
+{
 
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        PwmOut* pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->pulsewidth(((pPmFloat_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.init<Serial,PinName,PinName>(OBJ_TYPE_INT, OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_20_mbed_puslewidth_ms(pPmFrame_t *ppframe)
+nat_28_mbed_baud(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.method<Serial,int,&Serial::baud>(OBJ_TYPE_NON, OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
+PmReturn_t
+nat_29_mbed_readable(pPmFrame_t *ppframe)
+{
 
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->pulsewidth_ms(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<int,Serial,&Serial::readable>(OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_21_mbed_pulsewidth_us(pPmFrame_t *ppframe)
+nat_30_mbed_writeable(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        PwmOut *pwm;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        pwm = (PwmOut *)((pPmInt_t)pn)->val;
-
-        pn = NATIVE_GET_LOCAL(1);
-        pwm->pulsewidth_us(((pPmInt_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<int,Serial,&Serial::writeable>(OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_22_mbed___init__(pPmFrame_t *ppframe)
+nat_31_mbed_putc(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t ptx;
-        pPmObj_t prx;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        Serial *ser;
-        uint8_t objid;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 3)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        ptx = NATIVE_GET_LOCAL(1);
-        prx = NATIVE_GET_LOCAL(2);
-        if ((OBJ_GET_TYPE(ptx) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(prx) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        ser = new Serial(pinNumToName[((pPmInt_t)ptx)->val],
-                         pinNumToName[((pPmInt_t)prx)->val]);
-
-        /* Save the pointer to ser as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)ser, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        heap_gcPushTempRoot(pn, &objid);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        heap_gcPopTempRoot(objid);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        Serial* obj;
+        nci._load_obj<Serial>(&obj);
+        int r = obj->putc(nci.argv<int>(1));
+        return nci.set_return_value<int>(OBJ_TYPE_INT, r);
+        //return nci.method<int,Serial,int,&Serial::putc>(OBJ_TYPE_INT, OBJ_TYPE_STR);
         
 }
 
 PmReturn_t
-nat_23_mbed_putc(pPmFrame_t *ppframe)
+nat_32_mbed_puts(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        Serial *ser;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_STR)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        ser = (Serial *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        ser->putc(((pPmString_t)pn)->val[0]);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
-        
-}
-
-PmReturn_t
-nat_24_mbed_puts(pPmFrame_t *ppframe)
-{
-
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        Serial *ser;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        pn = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pn) != OBJ_TYPE_STR)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        ser = (Serial *)((pPmInt_t)pn)->val;
-
-        /* Write value to DAC */
-        pn = NATIVE_GET_LOCAL(1);
-        ser->puts((const char *)((pPmString_t)pn)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        Serial* obj;
+        nci._load_obj<Serial>(&obj);
+        int r = obj->puts(nci.argv<const char*>(1));
+        return nci.set_return_value<int>(OBJ_TYPE_INT, r);
+        //return nci.method<int,Serial,char*,&Serial::puts>(OBJ_TYPE_INT, OBJ_TYPE_STR);
         
 }
 
 PmReturn_t
-nat_25_mbed_getc(pPmFrame_t *ppframe)
+nat_33_mbed_getc(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        Serial *ser;
-        int32_t n;
-
-        /* If wrong number of args, throw type exception */
-        if (NATIVE_GET_NUM_ARGS() != 1)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        ser = (Serial *)((pPmInt_t)pn)->val;
-
-        /* Return char (as string) on the stack */
-        n = ser->getc();
-        retval = string_newFromChar((uint8_t)n, &pn);
-        NATIVE_SET_TOS(pn);
-
-        return retval;
+        NativeClassInterface nci;
+        Serial* obj;
+        nci._load_obj<Serial>(&obj);
+        int r = obj->getc();
+        return nci.set_return_value<int>(OBJ_TYPE_STR, r);
+        //return nci.method<int,Serial,&Serial::getc>(OBJ_TYPE_STR);
         
 }
 
 PmReturn_t
-nat_26_mbed___init__(pPmFrame_t *ppframe)
+nat_34_mbed___init__(pPmFrame_t *ppframe)
+{
+
+        NativeClassInterface nci;
+        return nci.init<SPI,PinName,PinName,PinName>(OBJ_TYPE_INT, OBJ_TYPE_INT, OBJ_TYPE_INT);
+        
+}
+
+PmReturn_t
+nat_35_mbed_format(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pmosi;
-        pPmObj_t pmiso;
-        pPmObj_t psclk;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        SPI *spi;
-        uint8_t objid;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 4)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.method<SPI,int,int,&SPI::format>(OBJ_TYPE_NON, OBJ_TYPE_INT, OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        pmosi = NATIVE_GET_LOCAL(1);
-        pmiso = NATIVE_GET_LOCAL(2);
-        psclk = NATIVE_GET_LOCAL(3);
-        if ((OBJ_GET_TYPE(pmosi) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(pmiso) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(psclk) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
+PmReturn_t
+nat_36_mbed_frequency(pPmFrame_t *ppframe)
+{
 
-        /* Instantiate the C++ object */
-        spi = new SPI(pinNumToName[((pPmInt_t)pmosi)->val],
-                      pinNumToName[((pPmInt_t)pmiso)->val],
-                      pinNumToName[((pPmInt_t)psclk)->val]);
-
-        /* Save the pointer to ser as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)spi, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        heap_gcPushTempRoot(pn, &objid);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        heap_gcPopTempRoot(objid);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<SPI,int,&SPI::frequency>(OBJ_TYPE_NON, OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_27_mbed_format(pPmFrame_t *ppframe)
+nat_37_mbed_write(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pbits;
-        pPmObj_t pmode;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        SPI *spi;
-
-        /* Raise TypeError if wrong number of args */
-        if ((NATIVE_GET_NUM_ARGS() < 2) || (NATIVE_GET_NUM_ARGS() > 3))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.method<int,SPI,int,&SPI::write>(OBJ_TYPE_INT, OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        pbits = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pbits) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
+PmReturn_t
+nat_38_mbed___init__(pPmFrame_t *ppframe)
+{
 
-        /* Get the mode arg if it exists */
-        pmode = PM_ZERO;
-        if (NATIVE_GET_NUM_ARGS() == 3)
-        {
-            pmode = NATIVE_GET_LOCAL(3);
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        spi = (SPI *)((pPmInt_t)pn)->val;
-
-        /* Set format args */
-        spi->format(((pPmInt_t)pbits)->val, ((pPmInt_t)pmode)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.init<I2C,PinName,PinName>(OBJ_TYPE_INT, OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_28_mbed_frequency(pPmFrame_t *ppframe)
+nat_39_mbed_frequency(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t phz;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        SPI *spi;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        phz = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(phz) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        spi = (SPI *)((pPmInt_t)pn)->val;
-
-        /* Set frequency */
-        spi->frequency(((pPmInt_t)phz)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<I2C,int,&I2C::frequency>(OBJ_TYPE_NON, OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_29_mbed_write(pPmFrame_t *ppframe)
+nat_40_mbed_read(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t pv;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        SPI *spi;
-        int32_t r;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.method<int,I2C,int,char*,int,bool,&I2C::read>(OBJ_TYPE_INT, 
+        OBJ_TYPE_INT, OBJ_TYPE_STR, OBJ_TYPE_INT, OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        pv = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(pv) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
+PmReturn_t
+nat_41_mbed_write(pPmFrame_t *ppframe)
+{
 
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        spi = (SPI *)((pPmInt_t)pn)->val;
-
-        /* Write the value and return the response */
-        r = spi->write(((pPmInt_t)pv)->val);
-        retval = int_new(r, &pn);
-        NATIVE_SET_TOS(pn);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<int,I2C,int,const char*,int,bool,&I2C::write>(OBJ_TYPE_INT, 
+        OBJ_TYPE_INT, OBJ_TYPE_STR, OBJ_TYPE_INT, OBJ_TYPE_INT);
         
 }
 
 PmReturn_t
-nat_30_mbed___init__(pPmFrame_t *ppframe)
+nat_42_mbed___init__(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t psda;
-        pPmObj_t pscl;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        I2C *i2c;
-        uint8_t objid;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 3)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        psda = NATIVE_GET_LOCAL(1);
-        pscl = NATIVE_GET_LOCAL(2);
-        if ((OBJ_GET_TYPE(psda) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(pscl) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Instantiate the C++ object */
-        i2c = new I2C(pinNumToName[((pPmInt_t)psda)->val],
-                      pinNumToName[((pPmInt_t)pscl)->val]);
-
-        /* Save the pointer to ser as an inaccessible attribute */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = int_new((uint32_t)i2c, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        heap_gcPushTempRoot(pn, &objid);
-        retval = dict_setItem(pattrs, PM_NONE, pn);
-        heap_gcPopTempRoot(objid);
-        PM_RETURN_IF_ERROR(retval);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.init<Timer>();
         
 }
 
 PmReturn_t
-nat_31_mbed_frequency(pPmFrame_t *ppframe)
+nat_43_mbed_start(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t phz;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        I2C *i2c;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 2)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.method<Timer,&Timer::start>(OBJ_TYPE_NON);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        phz = NATIVE_GET_LOCAL(1);
-        if (OBJ_GET_TYPE(phz) != OBJ_TYPE_INT)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
+PmReturn_t
+nat_44_mbed_stop(pPmFrame_t *ppframe)
+{
 
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        i2c = (I2C *)((pPmInt_t)pn)->val;
-
-        /* Set frequency */
-        i2c->frequency(((pPmInt_t)phz)->val);
-
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<Timer,&Timer::stop>(OBJ_TYPE_NON);
         
 }
 
 PmReturn_t
-nat_32_mbed_read(pPmFrame_t *ppframe)
+nat_45_mbed_reset(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t paddr;
-        pPmObj_t pdata;
-        pPmObj_t plen;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        I2C *i2c;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 4)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
-
-        /* Raise TypeError if arg is not the right type */
-        paddr = NATIVE_GET_LOCAL(1);
-        pdata = NATIVE_GET_LOCAL(2);
-        plen = NATIVE_GET_LOCAL(3);
-        if ((OBJ_GET_TYPE(paddr) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(pdata) != OBJ_TYPE_STR)
-            || (OBJ_GET_TYPE(plen) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        i2c = (I2C *)((pPmInt_t)pn)->val;
-
-        /* Read the bytes into the string */
-        /* WARNING: Changing the bytes of a string object is BAD. */
-        i2c->read(((pPmInt_t)paddr)->val,
-                  (char *)((pPmString_t)pdata)->val,
-                  ((pPmInt_t)plen)->val);
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<Timer,&Timer::reset>(OBJ_TYPE_NON);
         
 }
 
 PmReturn_t
-nat_33_mbed_write(pPmFrame_t *ppframe)
+nat_46_mbed_read(pPmFrame_t *ppframe)
+{
+
+        NativeClassInterface nci;
+        return nci.method<float,Timer,&Timer::read>(OBJ_TYPE_FLT);
+        
+}
+
+PmReturn_t
+nat_47_mbed_read_ms(pPmFrame_t *ppframe)
 {
 
-        pPmObj_t pself;
-        pPmObj_t pn;
-        pPmObj_t paddr;
-        pPmObj_t pdata;
-        pPmObj_t plen;
-        pPmObj_t pattrs;
-        PmReturn_t retval = PM_RET_OK;
-        I2C *i2c;
-
-        /* Raise TypeError if wrong number of args */
-        if (NATIVE_GET_NUM_ARGS() != 4)
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
-        pself = NATIVE_GET_LOCAL(0);
+        NativeClassInterface nci;
+        return nci.method<int,Timer,&Timer::read_ms>(OBJ_TYPE_INT);
+        
+}
 
-        /* Raise TypeError if arg is not the right type */
-        paddr = NATIVE_GET_LOCAL(1);
-        pdata = NATIVE_GET_LOCAL(2);
-        plen = NATIVE_GET_LOCAL(3);
-        if ((OBJ_GET_TYPE(paddr) != OBJ_TYPE_INT)
-            || (OBJ_GET_TYPE(pdata) != OBJ_TYPE_STR)
-            || (OBJ_GET_TYPE(plen) != OBJ_TYPE_INT))
-        {
-            PM_RAISE(retval, PM_RET_EX_TYPE);
-            return retval;
-        }
+PmReturn_t
+nat_48_mbed_read_us(pPmFrame_t *ppframe)
+{
 
-        /* Get the the C++ instance */
-        pattrs = (pPmObj_t)((pPmInstance_t)pself)->cli_attrs;
-        retval = dict_getItem(pattrs, PM_NONE, &pn);
-        PM_RETURN_IF_ERROR(retval);
-        i2c = (I2C *)((pPmInt_t)pn)->val;
-
-        /* Write the value and return the response */
-        i2c->write(((pPmInt_t)paddr)->val,
-                   (char *)((pPmString_t)pdata)->val,
-                   ((pPmInt_t)plen)->val);
-        NATIVE_SET_TOS(PM_NONE);
-        return retval;
+        NativeClassInterface nci;
+        return nci.method<int,Timer,&Timer::read_us>(OBJ_TYPE_INT);
         
 }
 
@@ -1419,31 +490,46 @@
     nat_04_mbed___init__,
     nat_05_mbed_read,
     nat_06_mbed___init__,
-    nat_07_mbed_read_u16,
-    nat_08_mbed_read,
-    nat_09_mbed___init__,
-    nat_10_mbed_write_u16,
-    nat_11_mbed_write,
-    nat_12_mbed_read,
-    nat_13_mbed___init__,
-    nat_14_mbed_write,
-    nat_15_mbed_read,
-    nat_16_mbed_period,
-    nat_17_mbed_period_ms,
-    nat_18_mbed_period_us,
-    nat_19_mbed_pulsewidth,
-    nat_20_mbed_puslewidth_ms,
-    nat_21_mbed_pulsewidth_us,
-    nat_22_mbed___init__,
-    nat_23_mbed_putc,
-    nat_24_mbed_puts,
-    nat_25_mbed_getc,
-    nat_26_mbed___init__,
-    nat_27_mbed_format,
-    nat_28_mbed_frequency,
-    nat_29_mbed_write,
-    nat_30_mbed___init__,
-    nat_31_mbed_frequency,
-    nat_32_mbed_read,
-    nat_33_mbed_write,
+    nat_07_mbed_read,
+    nat_08_mbed_write,
+    nat_09_mbed_input,
+    nat_10_mbed_output,
+    nat_11_mbed___init__,
+    nat_12_mbed_read_u16,
+    nat_13_mbed_read,
+    nat_14_mbed___init__,
+    nat_15_mbed_write_u16,
+    nat_16_mbed_write,
+    nat_17_mbed_read,
+    nat_18_mbed___init__,
+    nat_19_mbed_write,
+    nat_20_mbed_read,
+    nat_21_mbed_period,
+    nat_22_mbed_period_ms,
+    nat_23_mbed_period_us,
+    nat_24_mbed_pulsewidth,
+    nat_25_mbed_pulsewidth_ms,
+    nat_26_mbed_pulsewidth_us,
+    nat_27_mbed___init__,
+    nat_28_mbed_baud,
+    nat_29_mbed_readable,
+    nat_30_mbed_writeable,
+    nat_31_mbed_putc,
+    nat_32_mbed_puts,
+    nat_33_mbed_getc,
+    nat_34_mbed___init__,
+    nat_35_mbed_format,
+    nat_36_mbed_frequency,
+    nat_37_mbed_write,
+    nat_38_mbed___init__,
+    nat_39_mbed_frequency,
+    nat_40_mbed_read,
+    nat_41_mbed_write,
+    nat_42_mbed___init__,
+    nat_43_mbed_start,
+    nat_44_mbed_stop,
+    nat_45_mbed_reset,
+    nat_46_mbed_read,
+    nat_47_mbed_read_ms,
+    nat_48_mbed_read_us,
 };