OpenCores
URL https://opencores.org/ocsvn/qaz_libs/qaz_libs/trunk

Subversion Repositories qaz_libs

[/] [qaz_libs/] [trunk/] [BFM/] [sim/] [tests/] [tb_video_frame_dpi/] [py_dpi.c] - Diff between revs 43 and 44

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 43 Rev 44
Line 56... Line 56...
{
{
  int va_y = svSize(va, 1);
  int va_y = svSize(va, 1);
  int va_x = svSize(va, 2);
  int va_x = svSize(va, 2);
 
 
  printf("^^^ | c_get_array() | %dx%d\n", va_x, va_y);
  printf("^^^ | c_get_array() | %dx%d\n", va_x, va_y);
 
 
  g_va = (unsigned int *)svGetArrElemPtr2(va, 0, 0);
  g_va = (unsigned int *)svGetArrElemPtr2(va, 0, 0);
 
 
  PyObject *pmeth = PyObject_GetAttrString(g_dva_i, "py_get_array");
  PyObject *pmeth = PyObject_GetAttrString(g_dva_i, "py_get_array");
  // pargs  = Py_BuildValue("(ss)", arg1, arg2); /* convert to Python */
  // pargs  = Py_BuildValue("(ss)", arg1, arg2); /* convert to Python */
  // PyObject *pres = PyEval_CallObject(pmeth, pargs); /* call method(x,y) */
  // PyObject *pres = PyEval_CallObject(pmeth, pargs); /* call method(x,y) */
  PyObject *pres = PyEval_CallObject(pmeth, NULL);
  PyObject *pres = PyEval_CallObject(pmeth, NULL);
 
 
  Py_DECREF(pmeth);
  Py_DECREF(pmeth);
  // Py_DECREF(pargs);
  // Py_DECREF(pargs);
  Py_DECREF(pres);
  Py_DECREF(pres);
}
}
 
 
// --------------------------------------------------------------------
// --------------------------------------------------------------------
 
#define MAX_ARGV 4
 
 
int py_run_file
int py_run_file
( const char *filename
( const char *filename
, int argc
, int argc
, const svOpenArrayHandle args
, const svOpenArrayHandle args
)
)
{
{
  printf("^^^ | py_run_file | %s |\n", filename);
  printf("^^^ | py_run_file | %s |\n", filename);
 
 
  char *argv[4];  // limit of 4 args
  wchar_t *w_argv[MAX_ARGV];  // limit of MAX_ARGV args
  int i;
  int i;
  for(i = 0; i < argc && i < 4; i++)
  for(i = 0; i < argc && i < MAX_ARGV; i++)
  {
    w_argv[i] = Py_DecodeLocale(*((char **)svGetArrElemPtr1(args, i)), NULL);
    argv[i] = *(char **)svGetArrElemPtr1(args, i);
 
    printf( "^^^ | py_run_file | args[%d] = %s\n"
 
          , i
 
          , argv[i]
 
          );
 
  }
 
 
 
  PySys_SetArgv(argc, argv);
  PySys_SetArgv(argc, w_argv);
  PyObject *PyFileObject = PyFile_FromString((char *)filename, "r");
 
  return PyRun_SimpleFileEx(PyFile_AsFile(PyFileObject), filename, 1);
  char pre_string[] = "exec(open('./";
 
  char post_string[] = "').read())";
 
  char v_filename[] = "try_it.py";
 
  unsigned int size = (sizeof(pre_string) + sizeof(post_string)) * sizeof(char);
 
  size += strlen(filename);
 
  char *run_string = (char *)malloc(size);
 
  sprintf(run_string, "%s%s%s", pre_string, filename, post_string);
 
 
 
  PyRun_SimpleString(run_string);
 
  free(run_string);
 
  return 0;
}
}
 
 
// --------------------------------------------------------------------
// --------------------------------------------------------------------
 
extern PyMODINIT_FUNC PyInit_py_to_video_frame(void);
 
 
void init_py_dpi(int width, int height)
void init_py_dpi(int width, int height)
{
{
  printf("^^^ | init_py_dpi() | %dx%d\n", width, height);
  printf("^^^ | init_py_dpi() | %dx%d\n", width, height);
 
 
 
  PyImport_AppendInittab("py_to_video_frame", PyInit_py_to_video_frame);
  Py_Initialize();
  Py_Initialize();
  init_py_to_video_frame();
 
 
  PyObject *sys = PyImport_ImportModule("sys");
 
  PyObject *path = PyObject_GetAttrString(sys, "path");
 
  PyList_Append(path, PyUnicode_FromString("."));
 
 
  PyObject *dva_m = PyImport_ImportModule("dpi_video_array");
  PyObject *dva_m = PyImport_ImportModule("dpi_video_array");
  if(!dva_m)
  if(!dva_m)
  {
  {
      PyErr_Print();
      PyErr_Print();

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.