Re: vibe.d get body of HTTPServerResponse

2020-11-02 Thread JG via Digitalmars-d-learn
On Monday, 2 November 2020 at 17:02:01 UTC, Steven Schveighoffer 
wrote:

On 11/2/20 10:10 AM, JG wrote:

I am trying to get the body the response generated by:

res.render!("index.dt");

where res is of type HTTPServerResponse

Does anyone know how I might go about this?



That is a convenience wrapper to diet-ng:

https://github.com/vibe-d/vibe.d/blob/70b50fdb9cd4144f1a5007b36e6ac39d4731c140/http/vibe/http/server.d#L337-L346

Instead, create your own output range (maybe a char[] 
appender?) and compile to that yourself:


import diet.html : compileHTMLDietFile;
import std.array : appdender;

auto app = appender!(char[]);
compileHTMLDietFile!("index.dt")(app);

auto resultingHTML = app.data;

-Steve


Thank you very much.


Re: vibe.d get body of HTTPServerResponse

2020-11-02 Thread Steven Schveighoffer via Digitalmars-d-learn

On 11/2/20 10:10 AM, JG wrote:

I am trying to get the body the response generated by:

res.render!("index.dt");

where res is of type HTTPServerResponse

Does anyone know how I might go about this?



That is a convenience wrapper to diet-ng:

https://github.com/vibe-d/vibe.d/blob/70b50fdb9cd4144f1a5007b36e6ac39d4731c140/http/vibe/http/server.d#L337-L346

Instead, create your own output range (maybe a char[] appender?) and 
compile to that yourself:


import diet.html : compileHTMLDietFile;
import std.array : appdender;

auto app = appender!(char[]);
compileHTMLDietFile!("index.dt")(app);

auto resultingHTML = app.data;

-Steve


vibe.d get body of HTTPServerResponse

2020-11-02 Thread JG via Digitalmars-d-learn

I am trying to get the body the response generated by:

res.render!("index.dt");

where res is of type HTTPServerResponse

Does anyone know how I might go about this?



Re: Druntime undefined references

2020-11-02 Thread IGotD- via Digitalmars-d-learn

On Monday, 2 November 2020 at 10:50:06 UTC, Severin Teona wrote:

Hi guys!

I build the druntime for an ARM Cortex-M based microcontroller 
and I trying to create an application and link it with the 
druntime. I am also using TockOS[1], which does not implement 
POSIX thread calls and other OS-dependent implementations. As I 
was looking through the errors I got, I found some functions 
and I don’t know what they do, or how should I solve the errors.


The first one is:
libdruntime-ldc.a(dwarfeh.o): in function 
`_d_eh_personality_common': 
dwarfeh.d:(.text._d_eh_personality_common[_d_eh_personality_common]+0x2c): undefined reference to `_d_eh_GetIPInfo'


and the second one is:
dl.d:(.text._D4core8internal3elf2dl12SharedObject14thisExecutableFNbNiZSQCgQCeQByQBxQBx[_D4core8internal3elf2dl12SharedObject14thisExecutableFNbNiZSQCgQCeQByQBxQBx]+0x1a):
 undefined reference to `dl_iterate_phdr'
(the druntime was build as a static library, because I can’t 
use dynamic libraries on a microcontroller)


Does anyone know what these exactly do and how 
important/essential are they? Is there any way I could solve 
them?


Thank a lot.

[1]: https://www.tockos.org


https://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html

dl_iterate_phdr is used to iterate over the elf program headers 
and is used to get a textual back trace among other things. These 
are typically calls found in Linux systems and if you don't have 
that, you have to replace them with your own calls or just remove 
the call all together.


Much of the elf stuff can be removed. The only things that might 
be essential is that druntime needs to know where the TLS data is 
per thread for scanning.




Re: Druntime undefined references

2020-11-02 Thread drug via Digitalmars-d-learn

On 11/2/20 1:50 PM, Severin Teona wrote:

Hi guys!

I build the druntime for an ARM Cortex-M based microcontroller and I 
trying to create an application and link it with the druntime. I am also 
using TockOS[1], which does not implement POSIX thread calls and other 
OS-dependent implementations. As I was looking through the errors I got, 
I found some functions and I don’t know what they do, or how should I 
solve the errors.


The first one is:
libdruntime-ldc.a(dwarfeh.o): in function `_d_eh_personality_common': 
dwarfeh.d:(.text._d_eh_personality_common[_d_eh_personality_common]+0x2c): 
undefined reference to `_d_eh_GetIPInfo'


and the second one is:
dl.d:(.text._D4core8internal3elf2dl12SharedObject14thisExecutableFNbNiZSQCgQCeQByQBxQBx[_D4core8internal3elf2dl12SharedObject14thisExecutableFNbNiZSQCgQCeQByQBxQBx]+0x1a): 
undefined reference to `dl_iterate_phdr'
(the druntime was build as a static library, because I can’t use dynamic 
libraries on a microcontroller)


Does anyone know what these exactly do and how important/essential are 
they? Is there any way I could solve them?


Thank a lot.

[1]: https://www.tockos.org



cant' help much but just in case - see 
https://github.com/ldc-developers/ldc/pull/2405#issuecomment-346187456, 
may be it helps


also you can define this symbol yourself with assert(0) to check if it 
is called at all


what about  - quick glance at 
https://linux.die.net/man/3/dl_iterate_phdr says us that this symbol is 
used only with shared objects so you can try to define it yourself with 
assert(0) like this (not tested!!!):

```D
extern(C):
alias Callback = int function (void*, size_t, void*);
int dl_iterate_phdr(Callback callback, void* data)
{
assert(0);
}
```
this lets you to link druntime at least and if those symbols were called 
abort the execution


Druntime undefined references

2020-11-02 Thread Severin Teona via Digitalmars-d-learn

Hi guys!

I build the druntime for an ARM Cortex-M based microcontroller 
and I trying to create an application and link it with the 
druntime. I am also using TockOS[1], which does not implement 
POSIX thread calls and other OS-dependent implementations. As I 
was looking through the errors I got, I found some functions and 
I don’t know what they do, or how should I solve the errors.


The first one is:
libdruntime-ldc.a(dwarfeh.o): in function 
`_d_eh_personality_common': 
dwarfeh.d:(.text._d_eh_personality_common[_d_eh_personality_common]+0x2c): undefined reference to `_d_eh_GetIPInfo'


and the second one is:
dl.d:(.text._D4core8internal3elf2dl12SharedObject14thisExecutableFNbNiZSQCgQCeQByQBxQBx[_D4core8internal3elf2dl12SharedObject14thisExecutableFNbNiZSQCgQCeQByQBxQBx]+0x1a):
 undefined reference to `dl_iterate_phdr'
(the druntime was build as a static library, because I can’t use 
dynamic libraries on a microcontroller)


Does anyone know what these exactly do and how 
important/essential are they? Is there any way I could solve them?


Thank a lot.

[1]: https://www.tockos.org