Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrent generation C++ files #13

Open
0xF6 opened this issue Dec 4, 2020 · 3 comments
Open

Incorrent generation C++ files #13

0xF6 opened this issue Dec 4, 2020 · 3 comments

Comments

@0xF6
Copy link
Collaborator

0xF6 commented Dec 4, 2020

i try compile follow code

package;
class Main {
    public function setup() {
        Arduino.pinMode(Arduino.LED_BUILTIN, Arduino.OUTPUT);
    }
    public function loop() {
        Arduino.digitalWrite(Arduino.LED_BUILTIN, Arduino.HIGH);
        var s = [1,2,3,4];
        var w = [4,5];
        var d = s.concat(w);
        Arduino.delay(1000);
        Arduino.digitalWrite(Arduino.LED_BUILTIN, Arduino.LOW);
        Arduino.delay(1000);
    }
    static function main() { }
}

and I get following C++ code:

Main.cpp
#include "Main.h"
#include <Arduino.h>

#define Util_addressOf(x) (byte*)&x

void Main::setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void Main::loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    LinkedList<int> s;
    s.add(1);
    s.add(2);
    s.add(3);
    s.add(4);

    LinkedList<int> w;
    w.add(4);
    w.add(5);

    LinkedList<int> d = s.concat(w);
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
}
void Main::main() {

}
Main.h
#ifndef Main_h_
#define Main_h_ 1


class Main {
    public:

        void setup();
        void loop();
        static void main();
};

#endif

And i see, LinkedList.h is not include in h file, but file available in include output

image

I'm sorry, you must be tired of me, but im in process of learning haxe, so I can't really help with pull requests :(

@0xF6
Copy link
Collaborator Author

0xF6 commented Dec 4, 2020

Maybe follow code is reason?

@0xF6
Copy link
Collaborator Author

0xF6 commented Dec 4, 2020

Yes, i'il try uncomment addRef and get following code:

#include "Main.h"
#include <Arduino.h>
#include <LinkedList.h>

#define Util_addressOf(x) (byte*)&x

void Main::setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void Main::loop() {
    digitalWrite(LED_BUILTIN, HIGH);
    LinkedList<int> s;
    s.add(1);
    s.add(2);
    s.add(3);
    s.add(4);

    LinkedList<int> w;
    w.add(4);
    w.add(5);

    LinkedList<int> d = s.concat(w);
    delay(1000);
    digitalWrite(LED_BUILTIN, LOW);
    delay(1000);
}

void Main::main() {
}

but compiler throw error because method concat is not defined in LinkedList :\

C:/git/hxArduino/examples/01-blink/build/hxArduino/src/Main.cpp:23:27: error: 'class LinkedList<int>' has no member named 'concat'
     LinkedList<int> d = s.concat(w);
                           ^~~~~~
In file included from C:/git/hxArduino/examples/01-blink/build/hxArduino/src/Main.cpp:3:0:
C:/git/hxArduino/examples/01-blink/build/hxArduino/include/LinkedList.h: In instantiation of 'ListNode<T>* LinkedList<T>::getNode(int) [with T = int]':
C:/git/hxArduino/examples/01-blink/build/hxArduino/include/LinkedList.h:185:22:   required from 'bool LinkedList<T>::add(int, T) [with T = int]'
C:/git/hxArduino/examples/01-blink/build/hxArduino/src/Main.cpp:30:1:   required from here
C:/git/hxArduino/examples/01-blink/build/hxArduino/include/LinkedList.h:167:9: error: cannot convert 'bool' to 'ListNode<int>*' in return
  return false;
         ^~~~~
COMPILATION FAILED!

@ianharrigan
Copy link
Owner

Hi yeah, there are going to be things like this quite alot i think, where certain functions in haxe havent been mapped to some type of simple equivalent in hxArduino. Ive added concat now (and and c++ copy constructor) to LinkedList... i havent tested it on a device yet as ill have to hook one up (which will have to wait until later).

Ive also uncommented that addRef... my guess is it was commented out for a reason, but not 100% sure what that is / was now! Let see what happens in the future!

Cheers,
Ian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants