Forum Replies Created
-
AuthorPosts
-
October 7, 2014 at 12:52 pm in reply to: Save and compile in code editor does not save lua code into panel #30232
Oh ok. Is the Ctrlr state then written to disk immediately somewhere, in case there is a crash after a change in a lua method ? (very common during development :P)
I see that you added luasocket in https://github.com/RomanKubiak/ctrlr/commit/86a1b7e21dc2e40e535b71990126f5230b681dff
I am yet to test this out, but does the debug library show stack traces and allow stepping through the code in Ctrlr now ?
September 26, 2014 at 12:29 pm in reply to: How do I add lua extensions/libraries to the Ctrlr Lua version ? #29579Yeah actually it was friend of mine. We are both using Ctrlr 🙂
I ll send in a request too.
September 26, 2014 at 4:32 am in reply to: How do I add lua extensions/libraries to the Ctrlr Lua version ? #29559Wow thanks atom 🙂 ! I ll test it out today.
If I want to contribute to Ctrlr through C/C++ code and lua, then do I need to fork your repo in Github ? Then do commits in the fork and initiate pull requests for you ?
September 25, 2014 at 2:32 pm in reply to: LSlider:setValue() does not have NotificationType exposed #29516Thanks so much.
I was wondering if an external editor with remote debugging capabilities like ZeroBrane https://studio.zerobrane.com/features.html
…could be supported by Ctrlr. Zerobrane has the ability to connect to a running Lua interpreter that has debugging support. If the Lua interpreter itself is compiled with Lua debugging support then it opens a socket to which an external debugger can connect.
So the idea would be that breakpoints are set in the Lua code in an external debugger. Then when the breakpoints are hit then the lua interpretor is frozen in Ctrlr and the user can examine the stack, variables etc.
The source code info would need to be conveyed to the external debugger of course so we would need the source code to be available in a file. Perhaps the lua methods for a panel can be read from a .lua file instead of being read from the .panel file. Then this file can simply be dropped into the external IDE/debugger.
Furthermore code editing can be done there too and whenever the user saves the file, the file can be compiled into Ctrlr by CtrlrLuaManager.
Of course before this we need to move Ctrlr to LuaJIT.
September 24, 2014 at 6:05 am in reply to: ThreadWithProgressWindow's setThreadFunction is failing #29452Thanks Atom,
It works well. I am bit newbie for Lua, Hope to catch up soon with it as well.
Thanks !
Thanks it works now. Do you know if we can pass native arrays back end forth.
Like if we have a C++ function which returns an array of doubles :
double[] doTask(void)
Can we call this in Lua and receive the array ? Or do we need to put the doubles in a StringArray and return that ?
ok, so I have tried. The problem is that when I return a StringArray from C++(not a StringArray & ), then it does get created in the lua side as expected. But I cant read its values using :
sa = obj:callback() val = sa:get(0) ERROR: No matching overload found, candidates: String get(custom [class LStringArray]&,int)
If you have a function in C++ side that returns a StringArray then are you able to read out the values in the StringArray using get() after you call the function ?
- This reply was modified 9 years, 7 months ago by synth.
oh wait, I did not see your reply, reading it now 🙂
————–
ok, you are right I should not be passing back references from C++ into Lua. If the object is destroyed in the C++ side by any chance, then lua might still have that reference and cause a crash if its used in lua code.
So yeah I ll try now with :
StringArray callback(void) {….}- This reply was modified 9 years, 7 months ago by synth.
I think I understand whats happening here.
The JUCE StringArray class allows access to its data through overloading the [] operator. It does not provide a StringArray::get() , so you have provided one via LStringArray::get() in LString.cpp
class_<StringArray, LStringArray>("StringArray") .def(constructor<>()) .def(constructor<const String &>()) .def(constructor<const char *const *, const int>()) .def(constructor<const char *const *>()) .def("size", &StringArray::size) .def("get", &LStringArray::get) .def("contains", &StringArray::contains) ....
Thats fine. But if I were to return a StringArray from a C++ function :
const StringArray& testArray(const StringArray& arr);Its not recognized in lua.
So I solved it by exposing StringArray::operator[] in LString.cpp :
class_<StringArray, LStringArray>("StringArray") .def(constructor<>()) .def(constructor<const String &>()) .def(constructor<const char *const *, const int>()) .def(constructor<const char *const *>()) .def("size", &StringArray::size) .def("getAt", &StringArray::operator[]) <----------- .def("get", &LStringArray::get) .def("contains", &StringArray::contains)
Well I checked the declaration of the C++ function again and it seems I need to make it as :
bool callback(const StringArray& arr) {….}
Now I am able to receive String arrays sent from Lua into C++.
Lets say I want to send a StringArray from C++ to Lua. Thats where I am stuck now:
If I have a C++ function like :const StringArray& callback(<strong>const </strong>StringArray& arr) { return m_saTest; }
This returns a StringArray to Lua. But am not able to read this StringArray in Lua:
sa = callback(testArray);
console(String(sa:get(1)))Error !!
September 4, 2014 at 2:06 pm in reply to: Adding new C++ class to Ctrlr and exposing through Lua #28469ok its working now. Some weird linking error from the VST project.
September 4, 2014 at 11:53 am in reply to: Adding new C++ class to Ctrlr and exposing through Lua #28456That was a parsing error in the forum. Here are the files again in code tags:
cpp:
#include "stdafx.h" #include "Test.h" void Test::wrapForLua (lua_State *L) { using namespace luabind; module(L) [ class_<Test>("Test") .def(constructor<uint32>()) .def("getValue", &getValue) ]; }
Header:
#ifndef __TEST__ #define __TEST__ #include "CtrlrLuaManager.h" class Test { public: Test(int i) {} int getValue() const { return 5; } static void wrapForLua (lua_State *L); }; #endif
The template parameters are there, but I still get the error. Just try dropping them in Source/Lua/JUCEClasses , you will see it.
-
AuthorPosts