I am a student in Computer Science, and I am learning about logic programming with Pascal.
I have found an interesting Pascal to PHP transpiler (http://en.wikipedia.org/wiki/Source-to-source_compiler), pas2php (http://www.wascal.net/pas2php/).
On their webpage, they have written:
Pas2Php will convert Object Pascal to PHP, alowing you to write web applications using Lazarus/FreePascal, and then run the application on a standard HTML/PHP server.
As a guide as to what Pas2Php can achieve... this web page was written in Pascal, and then converted to PHP. (The code is in the source package) Pas2Php uses the Pascal Parse Tree Classes (PasTree) which comes with FreePascal, and therefore the parsing limits are defined by this library. So far, most of the core Object Pascal language features are compete, but there is still a lot of work needed before I''d class this tool as being "ready".');
You can download the lastest source of Pas2Php from this site which includes an example project. There isn't much documentation, so, if you want to use Pas2Php, you will have to experiment with the code.
I have downloaded it, but there is no useful information in their documentation. Because I don't understand their documentation, so, tried to compiled it.
I have opened and compiled project.lpi with Lazarus 1.4.0. Then index.cgi has been created on disk. When I run it with Command Prompt, it printed into screen:
Pas2Php v0.4
Converts Standard Pascal to PHP
Copyright (C) 2014 Derek John Evans
The unit 'index' is up to date.
The unit 'P2PHtml' is up to date.
The unit 'P2PSystem' is up to date.
The unit 'P2PStringList' is up to date.
The unit 'PageColumnRight' is up to date.
The unit 'SiteDefines' is up to date.
The unit 'TabSheetBuzz' is up to date.
The unit 'TabSheetContacts' is up to date.
The unit 'TabSheetCredits' is up to date.
The unit 'TabSheetGeep' is up to date.
The unit 'HtmlSoftwareList' is up to date.
The unit 'TabSheetPas2Php' is up to date.
The unit 'TabSheetPas2PhpExamples' is up to date.
The unit 'TabSheetPas2PhpFeatures' is up to date.
The unit 'TabSheetWascal' is up to date.
Package conversion complete.
Then, my browser go to: http://localhost:8008/index.php. They return nothing.
How to compile and run pas2php from source code?.
You probably need to open the project.lpi in project/ with lazarus.
(In response to the edits:)
It seems that the archive also already contained the example converted from pascal to php, and you now generated it again.
So probably you now need to setup your PHP installation and make it find the generate PHP and start playing with it. Good luck!
Related
I don't have formal VS training, and I usually use it to program simple tools for my research. (I'm a faculty member).
I'm currently working on a C++ library for Python using SWIG, so I followed the steps suggested in How to create a DLL with SWIG from Visual Studio 2010?
Step no. 25 says "You can't build the Debug version unless you build a debug version of Python itself", but I thought one should be able to build a debug version of the C++ stuff by writing a main that uses the library from C++ itself, without touching Python or involving Python at all. (Please let me know if I'm wrong.)
A while ago I tried creating two projects in one solution (one for the library, one for a testing app), but I wasn't quite convinced with the result, so I thought it was time to try configurations. I modified the Debug config for my SWIG project following the suggestions in Redifining C/C++ entry point in Microsoft Visual Studio 2015 and the comments (changed configuration type, extension, and entry point, and added additional dependencies vcruntimed.lib and ucrtd.lib, also excluded from build the .i and the _wrap.cxx files).
The project compiles and runs, but the methods/functions in the standard <random> C++ library are returning non-random numbers. Update/clarification: In the following code,
std::normal_distribution<double> rand::distn(0, 1);
std::uniform_real_distribution<double> rand::distu(0, 1);
std::mt19937_64 rand::generator;
void rand::init() {
generator.seed((unsigned long)time(NULL));
}
double rand::u01()
{
return distu(generator);
}
the function u01() returns 0.0 always, while when calling it from Python it works as expected.
I checked the code and the generator is being seeded correctly. Also the library is still working fine from Python, so I tend to think this is not a coding but a configuration issue.
I know this would make a better question if I posted a minimal working example, but before investing time (which I think I don't have) on it I was wandering if there is something obvious I'm missing, that a more knowledgeable VS user could easily spot. Please don't get me wrong, if I'm mistaken and the answer is not so apparent, I'll really try to make the time.
Thanks in advance.
I am using rtags which is a C++ source code indexer based on clang. I have been able to play around with it and now I want to actually index the firefox source code. I am pretty new to this stuff and this tool uses cmake to generate a compile_commands.json file to pass over to the program that indexes code.
Is there a way I can generate a the compile_commands.json file for the firefox source code that provides the exact compilation line for each translation unit inside the firefox source?
You can generate compile_commands.json by
mozilla_cnetral/mach build-backend -b CompileDB
In my environment(Ubuntu 16.04), it was created at mozilla_cnetral/obj-x86_64-pc-linux-gnu/.
Reference:
https://developer.mozilla.org/en-US/docs/Developer_Guide/Editor_Configuration#rtags_(LLVMClang-based_Code_Indexing)
Not sure if I follow the part "Is there a way I can generate a the compile_commands.json file for the firefox source code that provides the exact compilation line for each translation unit inside the firefox source?". But I can offer simply that you can generate a compile_commands.json file from a make-based system using the bear utility (which I obtained from my package manager: brew). After a make clean, I do 'bear --append make' and it traces the make build process and produces the compile_commands.json. More can be learned here: https://vxlabs.com/2016/04/11/step-by-step-guide-to-c-navigation-and-completion-with-emacs-and-the-clang-based-rtags/
As the article referenced implies, my motivation was to be able to use the wonderful rtag system inside Emacs. Hope this helps a bit.
I have been unable to find any information how would one replace Processing IDE with Visual Studio 2015 Community.
Is it even possible to replace it, if yes then how?
Processing is a couple of things:
A set of tools that convert "Processing code" into Java code, or JavaScript code with Processing.js.
An IDE that lets you write Processing code and use those tools.
A Java library (and JavaScript, for Processing.js) that is called by that converted code.
That third thing is what you care about. You can use Processing as a Java library the same way you can use any Java library. Here is a tutorial on using it from eclipse.
The steps to use it with Visual Studio will be similar: find the Processing library jar (probably called core.jar), add it to your classpath, and then write Java code that uses the classes from that library jar.
However, I will say that you should know what you're doing with both Java and Processing before trying this. Processing's IDE is designed to make things as simple as possible, so it hides a lot of behind-the-scenes stuff from you. You have to be comfortable with the idea of using an API, OOP, and setting up the classpath.
Also note that Processing 3 has changed a bunch of things, so certain aspects of that tutorial are out of date. Most notably, PApplet no longer extends Applet, so you can't treat it as a component anymore. You have to go through its Surface instead. If you have no idea what I'm talking about, it might be a better idea to stick with Processing's included IDE.
Considering we doesn't to provide the source code to the customer (by any reason) regarding ZendGuard or Ion Cube which is used, i also heard about the HipHop which compiles php codes into java byte codes.
So do you think if it is right solution to use HHVM just compile my codes into byte codes then remove php files and everything work just fine?
I used codeignter which i saw 100% compatibility with HHVM in it's website.
HipHop expects the PHP source. You cannot remove the source files.
It is not a byte code compiler and should not be compared to Java's redistributable bytecode. HipHop is a runtime environment where PHP is JIT accelerated.
PHP is a dynamic typed language, so it's difficult to generate efficient machine code. HipHop observes the execution paths of PHP scripts over a period of time and makes a pretty good guess. You could turn on Authoritative mode, so that the file is read in once, and never expect to be changed. Even so, the JIT needs to be warmed up.
If you want to deliver a bytecode format of PHP, use a OpCache product instead of HHVM. But it's just not the same.
HipHop expects the PHP source. You cannot remove the source files.
It is not a byte code compiler and should not be compared to Java's redistributable bytecode.
You do can tell it to byte code compile PHP files to a SQLite file.
https://github.com/facebook/hhvm/wiki/Running-PHP-programs-with-HHVM#using-repoauthoritative-mode
I use VS2010 for C++ development, and I often end up doing work in some dll project and after everything compiles nicely I would like to try to run dummy data on some classes, but ofc the fact that it is a dll and not an exe with main makes that a no go. So is there a simple way to do what I want, or Im cursed till eternity to c/p parts of a big project into small testing one?
Ofc changing the type of the project also works, but I would like to have some almost like iteractive shell way of testing functions.
I know this isn't a library or anything, but if you want to run the dll on windows simply without framing it into anything, or writing a script, you can use rundll32.exe within windows. It allows you to run any of the exported functions in the dll. The syntax should be similiar to:
rundll32.exe PathAndNameofDll,exportedFunctionName [ArgsToTheExportedFunction]
http://best-windows.vlaurie.com/rundll32.html -- is a good simple still relevant tutorial on how to use this binary. Its got some cool tricks in there that may surprise you.
If you are wondering about a 64-bit version, it has the same name (seriously microsoft?) check it out here:
rundll32.exe equivalent for 64-bit DLLs
Furthermore, if you wanted to go low level, you could in theory utilize OllyDbg which comes with a DLL loader for running DLL's you want to debug (in assembly), which you can do the same type of stuff in (call exported functions and pass args) but the debugger is more for reverse engineering than code debugging.
I think you have basically two options.
First, is to use some sort of unit tests on the function. For C++ you can find a variety of implementations, for one take a look at CppUnit
The second option is to open the DLL, get the function via the Win32API and call it that way (this would still qualify as unit testing on some level). You could generalize this approach somewhat by creating an executable that does the above parametrized with the required information (e.g. dll path, function name) to achieve the "interactive shell" you mentioned -- if you decide to take this path, you can check out this CodeProject article on loading DLLs from C++
Besides using unit tests as provided by CppUnit, you can still write your own
small testing framework. That way you can setup your Dll projects as needed,
load it, link it, whatever you want and prove it with some simple data as
you like.
This is valueable if you have many Dlls that depend on each other to do a certain job.
(legacy Dlls projects in C++ tend to be hardly testable in my experience).
Having done some frame application, you can also inspect the possibilities that
CppUnit will give you and combine it with your test frame.
That way you will end up with a good set of automated test, which still are
valueable unit tests. It is somewhat hard starting to make unit tests if
a project already has a certain size. Having your own framework will let you
write tests whenever you make some change to a dll. Just insert it into your
framework, test what you expect it to do and enhance your frame more and more.
The basic idea is to separate the test, the testrunner, the testdata and the asserts
to be made.
I’m using python + ctypes to build quick testing routines for my DLL applications.
If you are using the extended attribute syntax, will be easy for you.
Google for Python + ctypes + test unit and you will find several examples.
I would recommend Window Powershell commandlets.
If you look at the article here - http://msdn.microsoft.com/en-us/magazine/cc163430.aspx you can see how easy it is to set up. Of course this article is mostly about testing C# code, but you can see how they talk about also being able to load any COM enabled DLL in the same way.
Here you can see how to load a COM assembly - http://blogs.technet.com/b/heyscriptingguy/archive/2009/01/26/how-do-i-use-windows-powershell-to-work-with-junk-e-mail-in-office-outlook.aspx
EDIT: I know a very successful storage virtualization software company that uses Powershell extensively to test both it's managaged and unmanaged (drivers) code.