Anonymous
Can I post stack overflow link here ?
Anonymous
I want save op_array (c program) for PHP .
Anonymous
It is PHP byte code
Anonymous
Please check PHP c source code
Igor🇺🇦
Please check PHP c source code
Why do you need to save it to file? You can call C/C++ code from PHP and back
Anonymous
I am developing c extension
Anonymous
How to serialize c pointer struct with simple function
Anonymous
Can I use mmap ?
Dima
Lol
Igor🇺🇦
I am developing c extension
What is a C extensions? I've heard of PHP extension, but don't know what C extension is. Anyway - if you want to serialize anything you need to come up with some standard representation of your data structure. You can't just save it as it is in a memory. For example pointers are meaningless in a different process that will read your "save"
Anonymous
struct _zend_op { const void *handler; znode_op op1; znode_op op2; znode_op result; uint32_t extended_value; uint32_t lineno; zend_uchar opcode; zend_uchar op1_type; zend_uchar op2_type; zend_uchar result_type; }; struct _zend_op_array { /* Common elements */ zend_uchar type; zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */ uint32_t fn_flags; zend_string *function_name; zend_class_entry *scope; zend_function *prototype; uint32_t num_args; uint32_t required_num_args; zend_arg_info *arg_info; /* END of common elements */ int cache_size; /* number of run_time_cache_slots * sizeof(void*) */ int last_var; /* number of CV variables */ uint32_t T; /* number of temporary variables */ uint32_t last; /* number of opcodes */ zend_op *opcodes; ZEND_MAP_PTR_DEF(void , run_time_cache); ZEND_MAP_PTR_DEF(HashTable *, static_variables_ptr); HashTable *static_variables; zend_string vars; /* names of CV variables */ uint32_t *refcount; int last_live_range; int last_try_catch; zend_live_range *live_range; zend_try_catch_element *try_catch_array; zend_string *filename; uint32_t line_start; uint32_t line_end; zend_string *doc_comment; int last_literal; zval *literals; void *reserved[ZEND_MAX_RESERVED_RESOURCES]; };
Francisco
Format the code
Honestly, I don't think it would make much more difference hahaha
Dima
Indeed
Anonymous
Anonymous
Please check attached file
Dima
So?
Dima
Doesn’t tell anything
Anonymous
Formated code
Dima
So?
Dima
Learn the basics first
Anonymous
struct _zend_op { const void * handler; znode_op op1; znode_op op2; znode_op result; uint32_t extended_value; uint32_t lineno; zend_uchar opcode; zend_uchar op1_type; zend_uchar op2_type; zend_uchar result_type; }; struct _zend_op_array { /* Common elements */ zend_uchar type; zend_uchar arg_flags[3]; /* bitset of arg_info.pass_by_reference */ uint32_t fn_flags; zend_string * function_name; zend_class_entry * scope; zend_function * prototype; uint32_t num_args; uint32_t required_num_args; zend_arg_info * arg_info; /* END of common elements */ int cache_size; /* number of run_time_cache_slots * sizeof(void*) */ int last_var; /* number of CV variables */ uint32_t T; /* number of temporary variables */ uint32_t last; /* number of opcodes */ zend_op * opcodes; ZEND_MAP_PTR_DEF(void , run_time_cache); ZEND_MAP_PTR_DEF(HashTable * , static_variables_ptr); HashTable * static_variables; zend_string vars; /* names of CV variables */ uint32_t * refcount; int last_live_range; int last_try_catch; zend_live_range * live_range; zend_try_catch_element * try_catch_array; zend_string * filename; uint32_t line_start; uint32_t line_end; zend_string * doc_comment; int last_literal; zval * literals; void * reserved[ZEND_MAX_RESERVED_RESOURCES]; };
Anonymous
Can I save data without Serialization ?
Dima
/warn long code snippet
Dayum I wanted to
Dima
Learn the basics first before writing a code
Anonymous
Thank you
Igor🇺🇦
Arshid what is the problem you're trying to solve?
Anonymous
Making cache PHP extension
Anonymous
I think, I need add data one by one, am I right ?
Anonymous
Any simple serialization library available? Like seriouse(op_array) like;
Igor🇺🇦
Making cache PHP extension
Generic serialization is not easy. You need to tell what should and shouldn't be saved. I'm not familiar with PHP very well, but it knows how to save PHP classes. Why do you need C? In short - somebody has to describe how to save every structure in your specific object.
Anonymous
I want save all elements in op_array
Igor🇺🇦
Why do you need this specific structure? Can't you save only relevant data and re build this object afterwards?
Anonymous
zend_op is array.
Anonymous
I am confused, how to save this zend_op array
Igor🇺🇦
I think you need to go to drawing board and redesign whatever you are trying to do. This requires deep understanding of PHP. Can't help you with that. Sorry ☹️
Anonymous
@LaurenSyme i think you are not supposed to be here😂😂.
Fabio
Hi, everyone...i've a dumb question to do
Fabio
I'm trying to concatenate an int to a const char *, I've try a thousands of way to do that...so which is the best method to that?
Fabio
And when I cast the integer, what happened, I mean something is put before or after the number?
你那個朋友
if performance is not much an issue, one can simply std::to_string(the int).c_str()
Artöm
Anyway use sprintf and preallocated buffer
Fabio
Serhii
c++11
std::stringstream
Fabio
I used ("imu" + std::to_string(i)).c_str() or strcat("imu_" ,std::to_string(i).c_str())
Artöm
Use std::string and either std::to_string or std::to_chars
Artöm
c++11
Why char* then?
Fabio
Publisher(const char * topic_name, Msg * msg, int endpoint = rosserial_msgs::TopicInfo::ID_PUBLISHER) :
Fabio
i don't know, this is the constructor i'm using from ros_lib
Artöm
Why not std::string?
Artöm
Well, use 17
Fabio
Like to_chars(i)
Artöm
Nope, read the docs
Fabio
What are you trying to achieve? 🤷‍♂️
i wanna build some ros topic with different topic names created runtime
Fabio
like "imu_1" "imu_2" and so on
Fabio
using rosserial_arduino, but rosserial_server crash launching an exception saying that topic name is not valid (I think it is somenthing related to the cast, which made strange character)
Igor🇺🇦
You need to concatenate strings not add something to char*
Fabio
So just use string("...") +...
+i or a cast to string of i?
Fabio
i is a number
Igor🇺🇦
+i or a cast to string of i?
If I is int use std::to_string(i)
Fabio
Okay it seems to work let me debug for a while
Manish
Hi, I am using Google protobuf 3 . I don't have any idea what protoc generate. I need help. Anyone plz?
Asdew
Will there ever be #duckit?
Manish
I have tried and successfully ran example given at GitHub. But when I am using with my own code then getting segmentation fault error.
Artöm
There could be lots of reasons for segfault. Debug it
Artöm
With gdb or debug prints
Artöm
Or vs debugger if youre windows user
Igor🇺🇦
Will there ever be #duckit?
https://lmgtfy.com/?q=protobuf+3+tutorial&s=d&iie=1